diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 810cc1a9..0cd81411 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,6 +40,7 @@ jobs: - uses: actions/checkout@v4 with: submodules: recursive + fetch-depth: 0 - uses: actions/setup-python@v5 with: @@ -48,21 +49,18 @@ jobs: - name: Install compiler tools on macOS if: runner.os == 'macOS' run: | - brew install make automake swig gmp mpfr boost libtool + brew reinstall gfortran + brew install swig boost cgal gmp mpfr - name: Install extra deps on Linux if: runner.os == 'Linux' - run: sudo apt-get update && sudo apt-get install -y libboost-dev libmpfr-dev swig autoconf libtool + run: sudo apt-get update && sudo apt-get install -y libboost-dev libmpfr-dev swig libcgal-dev - name: Install package (MacOS) if: runner.os == 'macOS' run: | eval "$(/opt/homebrew/bin/brew shellenv)" export PATH="/opt/homebrew/opt/make/libexec/gnubin:/opt/homebrew/opt/libtool/libexec/gnubin:$PATH" - export CPPFLAGS+="-I/opt/homebrew/include -L/opt/homebrew/lib" - export CXXFLAGS+="-I/opt/homebrew/include -L/opt/homebrew/lib" - export CFLAGS+="-I/opt/homebrew/include -L/opt/homebrew/lib" - export LDFLAGS+="-L/opt/homebrew/lib" python -m pip install '.[test]' -v - name: Install package (Linux) @@ -91,17 +89,19 @@ jobs: - uses: actions/checkout@v4 with: submodules: recursive + fetch-depth: 0 - name: Install compiler tools on macOS if: runner.os == 'macOS' run: | - brew install make automake swig mpfr boost libtool - echo "PATH=/opt/homebrew/opt/make/libexec/gnubin:/opt/homebrew/opt/libtool/libexec/gnubin:$PATH" >> "$GITHUB_ENV" - echo "CPPFLAGS=-I/opt/homebrew/include -L/opt/homebrew/lib $CPPFLAGS" >> "$GITHUB_ENV" - echo "CXXFLAGS=-I/opt/homebrew/include -L/opt/homebrew/lib $CXXFLAGS" >> "$GITHUB_ENV" - echo "CFLAGS=-I/opt/homebrew/include -L/opt/homebrew/lib $CFLAGS" >> "$GITHUB_ENV" - echo "LDFLAGS=-L/opt/homebrew/lib $LDFLAGS" >> "$GITHUB_ENV" echo "MACOSX_DEPLOYMENT_TARGET=11.0" >> "$GITHUB_ENV" + brew uninstall gcc@12 gcc@13 gnupg gnutls isl libmpc nettle gcc mpfr gmp --ignore-dependencies + brew install m4 make automake autoconf libtool swig boost cgal --ignore-dependencies + echo "PATH=/opt/homebrew/opt/make/libexec/gnubin:/opt/homebrew/opt/libtool/libexec/gnubin:$PATH" >> "$GITHUB_ENV" + + - name: Install extra deps on Linux + if: runner.os == 'Linux' + run: sudo apt-get update && sudo apt-get install -y libboost-dev libmpfr-dev swig libcgal-dev - name: Clone gmp if: runner.os == 'macOS' @@ -110,7 +110,7 @@ jobs: repository: gmp-mirror/gmp-6.3 path: gmp-6.3 - - name: Build gmp from source for MACOSX_DEPLOYMENT_TARGET + - name: Build gmp from source for MACOSX_DEPLOYMENT_TARGET=11.0 if: runner.os == 'macOS' working-directory: gmp-6.3 run: | @@ -124,6 +124,24 @@ jobs: make --jobs make install + - name: Get mpfr release + if: runner.os == 'macOS' + run: | + curl -Lk https://www.mpfr.org/mpfr-current/mpfr-4.2.2.tar.gz -o mpfr-4.2.2.tar.gz + tar -xzf mpfr-4.2.2.tar.gz + + - name: Build mpfr from source for MACOSX_DEPLOYMENT_TARGET=11.0 + if: runner.os == 'macOS' + working-directory: mpfr-4.2.2 + run: | + autoreconf -i -f + ./configure --help + ./configure \ + --prefix=$(brew --prefix) \ + --with-gmp=$(brew --prefix) + make --jobs + make install + - uses: pypa/cibuildwheel@v2.23 env: CIBW_ARCHS: ${{ matrix.arch }} diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 21f97a5a..0e154fc7 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -17,6 +17,7 @@ jobs: - uses: actions/checkout@v4 with: submodules: recursive + fetch-depth: 0 - name: Build SDist run: pipx run build --sdist @@ -40,17 +41,15 @@ jobs: - uses: actions/checkout@v4 with: submodules: recursive + fetch-depth: 0 - name: Install compiler tools on macOS if: runner.os == 'macOS' run: | - brew install make automake swig mpfr boost libtool - echo "PATH=/opt/homebrew/opt/make/libexec/gnubin:/opt/homebrew/opt/libtool/libexec/gnubin:$PATH" >> "$GITHUB_ENV" - echo "CPPFLAGS=-I/opt/homebrew/include -L/opt/homebrew/lib $CPPFLAGS" >> "$GITHUB_ENV" - echo "CXXFLAGS=-I/opt/homebrew/include -L/opt/homebrew/lib $CXXFLAGS" >> "$GITHUB_ENV" - echo "CFLAGS=-I/opt/homebrew/include -L/opt/homebrew/lib $CFLAGS" >> "$GITHUB_ENV" - echo "LDFLAGS=-L/opt/homebrew/lib $LDFLAGS" >> "$GITHUB_ENV" echo "MACOSX_DEPLOYMENT_TARGET=11.0" >> "$GITHUB_ENV" + brew uninstall gcc@12 gcc@13 gnupg gnutls isl libmpc nettle gcc mpfr gmp --ignore-dependencies + brew install m4 make automake autoconf libtool swig boost cgal --ignore-dependencies + echo "PATH=/opt/homebrew/opt/make/libexec/gnubin:/opt/homebrew/opt/libtool/libexec/gnubin:$PATH" >> "$GITHUB_ENV" - name: Clone gmp if: runner.os == 'macOS' @@ -74,6 +73,24 @@ jobs: make --jobs make install + - name: Get mpfr release + if: runner.os == 'macOS' + run: | + curl -Lk https://www.mpfr.org/mpfr-current/mpfr-4.2.2.tar.gz -o mpfr-4.2.2.tar.gz + tar -xzf mpfr-4.2.2.tar.gz + + - name: Build mpfr from source for MACOSX_DEPLOYMENT_TARGET=11.0 + if: runner.os == 'macOS' + working-directory: mpfr-4.2.2 + run: | + autoreconf -i -f + ./configure --help + ./configure \ + --prefix=$(brew --prefix) \ + --with-gmp=$(brew --prefix) + make --jobs + make install + - uses: pypa/cibuildwheel@v2.23 env: CIBW_ARCHS: ${{ matrix.arch }} @@ -98,7 +115,7 @@ jobs: - name: Install extra deps on Linux if: runner.os == 'Linux' - run: sudo apt-get update && sudo apt-get install -y libboost-dev swig autoconf libtool + run: sudo apt-get update && sudo apt-get install -y libboost-dev swig autoconf libtool libcgal-dev - name: test sdist run: python -m pip install dist/*.tar.gz diff --git a/.gitignore b/.gitignore index fa91a4c6..e5de6014 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +src/fastjet/version.py _swig.py _fastjet_core *.so.[0-9] diff --git a/.gitmodules b/.gitmodules index c3d1c0d1..a10c9a12 100644 --- a/.gitmodules +++ b/.gitmodules @@ -3,4 +3,4 @@ url = https://gitlab.com/fastjet/fastjet.git [submodule "fastjet-contrib"] path = extern/fastjet-contrib - url = https://github.com/cms-externals/fastjet-contrib.git + url = https://github.com/lgray/fastjet-contrib.git diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7af12b6b..751982e3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -41,18 +41,11 @@ repos: hooks: - id: setup-cfg-fmt -- repo: https://github.com/pycqa/flake8 - rev: 7.2.0 +- repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.11.4 hooks: - - id: flake8 - exclude: docs/conf.py - additional_dependencies: [flake8-bugbear, flake8-print] - -- repo: https://github.com/mgedmin/check-manifest - rev: "0.50" - hooks: - - id: check-manifest - stages: [manual] + - id: ruff + args: [--fix, --show-fixes] - repo: https://github.com/pre-commit/mirrors-clang-format rev: "v20.1.0" diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..28be2f1c --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,48 @@ +cmake_minimum_required(VERSION 3.15...4.0) + +if(NOT SKBUILD_PROJECT_VERSION) + set(SKBUILD_PROJECT_VERSION "0.0.0") # provided by scikit-build-core +endif() +string(REPLACE "." ";" VERSION_SPLIT ${SKBUILD_PROJECT_VERSION}) +list(GET VERSION_SPLIT 0 SPLIT_VERSION_MAJOR) +list(GET VERSION_SPLIT 1 SPLIT_VERSION_MINOR) + +project(fastjet VERSION ${SPLIT_VERSION_MAJOR}.${SPLIT_VERSION_MINOR} LANGUAGES CXX) + +set(PKG_INSTALL "fastjet") ## python package name + +include(FetchContent) + +find_package(pybind11 REQUIRED) + +find_package(CGAL) +if (NOT CGAL_FOUND) + FetchContent_Declare(CGAL + GIT_REPOSITORY https://github.com/CGAL/cgal.git + GIT_TAG v6.0.1 + ) + FetchContent_MakeAvailable(CGAL) +endif() + +#FetchContent_Declare(fastjet +# SOURCE_DIR ${CMAKE_SOURCE_DIR}/extern/fastjet-core +# CMAKE_ARGS "-DCMAKE_BUILD_TYPE=\"Release\" -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}/${PKG_INSTALL} -DFASTJET_CUSTOM_PYTHON_INSTALL=lib/${PKG_INSTALL} -DFASTJET_PYTHON_PACKAGE_NAME=_swig -DFASTJET_ENABLE_CGAL=ON" +# ) +#FetchContent_MakeAvailable(fastjet) + +add_subdirectory(${CMAKE_SOURCE_DIR}/extern/fastjet-core) +add_subdirectory(${CMAKE_SOURCE_DIR}/extern/fastjet-contrib) + +pybind11_add_module(_ext MODULE src/_ext.cpp) +target_link_libraries(_ext PRIVATE fastjet::fastjet) +target_link_libraries(_ext PRIVATE EnergyCorrelator LundPlane Nsubjettiness RecursiveTools) +target_include_directories(_ext PRIVATE ${CMAKE_BINARY_DIR}/include) +#set_target_properties(_ext PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE) +#set_target_properties(_ext PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE) +if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + set_target_properties(_ext PROPERTIES INSTALL_RPATH "@loader_path/lib") +else() + set_target_properties(_ext PROPERTIES INSTALL_RPATH "$ORIGIN/lib") +endif() + +install(TARGETS _ext LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}) diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 7d1a5828..00000000 --- a/MANIFEST.in +++ /dev/null @@ -1,6 +0,0 @@ -graft src -graft tests -graft extern -global-exclude .git .gitmodules -include LICENSE README.md pyproject.toml setup.py setup.cfg patch_clustersequence.txt -exclude .cirrus.yml diff --git a/extern/fastjet-contrib b/extern/fastjet-contrib index aa1972cd..539cc735 160000 --- a/extern/fastjet-contrib +++ b/extern/fastjet-contrib @@ -1 +1 @@ -Subproject commit aa1972cd2b3e8aa2c76764f14122e8f728c23712 +Subproject commit 539cc7350fd251e53589479205a0faead80a3efb diff --git a/extern/fastjet-core b/extern/fastjet-core index 0648cfc3..8fc02d2a 160000 --- a/extern/fastjet-core +++ b/extern/fastjet-core @@ -1 +1 @@ -Subproject commit 0648cfc312bbfefbaa28ffa2cb29b010f88e163c +Subproject commit 8fc02d2a1b6058f295cb7ce89a60d996c8cd6e53 diff --git a/pyproject.toml b/pyproject.toml index be3ca686..c535d6e7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,10 +1,93 @@ [build-system] requires = [ - "setuptools>=42", - "setuptools_scm[toml]>=3.4", - "pybind11>=2.12.0", + "pybind11>=2.6.1", + "scikit-build-core>=0.11", ] -build-backend = "setuptools.build_meta" +build-backend = "scikit_build_core.build" + +[project] +name = "fastjet" +dynamic = ["version"] +requires-python = ">=3.9" +classifiers = [ + "Development Status :: 1 - Planning", + "Intended Audience :: Developers", + "Intended Audience :: Science/Research", + "Operating System :: MacOS :: MacOS X", + "Operating System :: POSIX :: Linux", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3 :: Only", + "Topic :: Scientific/Engineering", +] +dependencies = [ + "awkward>=2", + "numpy>=1.13.3", + "vector" +] + +[project.optional-dependencies] +local_build = [ + "scikit-build-core>=0.11", + "setuptools-scm", +] +dask = [ + "dask>=2023.4.0", + "dask-awkward>=2023.4.2", +] +dev = [ + "pytest>=4.6", +] +docs = [ + "Sphinx>=3.0.0", + "recommonmark>=0.5.0", + "sphinx-copybutton", + "sphinx-rtd-theme>=0.5.0", +] +test = [ + "pytest>=4.6", + "uproot>=5", + "dask>=2023.4.0;python_version>'3.7'", + "dask-awkward[test]>=2023.4.2;python_version>'3.7'", + "distributed>=2023.4.0;python_version>'3.7'", +] + +[tool.pytest.ini_options] +minversion = "6.0" +testpaths = ["tests"] +addopts = [ + "-vv", + "-rs", + "-Wd", +] + +[tool.isort] +profile = "black" +multi_line_output = 3 + +[tool.ruff] +extend-exclude = ["docs/conf.py"] + +[tools.mypy] +files = "src" +python_version = 3.9 +warn_unused_configs = true +disallow_any_generics = true +disallow_subclassing_any = true +disallow_untyped_calls = true +disallow_untyped_defs = true +disallow_incomplete_defs = true +check_untyped_defs = true +disallow_untyped_decorators = true +no_implicit_optional = true +warn_redundant_casts = true +warn_unused_ignores = true +warn_return_any = true +no_implicit_reexport = true +strict_equality = true + +[tools.mypy.numpy] +ignore_missing_imports = true [tool.cibuildwheel] skip = "pp*" @@ -20,6 +103,50 @@ before-all = [ "curl -L https://archives.boost.io/release/1.87.0/source/boost_1_87_0.tar.bz2 -o boost_1_87_0.tar.bz2", "tar --bzip2 -xf boost_1_87_0.tar.bz2", "mv boost_1_87_0/boost /usr/include/boost", + "curl -L https://github.com/CGAL/cgal/releases/download/v5.6/CGAL-5.6-library.zip -o CGAL-5.6-library.zip", + "unzip -q CGAL-5.6-library.zip", + "mkdir CGAL-5.6/build", + "cmake -S CGAL-5.6 -B CGAL-5.6/build -DCMAKE_BUILD_TYPE=\"Release\"", + "cmake --build CGAL-5.6/build --clean-first", + "cmake --install CGAL-5.6/build", + "rm -r CGAL-5.6 CGAL-5.6-library.zip", ] # Skip musllinux builds for the moment skip = "*-musllinux_*" + +[tool.scikit-build] +minimum-version = "build-system.requires" +metadata.version.provider = "scikit_build_core.metadata.setuptools_scm" +cmake.version = "CMakeLists.txt" +sdist.include = ["src/fastjet/version.py"] +wheel.install-dir = "fastjet" + +[tool.scikit-build.cmake.define] +FASTJET_ENABLE_PYTHON = "ON" +FASTJET_ENABLE_CGAL = "ON" +FASTJET_PYTHON_PACKAGE_NAME = "_swig" +FASTJET_CUSTOM_PYTHON_INSTALL = "./" +FASTJET_ENABLE_PLUGIN_PXCONE = "OFF" +FASTJETCONTRIB_ENABLE_GENERICSUBTRACTOR = "OFF" +FASTJETCONTRIB_ENABLE_JETFFMOMENTS = "OFF" +FASTJETCONTRIB_ENABLE_VARIABLER = "OFF" +FASTJETCONTRIB_ENABLE_SCJET = "OFF" +FASTJETCONTRIB_ENABLE_SUBJETCOUNTING = "OFF" +FASTJETCONTRIB_ENABLE_JETCLEANSER = "OFF" +FASTJETCONTRIB_ENABLE_JETSWITHOUTJETS = "OFF" +FASTJETCONTRIB_ENABLE_CONSTITUENTSUBTRACTOR = "OFF" +FASTJETCONTRIB_ENABLE_SOFTKILLER = "OFF" +FASTJETCONTRIB_ENABLE_VALENCIAPLUGIN = "OFF" +FASTJETCONTRIB_ENABLE_CLUSTERINGVETOPLUGIN = "OFF" +FASTJETCONTRIB_ENABLE_QCDAWAREPLUGIN = "OFF" +FASTJETCONTRIB_ENABLE_FLAVORCONE = "OFF" +FASTJETCONTRIB_ENABLE_CENTAURO = "OFF" +FASTJETCONTRIB_ENABLE_KTCLUSCXX = "OFF" +FASTJETCONTRIB_ENABLE_SIGNALFREEBACKGROUNDESTIMATOR = "OFF" +FASTJETCONTRIB_ENABLE_IFNPLUGIN = "OFF" +FASTJETCONTRIB_ENABLE_CMPPLUGIN = "OFF" +FASTJETCONTRIB_ENABLE_SDFPLUGIN = "OFF" +FASTJETCONTRIB_ENABLE_GHSALGO = "OFF" + +[tool.setuptools_scm] +write_to = "src/fastjet/version.py" diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index da2cbc54..00000000 --- a/setup.cfg +++ /dev/null @@ -1,106 +0,0 @@ -[metadata] -name = fastjet -description = Official FastJet bindings to Python and Awkward Array. -long_description = file: README.md -long_description_content_type = text/markdown -url = https://github.com/scikit-hep/fastjet -author = Aryan Roy -author_email = aryanroy5678@gmail.com -maintainer = The Scikit-HEP admins -maintainer_email = scikit-hep-admins@googlegroups.com -license = BSD-3-Clause -license_files = LICENSE -platforms = - Any -classifiers = - Development Status :: 1 - Planning - Intended Audience :: Developers - Intended Audience :: Science/Research - Operating System :: MacOS :: MacOS X - Operating System :: POSIX :: Linux - Programming Language :: Python - Programming Language :: Python :: 3 - Programming Language :: Python :: 3 :: Only - Topic :: Scientific/Engineering -project_urls = - Documentation = https://fastjet.readthedocs.io/ - Bug Tracker = https://github.com/scikit-hep/fastjet/issues - Discussions = https://github.com/scikit-hep/fastjet/discussions - Changelog = https://github.com/scikit-hep/fastjet/releases - -[options] -packages = find: -install_requires = - awkward>=2 - numpy>=1.13.3 - vector -python_requires = >=3.9 -include_package_data = True -package_dir = - =src - -[options.packages.find] -where = src - -[options.extras_require] -dask = - dask>=2023.4.0 - dask-awkward>=2023.4.2 -dev = - pytest>=4.6 -docs = - Sphinx>=3.0.0 - recommonmark>=0.5.0 - sphinx-copybutton - sphinx-rtd-theme>=0.5.0 -test = - pytest>=4.6 - uproot>=5 - dask>=2023.4.0;python_version>"3.7" - dask-awkward[test]>=2023.4.2;python_version>"3.7" - distributed>=2023.4.0;python_version>"3.7" - -[tool:pytest] -addopts = -vv -rs -Wd -testpaths = - tests - -[check-manifest] -ignore = - .github/** - docs/** - .pre-commit-config.yaml - .readthedocs.yml - .clang-format - src/*/version.py - -[tool:isort] -profile = black -multi_line_output = 3 - -[flake8] -ignore = E203, E231, E501, E722, W503, B950 -select = C,E,F,W,T,B,B9,I -per-file-ignores = - tests/*: T - -[mypy] -files = src -python_version = 3.6 -warn_unused_configs = True -disallow_any_generics = True -disallow_subclassing_any = True -disallow_untyped_calls = True -disallow_untyped_defs = True -disallow_incomplete_defs = True -check_untyped_defs = True -disallow_untyped_decorators = True -no_implicit_optional = True -warn_redundant_casts = True -warn_unused_ignores = True -warn_return_any = True -no_implicit_reexport = True -strict_equality = True - -[mypy-numpy] -ignore_missing_imports = True diff --git a/setup.py b/setup.py deleted file mode 100644 index f6a64ff4..00000000 --- a/setup.py +++ /dev/null @@ -1,206 +0,0 @@ -#!/usr/bin/env python -# Copyright (c) 2021, Aryan Roy -# -# Distributed under the 3-clause BSD license, see accompanying file LICENSE -# or https://github.com/scikit-hep/fastjet for details. - -from setuptools import setup # isort:skip - -# Available at setup time due to pyproject.toml -from pybind11.setup_helpers import Pybind11Extension # isort:skip - -import os -import pathlib -import shutil -import subprocess -import sys -import sysconfig -import urllib.request -import zipfile - -import setuptools.command.build_ext -import setuptools.command.install - -CGAL_ZIP = "https://github.com/CGAL/cgal/releases/download/v5.6/CGAL-5.6-library.zip" - -DIR = pathlib.Path(__file__).parent.resolve() -FASTJET = DIR / "extern" / "fastjet-core" -FASTJET_CONTRIB = DIR / "extern" / "fastjet-contrib" -PYTHON = DIR / "src" / "fastjet" -OUTPUT = PYTHON / "_fastjet_core" - - -# Clean up transient directories to allow for rebuilds during development -if (DIR / "build").exists(): - shutil.rmtree(DIR / "build") -if OUTPUT.exists(): - shutil.rmtree(OUTPUT) - -LIBS = [ - "fastjet", - "fastjettools", - "siscone", - "siscone_spherical", - "fastjetplugins", - "fastjetcontribfragile", -] - - -def get_version() -> str: - g = {} - with open(PYTHON / "version.py") as f: - exec(f.read(), g) - return g["__version__"] - - -class FastJetBuild(setuptools.command.build_ext.build_ext): - def build_extensions(self): - if not OUTPUT.exists(): - zip_filename = DIR / pathlib.Path(CGAL_ZIP).parts[-1] - - with urllib.request.urlopen(CGAL_ZIP) as http_obj: - with open(zip_filename, "wb") as file_obj: - shutil.copyfileobj(http_obj, file_obj) - - with zipfile.ZipFile(zip_filename) as zip_obj: - cgal_dir = DIR / zip_obj.namelist()[0] - zip_obj.extractall(DIR) - - # Patch for segfault of LimitedWarning - # For more info see https://github.com/scikit-hep/fastjet/pull/131 - subprocess.run( - ["patch", "src/ClusterSequence.cc", DIR / "patch_clustersequence.txt"], - cwd=FASTJET, - ) - - # RPATH is set for shared libraries in the following locations: - # * fastjet/ - # * fastjet/_fastjet_core/lib/ - # * fastjet/_fastjet_core/lib/python*/site-packages/ - _rpath = "'$$ORIGIN/_fastjet_core/lib:$$ORIGIN:$$ORIGIN/../..'" - env = os.environ.copy() - env["PYTHON"] = sys.executable - env["PYTHON_INCLUDE"] = f'-I{sysconfig.get_path("include")}' - env["CXXFLAGS"] = "-O3 -Bstatic -lgmp -Bdynamic -std=c++17 " + env.get( - "CXXFLAGS", "" - ) - env["LDFLAGS"] = env.get("LDFLAGS", "") + f" -Wl,-rpath,{_rpath}" - env["ORIGIN"] = "$ORIGIN" # if evaluated, it will still be '$ORIGIN' - - args = [ - f"--prefix={OUTPUT}", - "--enable-thread-safety", - "--disable-auto-ptr", - "--enable-allcxxplugins", - "--enable-cgal", - "--enable-cgal-header-only", - f"--with-cgaldir={cgal_dir}", - "--enable-swig", - "--enable-pyext", - f'LDFLAGS={env["LDFLAGS"]}', - ] - - try: - subprocess.run( - ["./autogen.sh"] + args, - cwd=FASTJET, - env=env, - check=True, - ) - except Exception: - subprocess.run(["cat", "config.log"], cwd=FASTJET, check=True) - raise - - env = os.environ.copy() - env["CXX"] = env.get("CXX", "g++") - env["LDFLAGS"] = env.get("LDFLAGS", "") + f" -Wl,-rpath,{_rpath}" - env["ORIGIN"] = "$ORIGIN" # if evaluated, it will still be '$ORIGIN' - subprocess.run(["make", "-j"], cwd=FASTJET, env=env, check=True) - subprocess.run(["make", "install"], cwd=FASTJET, env=env, check=True) - - subprocess.run( - [ - "./configure", - f"--fastjet-config={FASTJET}/fastjet-config", - f'CXX={env["CXX"]}', - "CXXFLAGS=-O3 -Bstatic -Bdynamic -std=c++17 " - + env.get("CXXFLAGS", ""), - f'LDFLAGS={env["LDFLAGS"]}', - ], - cwd=FASTJET_CONTRIB, - env=env, - check=True, - ) - subprocess.run(["make", "-j"], cwd=FASTJET_CONTRIB, env=env, check=True) - subprocess.run( - ["make", "install"], cwd=FASTJET_CONTRIB, env=env, check=True - ) - subprocess.run( - ["make", "fragile-shared"], cwd=FASTJET_CONTRIB, env=env, check=True - ) - subprocess.run( - ["make", "fragile-shared-install"], - cwd=FASTJET_CONTRIB, - env=env, - check=True, - ) - - setuptools.command.build_ext.build_ext.build_extensions(self) - - -class FastJetInstall(setuptools.command.install.install): - def run(self): - fastjetdir = pathlib.Path(f"{self.build_lib}/fastjet") - - shutil.copytree(OUTPUT, fastjetdir / "_fastjet_core", symlinks=True) - - make = "make" - if sys.platform == "darwin": - make = "gmake" - - pythondir = pathlib.Path( - subprocess.check_output( - f"""{make} -f Makefile --eval='print-pythondir: -\t@echo $(pythondir) -' print-pythondir""", - shell=True, - cwd=FASTJET / "pyinterface", - text=True, - ).strip() - ) - - pyexecdir = pathlib.Path( - subprocess.check_output( - f"""{make} -f Makefile --eval='print-pyexecdir: -\t@echo $(pyexecdir) -' print-pyexecdir""", - shell=True, - cwd=FASTJET / "pyinterface", - text=True, - ).strip() - ) - - shutil.copyfile(pythondir / "fastjet.py", fastjetdir / "_swig.py") - shutil.copyfile(pyexecdir / "_fastjet.so", fastjetdir / "_fastjet.so") - - setuptools.command.install.install.run(self) - - -ext_modules = [ - Pybind11Extension( - "fastjet._ext", - ["src/_ext.cpp"], - cxx_std=11, - include_dirs=[str(OUTPUT / "include")], - library_dirs=[str(OUTPUT / "lib")], - runtime_library_dirs=["$ORIGIN/_fastjet_core/lib"], - libraries=LIBS, - ), -] - - -setup( - version=get_version(), - ext_modules=ext_modules, - cmdclass={"build_ext": FastJetBuild, "install": FastJetInstall}, -) diff --git a/src/fastjet/version.py b/src/fastjet/version.py deleted file mode 100644 index af50b60e..00000000 --- a/src/fastjet/version.py +++ /dev/null @@ -1,9 +0,0 @@ -# BSD 3-Clause License; see https://github.com/scikit-hep/fastjet/blob/main/LICENSE - -import re - -__version__ = "3.4.3.1" -version = __version__ -version_info = tuple(re.split(r"[-\.]", __version__)) - -del re