Skip to content

Commit

Permalink
fix: use CMake 3.24 & smart downloading
Browse files Browse the repository at this point in the history
Signed-off-by: Henry Schreiner <[email protected]>
  • Loading branch information
henryiii committed Mar 28, 2024
1 parent 9d83cb1 commit a4cc0ae
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
20 changes: 15 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
cmake_minimum_required(VERSION 3.15...3.27)
cmake_minimum_required(VERSION 3.24...3.29)

project(BOOST_HISTOGRAM LANGUAGES CXX)
# Version is added later

include(FetchContent)

# Boost histogram requires C++14
set(CMAKE_CXX_STANDARD
14
Expand Down Expand Up @@ -35,16 +37,24 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
"RelWithDebInfo")
endif()

# Display versions
message(STATUS "CMake ${CMAKE_VERSION}")

# Adding pybind11 and setting up Python
# Will display pybind11 version
set(PYBIND11_FINDPYTHON TRUE)
set(Python_ARTIFACTS_INTERACTIVE TRUE)
add_subdirectory(extern/pybind11)

FetchContent_Declare(
pybind11
GIT_REPOSITORY https://github.com/pybind/pybind11.git
GIT_TAG 3e9dfa2866941655c56877882565e7577de6fc7b # v2.12.0
FIND_PACKAGE_ARGS NAMES pybind11)
FetchContent_MakeAvailable(pybind11)

# Display versions
message(STATUS "CMake ${CMAKE_VERSION}")
message(STATUS "Python ${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}")
if(DEFINED pybind11_VERSION)
message(STATUS "pybind11 ${pybind11_VERSION}")
endif()

# This is completely optional and just adds hints to IDEs - no affect on build at all.
file(GLOB_RECURSE BOOST_HIST_FILES "extern/histogram/include/*.hpp")
Expand Down
1 change: 0 additions & 1 deletion extern/pybind11
Submodule pybind11 deleted from 8a099e
6 changes: 2 additions & 4 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from __future__ import annotations

import argparse
import shutil
from pathlib import Path

import nox

nox.needs_version = ">=2024.3.2"
nox.options.default_venv_backend = "uv|virtualenv"
nox.options.sessions = ["lint", "tests"]


Expand All @@ -15,7 +16,6 @@ def tests(session: nox.Session) -> None:
Run the unit and regular tests.
"""

shutil.rmtree("build", ignore_errors=True)
session.install(".[test]")
session.run("pytest", *session.posargs)

Expand All @@ -26,7 +26,6 @@ def testsnp2(session: nox.Session) -> None:
Run the unit and regular tests with NumPy 2.
"""

shutil.rmtree("build", ignore_errors=True)
session.install(".[test]", "numpy>=2.0a1")
session.run("pytest", *session.posargs)

Expand All @@ -36,7 +35,6 @@ def hist(session: nox.Session) -> None:
"""
Run Hist's test suite
"""
shutil.rmtree("build", ignore_errors=True)
session.install(".")
tmpdir = session.create_tmp()
session.chdir(tmpdir)
Expand Down
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["scikit-build-core[pyproject]"]
requires = ["scikit-build-core[pyproject]", "pybind11"]
build-backend = "scikit_build_core.build"

[project]
Expand Down Expand Up @@ -95,6 +95,8 @@ Homepage = "https://github.com/scikit-hep/boost-histogram"
metadata.version.provider = "scikit_build_core.metadata.setuptools_scm"
sdist.include = ["src/boost_histogram/version.py"]
wheel.expand-macos-universal-tags = true
minimum-version = "0.8"
cmake.version = ">=3.24"


[tool.setuptools_scm]
Expand Down

0 comments on commit a4cc0ae

Please sign in to comment.