diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 274994fd..ff4fef8a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -108,7 +108,7 @@ jobs: - uses: pypa/cibuildwheel@v2.15 env: - CIBW_BUILD: cp38-win32 cp312-manylinux_x86_64 cp37-macosx_x86_64 + CIBW_BUILD: cp38-win32 cp312-manylinux_x86_64 cp38-macosx_universal2 CIBW_BUILD_VERBOSITY: 1 CIBW_ENVIRONMENT: "PIP_ONLY_BINARY=:all:" diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index e030b511..66f3674a 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -91,7 +91,7 @@ jobs: strategy: fail-fast: false matrix: - os: [windows-2019, macos-latest, ubuntu-latest] + os: [windows-2019, ubuntu-latest] arch: [auto64] include: @@ -101,6 +101,10 @@ jobs: - os: windows-2019 arch: auto32 + - os: macos-latest + arch: auto64 + build: cp37* + steps: - uses: actions/checkout@v4 with: diff --git a/CMakeLists.txt b/CMakeLists.txt index 3478fc29..6e668278 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.10...3.26) +cmake_minimum_required(VERSION 3.15...3.26) project(BOOST_HISTOGRAM LANGUAGES CXX) # Version is added later @@ -154,7 +154,8 @@ 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 # 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 @@ -174,15 +175,20 @@ if(NOT "${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}") 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 @@ -220,12 +226,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 32097096..f27dcb64 100644 --- a/README.md +++ b/README.md @@ -196,7 +196,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/pyproject.toml b/pyproject.toml index 3d489f48..8b90dd89 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,13 +1,106 @@ [build-system] -requires = [ - "setuptools>=45", - "setuptools_scm[toml]>=4.1.2", +requires = ["scikit-build-core[pyproject]"] +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;python_version<'3.12'", + "numpy>=1.26.0b1;python_version>='3.12'", + "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 + [tool.setuptools_scm] write_to = "src/boost_histogram/version.py" + [tool.pytest.ini_options] minversion = "6.0" junit_family = "xunit2" @@ -94,6 +187,7 @@ test-skip = [ skip = ["pp*-manylinux_i686", "cp312-win32"] # not supported by NumPy environment-pass = ["SETUPTOOLS_SCM_PRETEND_VERSION"] environment = { PIP_ONLY_BINARY = "numpy" } +macos.archs = ["universal2"] [tool.pylint] main.py-version = "3.7" diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 266c9b85..00000000 --- a/setup.cfg +++ /dev/null @@ -1,67 +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>=1.26.0b1;python_version>='3.12' - numpy;python_version<'3.12' - 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 9e9e49c4..00000000 --- a/setup.py +++ /dev/null @@ -1,73 +0,0 @@ -from __future__ import annotations - -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"] = sum(extras.values(), []) -extras["dev"] += extras["test"] - -setup(ext_modules=ext_modules, extras_require=extras)