diff --git a/.github/workflows/emscripten.yaml b/.github/workflows/emscripten.yaml index ee9b518d..6d6646b9 100644 --- a/.github/workflows/emscripten.yaml +++ b/.github/workflows/emscripten.yaml @@ -46,11 +46,11 @@ jobs: actions-cache-folder: emsdk-cache - name: Build - run: CFLAGS=-fexceptions LDFLAGS=-fexceptions pyodide build + run: CFLAGS=-fexceptions LDFLAGS=-fexceptions pyodide build --exports whole_archive - uses: actions/setup-node@v4 with: - node-version: 18 + node-version: 20 - name: Set up Pyodide virtual environment run: | diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a5d86a61..500a4c23 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -19,7 +19,7 @@ jobs: clang-tidy: name: Clang-Tidy runs-on: ubuntu-latest - container: silkeh/clang:15-bullseye + container: silkeh/clang:18-bookworm steps: - name: Install requirements @@ -31,10 +31,10 @@ jobs: submodules: true - name: Install extra requirements - run: python3 -m pip install setuptools_scm + run: python3 -m pip install setuptools_scm --break-system-packages - name: Configure - run: cmake -S . -B build -DCMAKE_CXX_CLANG_TIDY="$(which clang-tidy);--warnings-as-errors=*" + run: cmake -S. -Bbuild -DCMAKE_CXX_CLANG_TIDY="$(which clang-tidy);--warnings-as-errors=*" - name: Build run: cmake --build build -j 2 @@ -55,6 +55,7 @@ jobs: pipx run nox -s pylint cmake: + name: CMake 🐍 ${{ matrix.python-version }} runs-on: ubuntu-latest env: PIP_ONLY_BINARY: numpy @@ -66,8 +67,6 @@ jobs: - python-version: "3.8" cmake-extras: "-DCMAKE_CXX_STANDARD=17" - name: CMake Python ${{ matrix.python-version }} - steps: - uses: actions/checkout@v4 with: @@ -80,10 +79,10 @@ jobs: allow-prereleases: true - name: Install python tools - run: python -m pip install -r dev-requirements.txt pytest-github-actions-annotate-failures numpy>=2.0a1 + run: python -m pip install -r dev-requirements.txt pytest-github-actions-annotate-failures numpy>=2.0.0rc1 - name: Configure - run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug -DBOOST_HISTOGRAM_ERRORS=ON ${{ matrix.cmake-extras }} + run: cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Debug -DBOOST_HISTOGRAM_ERRORS=ON ${{ matrix.cmake-extras }} - name: Build run: cmake --build build -j 2 @@ -93,12 +92,22 @@ jobs: run: python -m pytest -ra build_wheels: - name: Wheels on ${{ matrix.os }} + name: ${{ matrix.build }} runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: - os: [ubuntu-latest, windows-2019, macos-latest] + include: + - os: ubuntu-latest + build: cp312-manylinux_x86_64 + - os: windows-2019 + build: cp38-win32 + - os: windows-2019 + build: cp37-win_amd64 + - os: macos-13 + build: cp39-macosx_x86_64 + - os: macos-14 + build: cp39-macosx_arm64 steps: - uses: actions/checkout@v4 @@ -106,17 +115,33 @@ jobs: submodules: true fetch-depth: 0 + - uses: actions/setup-python@v5 + with: + python-version: "3.x" + - uses: pypa/cibuildwheel@v2.17 env: - CIBW_BUILD: cp38-win32 cp312-manylinux_x86_64 cp37-macosx_x86_64 + CIBW_BUILD: "${{ matrix.build }}" CIBW_BUILD_VERBOSITY: 1 - CIBW_ENVIRONMENT: "PIP_ONLY_BINARY=:all:" - uses: actions/upload-artifact@v4 with: path: wheelhouse/* name: test-wheels-${{ strategy.job-index }} + # Pipx is either missing or broken on macos-14 runners ATM + - name: Install twine + run: pip install twine + - name: Check wheels - run: pipx run twine check wheelhouse/* + run: twine check wheelhouse/* shell: bash + + pass: + if: always() + needs: [clang-tidy, pylint, cmake, build_wheels] + runs-on: ubuntu-latest + steps: + - uses: re-actors/alls-green@release/v1 + with: + jobs: ${{ toJSON(needs) }} diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 15a57d33..c563d563 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -15,7 +15,6 @@ concurrency: env: SETUPTOOLS_SCM_PRETEND_VERSION: ${{ github.event.inputs.overrideVersion }} - CIBW_ENVIRONMENT: "PIP_PREFER_BINARY=1" jobs: build_sdist: @@ -76,15 +75,23 @@ jobs: strategy: fail-fast: false matrix: - os: [windows-2019, macos-latest] - arch: [auto64] - build: ["*"] - include: - - os: macos-latest - arch: universal2 + - os: macos-13 + arch: auto64 + build: "*" + + - os: macos-14 + arch: auto64 build: "*" + - os: windows-2019 + arch: auto64 + build: "cp*" + + - os: windows-2019 + arch: auto64 + build: "pp*" + - os: windows-2019 arch: auto32 build: "*" diff --git a/CMakeLists.txt b/CMakeLists.txt index 7391d15b..cc27945e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,8 +1,10 @@ -cmake_minimum_required(VERSION 3.10...3.26) +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 @@ -35,14 +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 -add_subdirectory(extern/pybind11) +set(PYBIND11_FINDPYTHON TRUE) +set(Python_ARTIFACTS_INTERACTIVE TRUE) -message(STATUS "Python ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}") +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") @@ -53,7 +65,7 @@ file(GLOB_RECURSE BOOST_HIST_PY_HEADERS "include/bh_python/*.hpp") file(GLOB BOOST_HIST_PY_SRC CONFIGURE_DEPENDS src/*.cpp) # This is the Python module -pybind11_add_module(_core SHARED ${BOOST_HIST_PY_HEADERS} ${BOOST_HIST_PY_SRC} ${BOOST_HIST_FILES}) +pybind11_add_module(_core MODULE ${BOOST_HIST_PY_HEADERS} ${BOOST_HIST_PY_SRC} ${BOOST_HIST_FILES}) # Add the include directory for boost/histogram/python target_include_directories(_core PRIVATE include) @@ -69,9 +81,16 @@ target_include_directories( extern/throw_exception/include extern/variant2/include) -# Useful flags -target_compile_options(_core - PRIVATE $,/fp:fast,-funsafe-math-optimizations>) +# Support older Windows from newer MSVC +target_compile_options(_core PRIVATE $<$:/d2FH4->) + +# Better error messages +target_compile_definitions(_core PRIVATE PYBIND11_DETAILED_ERROR_MESSAGES) + +# Atomic is required for armv7l +if(CMAKE_SYSTEM_PROCESSOR MATCHES "armv7l") + target_link_libraries(_core PRIVATE atomic) +endif() # This makes IDE's like XCode mimic the Boost Histogram structure source_group( @@ -126,38 +145,37 @@ endif() # which confuses Python. set_property(TARGET _core PROPERTY LIBRARY_OUTPUT_DIRECTORY "$<1:boost_histogram>") -# Collect all the python files and symlink them (3.14+) or copy them (3.12-3.13) -# into the build directory +# Collect all the python files and symlink them into the build directory # Protects from in-source builds (don't do this, please) -if(NOT "${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}") +if(NOT "${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}" AND NOT DEFINED + SKBUILD) file( GLOB_RECURSE BOOST_HIST_PY_FILES LIST_DIRECTORIES false RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/src" CONFIGURE_DEPENDS "src/boost_histogram/*.py") foreach(F IN LISTS BOOST_HIST_PY_FILES) - if(CMAKE_VERSION VERSION_LESS 3.14) - get_filename_component(FDIR "${F}" DIRECTORY) - file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/src/${F}" - DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/${FDIR}") - else() - file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/${F}") - file(CREATE_LINK "${CMAKE_CURRENT_SOURCE_DIR}/src/${F}" "${CMAKE_CURRENT_BINARY_DIR}/${F}" - COPY_ON_ERROR SYMBOLIC) - endif() + file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/${F}") + file(CREATE_LINK "${CMAKE_CURRENT_SOURCE_DIR}/src/${F}" "${CMAKE_CURRENT_BINARY_DIR}/${F}" + COPY_ON_ERROR SYMBOLIC) endforeach() endif() # Support installing -install(DIRECTORY "src/boost_histogram" DESTINATION ".") -install(FILES "${CMAKE_CURRENT_BINARY_DIR}/boost_histogram/version.py" - DESTINATION "boost_histogram") install(TARGETS _core DESTINATION "boost_histogram") -# Tests (Requires pytest to be available to run) -include(CTest) +if(NOT DEFINED SKBUILD) + install(DIRECTORY "src/boost_histogram" DESTINATION ".") + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/boost_histogram/version.py" + DESTINATION "boost_histogram") -if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/src/boost_histogram/version.py") + # Tests (Requires pytest to be available to run) + include(CTest) +endif() + +if(DEFINED SKBUILD) + # Don't worry about the version +elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/src/boost_histogram/version.py") set(VERSION_REGEX [=[version[ \t]*=[ \t]*["']([0-9]+\.[0-9]+\.[0-9]+)]=]) # Read in the line containing the version @@ -170,24 +188,11 @@ else() pybind11_find_import(setuptools_scm REQUIRED) execute_process( - COMMAND - ${PYTHON_EXECUTABLE} -c - "from setuptools_scm import get_version; print(get_version(root='${CMAKE_CURRENT_SOURCE_DIR}'))" - RESULT_VARIABLE VERSION_PRESENT + COMMAND ${Python_EXECUTABLE} -c "from setuptools_scm import get_version; print(get_version())" + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" OUTPUT_VARIABLE VERSION_FULL_STRING - ERROR_VARIABLE VERSION_ERROR) + OUTPUT_STRIP_TRAILING_WHITESPACE COMMAND_ERROR_IS_FATAL ANY) - if(ERROR_VARIABLE) - message(STATUS "Warning from setuptools_scm:\n${ERROR_VARIABLE}") - endif() - - if(NOT VERSION_PRESENT EQUAL 0) - message( - FATAL_ERROR - "Cannot detect ${VERSION_PRESENT} the version from setuptools_scm\n${VERSION_STRING}") - endif() - - string(STRIP "${VERSION_FULL_STRING}" VERSION_FULL_STRING) string(REGEX MATCH [=[^[0-9]+\.[0-9]+\.[0-9]+]=] VERSION_STRING "${VERSION_FULL_STRING}") string(REPLACE "-" "." VERSION_STRING "${VERSION_STRING}") file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/boost_histogram/version.py" @@ -195,12 +200,14 @@ else() message(STATUS "Full version output: ${VERSION_FULL_STRING}") endif() -project( - BOOST_HISTOGRAM - LANGUAGES CXX - VERSION ${VERSION_STRING}) -message(STATUS "boost-histogram ${BOOST_HISTOGRAM_VERSION}") +if(NOT DEFINED SKBUILD) + project( + BOOST_HISTOGRAM + LANGUAGES CXX + VERSION ${VERSION_STRING}) + message(STATUS "boost-histogram ${BOOST_HISTOGRAM_VERSION}") -if(BUILD_TESTING) - add_subdirectory(tests) + if(BUILD_TESTING) + add_subdirectory(tests) + endif() endif() diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index bcb6d75a..00000000 --- a/MANIFEST.in +++ /dev/null @@ -1,26 +0,0 @@ -graft include -graft src -graft tests - -graft extern/assert/include -graft extern/config/include -graft extern/core/include -graft extern/histogram/include -graft extern/mp11/include -graft extern/throw_exception/include -graft extern/variant2/include - -graft extern/pybind11/include -graft extern/pybind11/tools -graft extern/pybind11/pybind11 -include extern/pybind11/CMakeLists.txt - -global-exclude .git* -global-exclude .pytest_cache -global-exclude .DS_Store -global-exclude .ipynb_checkpoints -global-exclude *.py[co] -global-exclude __pycache__ - -include CMakeLists.txt LICENSE README.md setup.py setup.cfg pyproject.toml -recursive-include extern *LICENSE* diff --git a/README.md b/README.md index e0502dd3..ac6b046a 100644 --- a/README.md +++ b/README.md @@ -195,7 +195,7 @@ platforms have wheels provided in boost-histogram: | ManyLinux2014 | 64-bit | 3.7, 3.8, 3.9, 3.10, 3.11, 3.12 | 3.7, 3.8, 3.9, 3.10 | | ManyLinux2014 | ARM64 | 3.7, 3.8, 3.9, 3.10, 3.11, 3.12 | 3.7, 3.8, 3.9, 3.10 | | MuslLinux_1_1 | 64-bit | 3.7, 3.8, 3.9, 3.10, 3.11, 3.12 | | -| macOS 10.9+ | 64-bit | 3.7, 3.8, 3.9, 3.10, 3.11, 3.12 | 3.7, 3.8, 3.9, 3.10 | +| macOS 10.9+ | 64-bit | 3.7 | 3.7, 3.8, 3.9, 3.10 | | macOS Universal2 | Arm64 | 3.8, 3.9, 3.10, 3.11, 3.12 | | | Windows | 32 & 64-bit | 3.7, 3.8, 3.9, 3.10, 3.11, 3.12 | | | Windows | 64-bit | | 3.7, 3.8, 3.9, 3.10 | diff --git a/dev-requirements.txt b/dev-requirements.txt index f3d21337..19cefd0e 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,10 +1,8 @@ cloudpickle -dataclasses; python_version<'3.7' hypothesis >=6.0 numpy pytest >=6,!=6.1.0,!=7.1.0 pytest-benchmark -setuptools >=42 setuptools_scm[toml] >=3.4,!=4.0.0 typing_extensions; python_version<'3.8' uproot diff --git a/extern/pybind11 b/extern/pybind11 deleted file mode 160000 index 3e9dfa28..00000000 --- a/extern/pybind11 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 3e9dfa2866941655c56877882565e7577de6fc7b diff --git a/noxfile.py b/noxfile.py index 981c3cec..7d3d1ab4 100644 --- a/noxfile.py +++ b/noxfile.py @@ -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"] @@ -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) @@ -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) @@ -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) diff --git a/pyproject.toml b/pyproject.toml index f08e270f..d6bebd7e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,13 +1,107 @@ [build-system] -requires = [ - "setuptools>=45", - "setuptools_scm[toml]>=4.1.2", +requires = ["scikit-build-core[pyproject]", "pybind11"] +build-backend = "scikit_build_core.build" + +[project] +name = "boost-histogram" +dynamic = ["version"] +description = "The Boost::Histogram Python wrapper." +readme = "README.md" +requires-python = ">=3.7" +authors = [ + { name = "Hans Dembinski and Henry Schreiner", email = "hschrein@cern.ch" }, +] +keywords = [ + "boost-histogram", + "histogram", +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "Intended Audience :: Information Technology", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: BSD License", + "Operating System :: MacOS", + "Operating System :: Microsoft :: Windows", + "Operating System :: POSIX", + "Operating System :: Unix", + "Programming Language :: C++", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: PyPy", + "Programming Language :: Python", + "Topic :: Scientific/Engineering :: Information Analysis", + "Topic :: Scientific/Engineering :: Mathematics", + "Topic :: Scientific/Engineering :: Physics", + "Topic :: Scientific/Engineering", + "Topic :: Software Development", + "Topic :: Utilities", + "Typing :: Typed", +] +dependencies = [ + "numpy", + "typing-extensions;python_version<'3.8'", +] + +[project.optional-dependencies] +dev = [ + "cloudpickle", + "hypothesis>=6.0", + "ipykernel", + "pytest-benchmark", + "pytest>=6.0", + "typer", +] +docs = [ + "myst_parser>=0.13", + "nbsphinx", + "sphinx-book-theme>=0.0.33", + "Sphinx>=4.0", + "sphinx_copybutton", ] -build-backend = "setuptools.build_meta" +examples = [ + "matplotlib", + "netCDF4", + "numba", + "uproot3", + "xarray", + "xhistogram", +] +test = [ + "cloudpickle", + "hypothesis>=6.0", + "pytest-benchmark", + "pytest>=6.0", +] + +[project.urls] +"Bug Tracker" = "https://github.com/scikit-hep/boost-histogram/issues" +Changelog = "https://boost-histogram.readthedocs.io/en/latest/CHANGELOG.html" +Chat = " https://gitter.im/HSF/PyHEP-histogramming" +Discussions = "https://github.com/scikit-hep/boost-histogram/discussions" +Documentation = "https://boost-histogram.readthedocs.io/" +Homepage = "https://github.com/scikit-hep/boost-histogram" + + +[tool.scikit-build] +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] write_to = "src/boost_histogram/version.py" + [tool.pytest.ini_options] minversion = "6.0" junit_family = "xunit2" @@ -90,10 +184,12 @@ test-skip = [ "pp38-*", "pp310-*", "*universal2:arm64", + "cp38-macosx_*:arm64", "cp*-*musllinux*", # segfault ] environment-pass = ["SETUPTOOLS_SCM_PRETEND_VERSION"] environment.PIP_ONLY_BINARY = "numpy" +environment.PIP_PREFER_BINARY = "1" [tool.pylint] diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 1acbeea8..00000000 --- a/setup.cfg +++ /dev/null @@ -1,66 +0,0 @@ -[metadata] -name = boost_histogram -description = The Boost::Histogram Python wrapper. -long_description = file: README.md -long_description_content_type = text/markdown -url = https://github.com/scikit-hep/boost-histogram -author = Hans Dembinski and Henry Schreiner -author_email = hschrein@cern.ch -maintainer = Hans Dembinski and Henry Schreiner -maintainer_email = hschrein@cern.ch -license = BSD-3-Clause -license_files = LICENSE -classifiers = - Development Status :: 5 - Production/Stable - Intended Audience :: Developers - Intended Audience :: Information Technology - Intended Audience :: Science/Research - License :: OSI Approved :: BSD License - Operating System :: MacOS - Operating System :: Microsoft :: Windows - Operating System :: POSIX - Operating System :: Unix - Programming Language :: C++ - Programming Language :: Python - Programming Language :: Python :: 3 - Programming Language :: Python :: 3 :: Only - Programming Language :: Python :: 3.7 - Programming Language :: Python :: 3.8 - Programming Language :: Python :: 3.9 - Programming Language :: Python :: 3.10 - Programming Language :: Python :: 3.11 - Programming Language :: Python :: 3.12 - Programming Language :: Python :: Implementation :: CPython - Programming Language :: Python :: Implementation :: PyPy - Topic :: Scientific/Engineering - Topic :: Scientific/Engineering :: Information Analysis - Topic :: Scientific/Engineering :: Mathematics - Topic :: Scientific/Engineering :: Physics - Topic :: Software Development - Topic :: Utilities - Typing :: Typed -keywords = - histogram - boost-histogram -project_urls = - Documentation = https://boost-histogram.readthedocs.io/ - Bug Tracker = https://github.com/scikit-hep/boost-histogram/issues - Discussions = https://github.com/scikit-hep/boost-histogram/discussions - Changelog = https://boost-histogram.readthedocs.io/en/latest/CHANGELOG.html - Chat = https://gitter.im/HSF/PyHEP-histogramming - -[options] -packages = - boost_histogram - boost_histogram._core - boost_histogram._core.axis - boost_histogram._internal - boost_histogram.axis -install_requires = - numpy - typing-extensions;python_version<'3.8' -python_requires = >=3.7 -include_package_data = True -package_dir = - =src -zip_safe = False diff --git a/setup.py b/setup.py deleted file mode 100644 index 43de64b0..00000000 --- a/setup.py +++ /dev/null @@ -1,76 +0,0 @@ -from __future__ import annotations - -import functools -import operator -import os -import platform -import sys -from pathlib import Path - -from setuptools import setup - -DIR = Path(__file__).parent.resolve() - -sys.path.append(str(DIR / "extern" / "pybind11")) - -from pybind11.setup_helpers import ParallelCompile, Pybind11Extension # noqa: E402 - -del sys.path[-1] - -# Use the environment variable CMAKE_BUILD_PARALLEL_LEVEL to control parallel builds -ParallelCompile("CMAKE_BUILD_PARALLEL_LEVEL").install() - -cxx_std = int(os.environ.get("CMAKE_CXX_STANDARD", "14")) - -SRC_FILES = [ - "src/module.cpp", - "src/register_accumulators.cpp", - "src/register_algorithm.cpp", - "src/register_axis.cpp", - "src/register_histograms.cpp", - "src/register_storage.cpp", - "src/register_transforms.cpp", -] - -INCLUDE_DIRS = [ - "include", - "extern/pybind11/include", - "extern/assert/include", - "extern/config/include", - "extern/core/include", - "extern/histogram/include", - "extern/mp11/include", - "extern/throw_exception/include", - "extern/variant2/include", -] - -ext_modules = [ - Pybind11Extension( - "boost_histogram._core", - SRC_FILES, - include_dirs=INCLUDE_DIRS, - cxx_std=cxx_std, - include_pybind11=False, - extra_compile_args=["/d2FH4-"] if sys.platform.startswith("win32") else [], - extra_link_args=["-latomic"] if platform.machine() == "armv7l" else [], - define_macros=[("PYBIND11_DETAILED_ERROR_MESSAGES", "1")], - ) -] - - -extras = { - "test": ["pytest>=6.0", "pytest-benchmark", "cloudpickle", "hypothesis>=6.0"], - "docs": [ - "Sphinx>=4.0", - "myst_parser>=0.13", - "sphinx-book-theme>=0.0.33", - "nbsphinx", - "sphinx_copybutton", - ], - "examples": ["matplotlib", "xarray", "xhistogram", "netCDF4", "numba", "uproot3"], - "dev": ["ipykernel", "typer"], -} -extras["all"] = functools.reduce(operator.iadd, extras.values(), []) -extras["dev"] += extras["test"] - -setup(ext_modules=ext_modules, extras_require=extras) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 9ad27a86..d84700d2 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -2,6 +2,9 @@ pybind11_find_import(numpy) pybind11_find_import(pytest) pybind11_find_import(pytest-benchmark) +# Much better test target on CMake 3.29+ +set(CMAKE_SKIP_TEST_ALL_DEPENDENCY FALSE) + # Support for running from build directory file(WRITE "${PROJECT_BINARY_DIR}/pytest.ini" "[pytest]\n" "addopts = --benchmark-disable\n" "testpaths = ${CMAKE_CURRENT_SOURCE_DIR}\n") @@ -18,8 +21,6 @@ foreach(TEST_FILE IN LISTS BOOST_HIST_PY_TESTS) get_filename_component(TEST_NAME "${TEST_FILE}" NAME_WE) add_test( NAME ${TEST_NAME} - COMMAND ${PYTHON_EXECUTABLE} -m pytest "${TEST_FILE}" --rootdir=. + COMMAND ${Python_EXECUTABLE} -m pytest "${TEST_FILE}" --rootdir=. WORKING_DIRECTORY "${PROJECT_BINARY_DIR}") endforeach() - -add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --verbose)