From ee5d8167f9c5b7844cce563bf4025eb5d3689ad5 Mon Sep 17 00:00:00 2001 From: Lindsey Gray Date: Tue, 10 Jun 2025 13:53:58 -0500 Subject: [PATCH 1/4] fastjet 3.5.0; fjcontrib cms-externals rebase; cmake build for unix-likes --- .github/workflows/ci.yml | 99 ++++- .github/workflows/wheels.yml | 59 ++- .gitignore | 1 + .pre-commit-config.yaml | 15 +- ...contrib-top-level-only-cmake-scripts.patch | 390 ++++++++++++++++++ CMakeLists.txt | 62 +++ MANIFEST.in | 6 - extern/fastjet-contrib | 2 +- extern/fastjet-core | 2 +- pyproject.toml | 116 +++++- setup.cfg | 106 ----- setup.py | 206 --------- src/fastjet/__init__.py | 10 + src/fastjet/version.py | 9 - 14 files changed, 713 insertions(+), 370 deletions(-) create mode 100644 0001-fjcontrib-top-level-only-cmake-scripts.patch create mode 100644 CMakeLists.txt delete mode 100644 MANIFEST.in delete mode 100644 setup.cfg delete mode 100644 setup.py delete mode 100644 src/fastjet/version.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 810cc1a9..8d47f642 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,35 +34,45 @@ jobs: fail-fast: false matrix: python-version: ["3.9", "3.13"] - runs-on: [ubuntu-latest, ubuntu-24.04-arm, macos-latest] + runs-on: [ubuntu-latest, ubuntu-24.04-arm, macos-latest] # , windows-latest] arch: [auto64] steps: - uses: actions/checkout@v4 with: submodules: recursive + fetch-depth: 0 - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} + - name: Install compiler tools on windows + if: runner.os == 'windows' + run: | + Install-Module -Name 7Zip4Powershell -Force + Invoke-Webrequest -Uri https://archives.boost.io/release/1.88.0/source/boost_1_88_0.zip -OutFile boost_1_88_0.zip + Invoke-Webrequest -Uri https://github.com/CGAL/cgal/releases/download/v6.0.1/CGAL-6.0.1.zip -OutFile CGAL-6.0.1.zip + Invoke-Webrequest -Uri https://github.com/CGAL/cgal/releases/download/v6.0.1/CGAL-6.0.1-win64-auxiliary-libraries-gmp-mpfr.zip -OutFile cgal_auxlibs.zip + Expand-7Zip boost_1_88_0.zip .\boost_1_88_0 + Expand-7Zip CGAL-6.0.1.zip .\CGAL-6.0.1 + Expand-7Zip cgal_auxlibs.zip .\cgal_auxlibs + vcpkg.exe install getopt + - 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) + - 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) @@ -71,6 +81,17 @@ jobs: echo $PATH python -m pip install '.[test]' -v + - name: Install package (windows) + if: runner.os == 'windows' + run: | + $Env:Path + $Env:GMP_INC_DIR = "${PWD}\cgal_auxlibs\auxiliary\gmp\include" + $Env:GMP_LIB_DIR = "${PWD}\cgal_auxlibs\auxiliary\gmp\lib" + $Env:MPFR_INC_DIR = "${PWD}\cgal_auxlibs\auxiliary\gmp\include" + $Env:MPFR_LIB_DIR = "${PWD}\cgal_auxlibs\auxiliary\gmp\lib" + $Env:CMAKE_PREFIX_PATH = "C:\vcpkg\packages\getopt-win32_x64-windows\share\unofficial-getopt-win32;$Env:CMAKE_PREFIX_PATH" + python -m pip install '.[test]' -v -C"cmake.define.GMP_DLL_TO_COPY"="C:\\a\\fastjet\\fastjet\\cgal_auxlibs\\auxiliary\\gmp\\bin\\gmp-10.dll" -C"cmake.define.Boost_INCLUDE_DIR"="${PWD}\boost_1_88_0\boost_1_88_0" -C"cmake.define.CGAL_DIR"="${PWD}\CGAL-6.0.1\CGAL-6.0.1" -C"cmake.define.FASTJET_ENABLE_DEBUG"="OFF" -C"cmake.define.SISCONE_ENABLE_DEBUG"="OFF" + - name: List installed Python packages run: python -m pip list @@ -83,7 +104,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, ubuntu-24.04-arm, macos-latest, macos-13] + os: [ubuntu-latest, ubuntu-24.04-arm, macos-latest, macos-13] # , windows-latest] python: [313] arch: [auto64] @@ -91,17 +112,31 @@ 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 --force --ignore-dependencies gcc@12 gcc@13 gnupg gnutls isl libmpc nettle gcc mpfr gmp + brew install --ignore-dependencies m4 make automake autoconf libtool swig boost cgal + echo "PATH=/opt/homebrew/opt/make/libexec/gnubin:/opt/homebrew/opt/libtool/libexec/gnubin:$PATH" >> "$GITHUB_ENV" + + - name: Install compiler tools on windows + if: runner.os == 'windows' + run: | + Install-Module -Name 7Zip4Powershell -Force + Invoke-Webrequest -Uri https://archives.boost.io/release/1.88.0/source/boost_1_88_0.zip -OutFile boost_1_88_0.zip + Invoke-Webrequest -Uri https://github.com/CGAL/cgal/releases/download/v6.0.1/CGAL-6.0.1.zip -OutFile CGAL-6.0.1.zip + Invoke-Webrequest -Uri https://github.com/CGAL/cgal/releases/download/v6.0.1/CGAL-6.0.1-win64-auxiliary-libraries-gmp-mpfr.zip -OutFile cgal_auxlibs.zip + Expand-7Zip boost_1_88_0.zip .\boost_1_88_0 + Expand-7Zip CGAL-6.0.1.zip .\CGAL-6.0.1 + Expand-7Zip cgal_auxlibs.zip .\cgal_auxlibs + vcpkg.exe install getopt + + - 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 +145,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,11 +159,41 @@ 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 }} CIBW_BUILD: cp${{ matrix.python }}-* - CIBW_BUILD_VERBOSITY: 2 + CIBW_BUILD_VERBOSITY: 1 + CIBW_CONFIG_SETTINGS_WINDOWS: > + "cmake.define.GMP_DLL_TO_COPY"="C:\\\\a\\\\fastjet\\\\fastjet\\\\cgal_auxlibs\\\\auxiliary\\\\gmp\\\\bin\\\\gmp-10.dll" + "cmake.define.Boost_INCLUDE_DIR"="C:\a\fastjet\fastjet\boost_1_88_0\boost_1_88_0" + "cmake.define.CGAL_DIR"="C:\a\fastjet\fastjet\CGAL-6.0.1\CGAL-6.0.1" + "cmake.define.unofficial-getopt-win32_DIR"="C:\vcpkg\packages\getopt-win32_x64-windows\share\unofficial-getopt-win32" + "cmake.define.FASTJET_ENABLE_DEBUG"="OFF" + "cmake.define.SISCONE_ENABLE_DEBUG"="OFF" + CIBW_ENVIRONMENT_WINDOWS: > + GMP_INC_DIR='C:\a\fastjet\fastjet\cgal_auxlibs\auxiliary\gmp\include' + GMP_LIB_DIR='C:\a\fastjet\fastjet\cgal_auxlibs\auxiliary\gmp\lib' + MPFR_INC_DIR='C:\a\fastjet\fastjet\cgal_auxlibs\auxiliary\gmp\include' + MPFR_LIB_DIR='C:\a\fastjet\fastjet\cgal_auxlibs\auxiliary\gmp\lib' - name: Upload wheels uses: actions/upload-artifact@v4 diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 21f97a5a..69467a48 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 @@ -33,24 +34,34 @@ jobs: fail-fast: false matrix: python: [39, 310, 311, 312, 313] - os: [ubuntu-latest, ubuntu-24.04-arm, macos-latest, macos-13] + os: [ubuntu-latest, ubuntu-24.04-arm, macos-latest, macos-13] # , windows-latest] arch: [auto64] steps: - 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 --force --ignore-dependencies gcc@12 gcc@13 gnupg gnutls isl libmpc nettle gcc mpfr gmp + brew install --ignore-dependencies m4 make automake autoconf libtool swig boost cgal + echo "PATH=/opt/homebrew/opt/make/libexec/gnubin:/opt/homebrew/opt/libtool/libexec/gnubin:$PATH" >> "$GITHUB_ENV" + + - name: Install compiler tools on windows + if: runner.os == 'windows' + run: | + Install-Module -Name 7Zip4Powershell -Force + Invoke-Webrequest -Uri https://archives.boost.io/release/1.88.0/source/boost_1_88_0.zip -OutFile boost_1_88_0.zip + Invoke-Webrequest -Uri https://github.com/CGAL/cgal/releases/download/v6.0.1/CGAL-6.0.1.zip -OutFile CGAL-6.0.1.zip + Invoke-Webrequest -Uri https://github.com/CGAL/cgal/releases/download/v6.0.1/CGAL-6.0.1-win64-auxiliary-libraries-gmp-mpfr.zip -OutFile cgal_auxlibs.zip + Expand-7Zip boost_1_88_0.zip .\boost_1_88_0 + Expand-7Zip CGAL-6.0.1.zip .\CGAL-6.0.1 + Expand-7Zip cgal_auxlibs.zip .\cgal_auxlibs + vcpkg.exe install getopt - name: Clone gmp if: runner.os == 'macOS' @@ -74,11 +85,41 @@ 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 }} CIBW_BUILD: cp${{ matrix.python }}-* - CIBW_BUILD_VERBOSITY: 2 + CIBW_BUILD_VERBOSITY: 1 + CIBW_CONFIG_SETTINGS_WINDOWS: > + "cmake.define.GMP_DLL_TO_COPY"="C:\\\\a\\\\fastjet\\\\fastjet\\\\cgal_auxlibs\\\\auxiliary\\\\gmp\\\\bin\\\\gmp-10.dll" + "cmake.define.Boost_INCLUDE_DIR"="C:\a\fastjet\fastjet\boost_1_88_0\boost_1_88_0" + "cmake.define.CGAL_DIR"="C:\a\fastjet\fastjet\CGAL-6.0.1\CGAL-6.0.1" + "cmake.define.unofficial-getopt-win32_DIR"="C:\vcpkg\packages\getopt-win32_x64-windows\share\unofficial-getopt-win32" + "cmake.define.FASTJET_ENABLE_DEBUG"="OFF" + "cmake.define.SISCONE_ENABLE_DEBUG"="OFF" + CIBW_ENVIRONMENT_WINDOWS: > + GMP_INC_DIR='C:\a\fastjet\fastjet\cgal_auxlibs\auxiliary\gmp\include' + GMP_LIB_DIR='C:\a\fastjet\fastjet\cgal_auxlibs\auxiliary\gmp\lib' + MPFR_INC_DIR='C:\a\fastjet\fastjet\cgal_auxlibs\auxiliary\gmp\include' + MPFR_LIB_DIR='C:\a\fastjet\fastjet\cgal_auxlibs\auxiliary\gmp\lib' - name: Upload wheels uses: actions/upload-artifact@v4 @@ -98,7 +139,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/.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/0001-fjcontrib-top-level-only-cmake-scripts.patch b/0001-fjcontrib-top-level-only-cmake-scripts.patch new file mode 100644 index 00000000..0ff47797 --- /dev/null +++ b/0001-fjcontrib-top-level-only-cmake-scripts.patch @@ -0,0 +1,390 @@ +From fb98d019ce5bc96699ef25cbf08a7b5dcfb9a2b6 Mon Sep 17 00:00:00 2001 +From: Lindsey Gray +Date: Mon, 9 Jun 2025 18:21:34 -0500 +Subject: [PATCH 1/2] top-level-only cmake scripts + +--- + CMakeLists.txt | 229 +++++++++++++++++++++++++++++++++++ + Config.cmake.in | 5 + + contrib_CMakeLists.txt.in | 60 +++++++++ + defines.h.in | 20 +++ + inccontrib_CMakeLists.txt.in | 2 + + incdir_CMakeLists.txt.in | 5 + + incfastjet_CMakeLists.txt.in | 2 + + 7 files changed, 323 insertions(+) + create mode 100644 CMakeLists.txt + create mode 100644 Config.cmake.in + create mode 100644 contrib_CMakeLists.txt.in + create mode 100644 defines.h.in + create mode 100644 inccontrib_CMakeLists.txt.in + create mode 100644 incdir_CMakeLists.txt.in + create mode 100644 incfastjet_CMakeLists.txt.in + +diff --git a/CMakeLists.txt b/CMakeLists.txt +new file mode 100644 +index 0000000..c51bd38 +--- /dev/null ++++ b/CMakeLists.txt +@@ -0,0 +1,229 @@ ++cmake_minimum_required(VERSION 3.7.0) ++include(CMakePrintHelpers) ++ ++# set the project name ++project(FastJetContrib VERSION 1.101) ++# set a pre-release version if relevant, e.g. "-beta1" ++#set(PROJECT_VERSION_PRERELEASE "") ++set(PROJECT_VERSION_PRERELEASE "-devel") ++ ++if(MSVC) ++ execute_process(COMMAND ++ git apply --whitespace=fix -p0 0001-required-source-changes-for-windows-build.patch ++ WORKING_DIRECTORY ++ ${CMAKE_CURRENT_SOURCE_DIR} ++ ) ++endif() ++ ++#---------------------------------------------------------------------- ++# version information ++set(FASTJETCONTRIB_VERSION "${PROJECT_VERSION}${PROJECT_VERSION_PRERELEASE}") ++ ++set(FASTJETCONTRIB_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}") ++set(FASTJETCONTRIB_VERSION_MINOR "${PROJECT_VERSION_MINOR}") ++set(FASTJETCONTRIB_VERSION_PATCHLEVEL "${PROJECT_VERSION_PATCH}") ++set(FASTJETCONTRIB_VERSION_PRERELEASE "${PROJECT_VERSION_PRERELEASE}") ++# build a unique version number ++if (FASTJETCONTRIB_VERSION_MINOR LESS 10) ++ set(FASTJETCONTRIB_VERSION_MINOR_FOR_NUMBER "0${FASTJETCONTRIB_VERSION_MINOR}") ++else() ++ set(FASTJETCONTRIB_VERSION_MINOR_FOR_NUMBER "${FASTJETCONTRIB_VERSION_MINOR}") ++endif() ++if (FASTJETCONTRIB_VERSION_PATCHLEVEL LESS 10) ++ set(FASTJETCONTRIB_VERSION_PATCHLEVEL_FOR_NUMBER "0${FASTJETCONTRIB_VERSION_PATCHLEVEL}") ++else() ++ set(FASTJETCONTRIB_VERSION_PATCHLEVEL_FOR_NUMBER "${FASTJETCONTRIB_VERSION_PATCHLEVEL}") ++endif() ++set(FASTJETCONTRIB_VERSION_NUMBER "${FASTJETCONTRIB_VERSION_MAJOR}${FASTJETCONTRIB_VERSION_MINOR_FOR_NUMBER}${FASTJETCONTRIB_VERSION_PATCHLEVEL_FOR_NUMBER}") ++ ++# print out the project name and version ++cmake_print_variables(PROJECT_NAME FASTJETCONTRIB_VERSION) ++ ++# need this to be able to set the installation prefix in fastjet-config ++include(GNUInstallDirs) ++ ++#---------------------------------------------------------------------- ++# basic C++ checks ++#---------------------------------------------------------------------- ++ ++# specify the C++ standard ++set(CMAKE_CXX_STANDARD 14) ++set(CMAKE_CXX_STANDARD_REQUIRED ON) ++set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}) ++set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG") ++if (MSVC) ++ set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) ++endif() ++ ++ ++if (CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM") # Intel compilers are used with -O3 ++ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -Wall -Wshadow") ++elseif (MSVC) ++ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:__cplusplus /utf-8 /W4 /Ox") ++else() ++ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -Wall -Wshadow") ++endif() ++ ++# all contribs require fastjet so get it now! ++if(NOT TARGET fastjet::fastjet) ++ find_package(fastjet REQUIRED) ++endif() ++ ++list(APPEND fjcontrib_DIRNAMES ++ GenericSubtractor ++ JetFFMoments ++ VariableR ++ Nsubjettiness ++ EnergyCorrelator ++ ScJet ++ SubjetCounting ++ JetCleanser ++ JetsWithoutJets ++ ConstituentSubtractor ++ RecursiveTools ++ SoftKiller ++ ValenciaPlugin ++ ClusteringVetoPlugin ++ QCDAwarePlugin ++ FlavorCone ++ LundPlane ++ Centauro ++ KTClusCXX ++ SignalFreeBackgroundEstimator ++ IFNPlugin ++ CMPPlugin ++ SDFPlugin ++ GHSAlgo ++) ++ ++foreach (FJCONTRIB_NAME ${fjcontrib_DIRNAMES}) ++ string(TOUPPER ${FJCONTRIB_NAME} FJCONTRIB_NAME_UPPER) ++ option(FASTJETCONTRIB_ENABLE_${FJCONTRIB_NAME_UPPER} "Enable the ${FJCONTRIB_NAME} Contrib [default=ON]" ON) ++endforeach() ++option(FASTJETCONTRIB_ENABLE_FRAGILELIB "Enable fragile combined mono-library [default=OFF]" OFF) ++ ++set(fjcontrib_combined_TARGETS) ++ ++foreach (FJCONTRIB_NAME ${fjcontrib_DIRNAMES}) ++ ++ string(TOUPPER ${FJCONTRIB_NAME} FJCONTRIB_NAME_UPPER) ++ string(TOLOWER ${FJCONTRIB_NAME} FJCONTRIB_NAME_LOWER) ++ if (FASTJETCONTRIB_ENABLE_${FJCONTRIB_NAME_UPPER}) ++ configure_file(defines.h.in ${FJCONTRIB_NAME}/include/${FJCONTRIB_NAME_LOWER}_defines.h) ++ ++ set(SRCLINE) ++ set(INCLLINE) ++ set(DEPLINE) ++ file(STRINGS ${FJCONTRIB_NAME}/Makefile FJCONTRIB_MAKEFILE) ++ while(FJCONTRIB_MAKEFILE) ++ list(POP_FRONT FJCONTRIB_MAKEFILE MAKEFILE_LINE) ++ #message("${MAKEFILE_LINE}") ++ if(MAKEFILE_LINE MATCHES "^SRCS=") ++ string(REPLACE "SRCS=" "" SRCLINE "${MAKEFILE_LINE}") ++ set(${FJCONTRIB_NAME_LOWER}_SOURCES "${SRCLINE}") ++ endif() ++ if(MAKEFILE_LINE MATCHES "^INSTALLED_HEADERS=") ++ string(REPLACE "INSTALLED_HEADERS=" "" INCLLINE "${MAKEFILE_LINE}") ++ set(${FJCONTRIB_NAME_LOWER}_INCLUDES "${INCLLINE}") ++ endif() ++ if(MAKEFILE_LINE MATCHES "^DEPENDS_ON\ =") ++ string(REPLACE "DEPENDS_ON\ =" "" DEPLINE "${MAKEFILE_LINE}") ++ string(STRIP "${DEPLINE}" DEPLINE) ++ set(${FJCONTRIB_NAME_LOWER}_DEPENDENCIES "${DEPLINE}") ++ endif() ++ endwhile() ++ ++ if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${FJCONTRIB_NAME}/include) ++ configure_file(incfastjet_CMakeLists.txt.in ${CMAKE_CURRENT_SOURCE_DIR}/${FJCONTRIB_NAME}/include/CMakeLists.txt COPYONLY) ++ configure_file(inccontrib_CMakeLists.txt.in ${CMAKE_CURRENT_SOURCE_DIR}/${FJCONTRIB_NAME}/include/fastjet/CMakeLists.txt COPYONLY) ++ configure_file(incdir_CMakeLists.txt.in ${CMAKE_CURRENT_SOURCE_DIR}/${FJCONTRIB_NAME}/include/fastjet/contrib/CMakeLists.txt) ++ endif() ++ configure_file(contrib_CMakeLists.txt.in ${CMAKE_CURRENT_SOURCE_DIR}/${FJCONTRIB_NAME}/CMakeLists.txt) ++ ++ add_subdirectory(${FJCONTRIB_NAME}) ++ if (TARGET ${FJCONTRIB_NAME}) ++ if (FASTJETCONTRIB_ENABLE_FRAGILELIB) ++ set_target_properties(${FJCONTRIB_NAME} PROPERTIES POSITION_INDEPENDENT_CODE True) ++ endif() ++ if (MSVC) ++ target_compile_definitions(${FJCONTRIB_NAME} PUBLIC _USE_MATH_DEFINES) ++ if (FASTJETCONTRIB_ENABLE_FRAGILELIB) ++ target_compile_definitions(${FJCONTRIB_NAME} PRIVATE fastjetcontrib_EXPORTS) ++ else() ++ target_compile_definitions(${FJCONTRIB_NAME} PRIVATE ${FJCONTRIB_NAME_LOWER}_EXPORTS) ++ endif() ++ endif() ++ list(APPEND fjcontrib_combined_TARGETS $) ++ endif() ++ endif() ++ ++endforeach() ++ ++if (fjcontrib_combined_TARGETS AND FASTJETCONTRIB_ENABLE_FRAGILELIB) ++ add_library(fastjetcontribfragile SHARED ${fjcontrib_combined_TARGETS}) ++ target_link_libraries(fastjetcontribfragile PUBLIC fastjet::fastjettools) ++ foreach (FJCONTRIB_NAME ${fjcontrib_DIRNAMES}) ++ target_include_directories(fastjetcontribfragile ++ PUBLIC ++ $ ++ $ ++ $ ++ ) ++ endforeach() ++ ++ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") ++ set_target_properties(fastjetcontribfragile PROPERTIES INSTALL_RPATH "@loader_path") ++ elseif (NOT MSVC) ++ set_target_properties(fastjetcontribfragile PROPERTIES INSTALL_RPATH "$ORIGIN") ++ endif() ++ ++ add_library(fastjet::contrib::fastjetcontribfragile ALIAS fastjetcontribfragile) ++ install(TARGETS ++ fastjetcontribfragile ++ EXPORT ++ FastjetContribTargets ++ RUNTIME ++ COMPONENT Runtime ++ DESTINATION ${CMAKE_INSTALL_BINDIR} ++ LIBRARY ++ COMPONENT Runtime ++ DESTINATION ${CMAKE_INSTALL_LIBDIR} ++ ARCHIVE ++ COMPONENT Development ++ DESTINATION ${CMAKE_INSTALL_LIBDIR} ++ ) ++endif() ++ ++# allow Fastjet Contrib to work with find_package ++export(EXPORT FastjetContribTargets ++ NAMESPACE fastjet::contrib:: ++ FILE "${CMAKE_CURRENT_BINARY_DIR}/fastjetcontribTargets.cmake" ++) ++ ++install(EXPORT FastjetContribTargets ++ NAMESPACE fastjet::contrib:: ++ FILE fastjetcontribTargets.cmake ++ DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/fastjetcontrib ++) ++ ++include(CMakePackageConfigHelpers) ++ ++configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in ++ "${CMAKE_CURRENT_BINARY_DIR}/fastjetcontribConfig.cmake" ++ INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/fastjetcontrib" ++ NO_SET_AND_CHECK_MACRO ++ NO_CHECK_REQUIRED_COMPONENTS_MACRO ++ ) ++ ++write_basic_package_version_file( ++ "${CMAKE_CURRENT_BINARY_DIR}/fastjetcontribConfigVersion.cmake" ++ VERSION "${PROJECT_VERSION}" ++ COMPATIBILITY AnyNewerVersion ++ ) ++ ++install(FILES ++ ${CMAKE_CURRENT_BINARY_DIR}/fastjetcontribConfig.cmake ++ ${CMAKE_CURRENT_BINARY_DIR}/fastjetcontribConfigVersion.cmake ++ DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/fastjetcontrib ++ ) ++ +diff --git a/Config.cmake.in b/Config.cmake.in +new file mode 100644 +index 0000000..e4534aa +--- /dev/null ++++ b/Config.cmake.in +@@ -0,0 +1,5 @@ ++@PACKAGE_INIT@ ++ ++find_package(fastjet REQUIRED) ++ ++include ( "${CMAKE_CURRENT_LIST_DIR}/fastjetcontribTargets.cmake" ) +diff --git a/contrib_CMakeLists.txt.in b/contrib_CMakeLists.txt.in +new file mode 100644 +index 0000000..6b5df86 +--- /dev/null ++++ b/contrib_CMakeLists.txt.in +@@ -0,0 +1,60 @@ ++if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${FJCONTRIB_NAME}/include) ++ add_subdirectory(include) ++ install(FILES ++ ${CMAKE_CURRENT_BINARY_DIR}/${FJCONTRIB_NAME}/include/${FJCONTRIB_NAME_LOWER}_defines.h ++ DESTINATION ++ include/fastjet/contrib ++ ) ++else() ++ file(COPY ${${FJCONTRIB_NAME_LOWER}_INCLUDES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/${FJCONTRIB_NAME}/include/fastjet/contrib) ++ install(FILES ++ ${${FJCONTRIB_NAME_LOWER}_INCLUDES} ++ ${CMAKE_CURRENT_BINARY_DIR}/${FJCONTRIB_NAME}/include/${FJCONTRIB_NAME_LOWER}_defines.h ++ DESTINATION ++ include/fastjet/contrib ++ ) ++endif() ++ ++if(${FJCONTRIB_NAME_LOWER}_SOURCES) ++ ++ ++ if (FASTJETCONTRIB_ENABLE_FRAGILELIB) ++ add_library(${FJCONTRIB_NAME} OBJECT ${${FJCONTRIB_NAME_LOWER}_SOURCES}) ++ else() ++ add_library(${FJCONTRIB_NAME} SHARED ${${FJCONTRIB_NAME_LOWER}_SOURCES}) ++ endif() ++ target_link_libraries(${FJCONTRIB_NAME} PUBLIC fastjet::fastjettools ${${FJCONTRIB_NAME_LOWER}_DEPENDENCIES}) ++ if("${FJCONTRIB_NAME}" STREQUAL "SDFPlugin") ++ target_link_libraries(${FJCONTRIB_NAME} PUBLIC fastjet::fastjetplugins) ++ endif() ++ target_include_directories(${FJCONTRIB_NAME} ++ PUBLIC ++ $ ++ $ ++ $ ++ ) ++ ++ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") ++ set_target_properties(${FJCONTRIB_NAME} PROPERTIES INSTALL_RPATH "@loader_path") ++ elseif (NOT MSVC) ++ set_target_properties(${FJCONTRIB_NAME} PROPERTIES INSTALL_RPATH "$ORIGIN") ++ endif() ++ ++ if (NOT FASTJETCONTRIB_ENABLE_FRAGILELIB) ++ add_library(fastjet::contrib::${FJCONTRIB_NAME} ALIAS ${FJCONTRIB_NAME}) ++ install(TARGETS ++ ${FJCONTRIB_NAME} ++ EXPORT ++ FastjetContribTargets ++ RUNTIME ++ COMPONENT Runtime ++ DESTINATION ${CMAKE_INSTALL_BINDIR} ++ LIBRARY ++ COMPONENT Runtime ++ DESTINATION ${CMAKE_INSTALL_LIBDIR} ++ ARCHIVE ++ COMPONENT Development ++ DESTINATION ${CMAKE_INSTALL_LIBDIR} ++ ) ++ endif() ++endif() +diff --git a/defines.h.in b/defines.h.in +new file mode 100644 +index 0000000..a922989 +--- /dev/null ++++ b/defines.h.in +@@ -0,0 +1,20 @@ ++// Required definitions for exporting static variables in windows builds. ++// This is only needed for static data variables since we use ++// the CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON automation when building with cmake. ++// That automation handles all member functions. ++// So, when making a static variable please add in the beginning of a variable ++// definition, like a keyword. It is very important to use the visibility relevant ++// to the library you are working in, see below for possibilities! ++// e.g.: Nsubjettiness_VISIBILITY static bool verbosity; // inside a SomeClass.h, for instance ++// Similarly for declarations you must prefix the appropriate VISIBILITY ++// e.g. Nsubjettiness_VISIBILITY static bool SomeClass::verbosity = true; // in SomeClass.cc ++#ifdef _WIN32 ++ #if defined(${FJCONTRIB_NAME_LOWER}_EXPORTS) || defined(fastjetcontrib_EXPORTS) ++ #define ${FJCONTRIB_NAME_LOWER}_VISIBILITY __declspec(dllexport) // Export when building the DLL ++ #else ++ #define ${FJCONTRIB_NAME_LOWER}_VISIBILITY __declspec(dllimport) // Import when using the DLL ++ #endif ++#else ++ // For Linux/macOS ++ #define ${FJCONTRIB_NAME_LOWER}_VISIBILITY ++#endif +diff --git a/inccontrib_CMakeLists.txt.in b/inccontrib_CMakeLists.txt.in +new file mode 100644 +index 0000000..19c35f6 +--- /dev/null ++++ b/inccontrib_CMakeLists.txt.in +@@ -0,0 +1,2 @@ ++add_subdirectory(contrib) ++ +diff --git a/incdir_CMakeLists.txt.in b/incdir_CMakeLists.txt.in +new file mode 100644 +index 0000000..86f9c72 +--- /dev/null ++++ b/incdir_CMakeLists.txt.in +@@ -0,0 +1,5 @@ ++install(FILES ++ ${${FJCONTRIB_NAME_LOWER}_INCLUDES} ++ DESTINATION ++ include/fastjet/contrib ++ ) +diff --git a/incfastjet_CMakeLists.txt.in b/incfastjet_CMakeLists.txt.in +new file mode 100644 +index 0000000..e05498f +--- /dev/null ++++ b/incfastjet_CMakeLists.txt.in +@@ -0,0 +1,2 @@ ++add_subdirectory(fastjet) ++ +-- +2.39.5 (Apple Git-154) + diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..2eebaf00 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,62 @@ +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) + +option(SKHEPFJ_USE_INSTALLED_FASTJET "Use an existing installed version of fastjet" OFF) +option(SKHEPFJ_USE_INSTALLED_FASTJET_CONTRIB "Use an existing installed version of fastjet-contrib" OFF) +option(SKHEPFJ_PATCH_FJCONTRIB "Patch fastjet-contrib with cmake build" ON) + +set(PKG_INSTALL "fastjet") ## python package name + +find_package(pybind11 REQUIRED) + +if (SKHEPFJ_USE_INSTALLED_FASTJET) + find_package(fastjet REQUIRED) +else() + add_subdirectory(${CMAKE_SOURCE_DIR}/extern/fastjet-core) +endif() + +if (SKHEPFJ_USE_INSTALLED_FASTJET_CONTRIB) + find_package(fastjetcontrib REQUIRED) +else() + message("${CMAKE_CURRENT_SOURCE_DIR}/extern/fastjet-contrib") + if (SKHEPFJ_PATCH_FJCONTRIB) + execute_process(COMMAND + git apply --whitespace=fix ../../0001-fjcontrib-top-level-only-cmake-scripts.patch + WORKING_DIRECTORY + ${CMAKE_CURRENT_SOURCE_DIR}/extern/fastjet-contrib + ) + endif() + add_subdirectory(${CMAKE_SOURCE_DIR}/extern/fastjet-contrib) +endif() + +pybind11_add_module(_ext MODULE src/_ext.cpp) +target_link_libraries(_ext + PRIVATE + fastjet::fastjet + fastjet::contrib::fastjetcontribfragile + ) +if (MSVC) + target_compile_definitions(_ext PRIVATE _USE_MATH_DEFINES) +endif() +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/${CMAKE_INSTALL_LIBDIR}") +elseif(NOT MSVC) + set_target_properties(_ext PROPERTIES INSTALL_RPATH "$ORIGIN/${CMAKE_INSTALL_LIBDIR}") +endif() + +if (MSVC AND FASTJET_ENABLE_CGAL) + message("-- Copying ${GMP_DLL_TO_COPY} to project area!") + install(FILES ${GMP_DLL_TO_COPY} DESTINATION ${CMAKE_INSTALL_PREFIX}) +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..9bd5b79e 160000 --- a/extern/fastjet-contrib +++ b/extern/fastjet-contrib @@ -1 +1 @@ -Subproject commit aa1972cd2b3e8aa2c76764f14122e8f728c23712 +Subproject commit 9bd5b79e0667b6f9769d1c7755320c55fc0e4595 diff --git a/extern/fastjet-core b/extern/fastjet-core index 0648cfc3..12a34ba4 160000 --- a/extern/fastjet-core +++ b/extern/fastjet-core @@ -1 +1 @@ -Subproject commit 0648cfc312bbfefbaa28ffa2cb29b010f88e163c +Subproject commit 12a34ba4032718036a7755fbff65ee6aa5db962f diff --git a/pyproject.toml b/pyproject.toml index be3ca686..31318877 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,<2.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,31 @@ 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_ALLCXXPLUGINS = "ON" +FASTJETCONTRIB_ENABLE_FRAGILELIB = "ON" + +[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/__init__.py b/src/fastjet/__init__.py index a3726bf4..03b2fbd3 100644 --- a/src/fastjet/__init__.py +++ b/src/fastjet/__init__.py @@ -1,5 +1,15 @@ # BSD 3-Clause License; see https://github.com/scikit-hep/fastjet/blob/main/LICENSE +import os as _os + +if _os.name == "nt": + module_dir = _os.path.dirname(_os.path.abspath(__file__)) + + dll_dir1 = _os.path.abspath(_os.path.join(module_dir, "bin")) + + if _os.path.exists(dll_dir1): + _os.add_dll_directory(dll_dir1) + from typing import Union import awkward as ak 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 From f3dd6ff29b9bf31787041169c7f0b5a26d04206c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 10 Jun 2025 18:55:56 +0000 Subject: [PATCH 2/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- ...fjcontrib-top-level-only-cmake-scripts.patch | 17 ++++++++--------- CMakeLists.txt | 2 +- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/0001-fjcontrib-top-level-only-cmake-scripts.patch b/0001-fjcontrib-top-level-only-cmake-scripts.patch index 0ff47797..67c0bd5a 100644 --- a/0001-fjcontrib-top-level-only-cmake-scripts.patch +++ b/0001-fjcontrib-top-level-only-cmake-scripts.patch @@ -36,7 +36,7 @@ index 0000000..c51bd38 +set(PROJECT_VERSION_PRERELEASE "-devel") + +if(MSVC) -+ execute_process(COMMAND ++ execute_process(COMMAND + git apply --whitespace=fix -p0 0001-required-source-changes-for-windows-build.patch + WORKING_DIRECTORY + ${CMAKE_CURRENT_SOURCE_DIR} @@ -182,7 +182,7 @@ index 0000000..c51bd38 + endif() + endif() + list(APPEND fjcontrib_combined_TARGETS $) -+ endif() ++ endif() + endif() + +endforeach() @@ -193,7 +193,7 @@ index 0000000..c51bd38 + foreach (FJCONTRIB_NAME ${fjcontrib_DIRNAMES}) + target_include_directories(fastjetcontribfragile + PUBLIC -+ $ ++ $ + $ + $ + ) @@ -208,7 +208,7 @@ index 0000000..c51bd38 + add_library(fastjet::contrib::fastjetcontribfragile ALIAS fastjetcontribfragile) + install(TARGETS + fastjetcontribfragile -+ EXPORT ++ EXPORT + FastjetContribTargets + RUNTIME + COMPONENT Runtime @@ -318,7 +318,7 @@ index 0000000..6b5df86 + add_library(fastjet::contrib::${FJCONTRIB_NAME} ALIAS ${FJCONTRIB_NAME}) + install(TARGETS + ${FJCONTRIB_NAME} -+ EXPORT ++ EXPORT + FastjetContribTargets + RUNTIME + COMPONENT Runtime @@ -372,9 +372,9 @@ index 0000000..86f9c72 --- /dev/null +++ b/incdir_CMakeLists.txt.in @@ -0,0 +1,5 @@ -+install(FILES ++install(FILES + ${${FJCONTRIB_NAME_LOWER}_INCLUDES} -+ DESTINATION ++ DESTINATION + include/fastjet/contrib + ) diff --git a/incfastjet_CMakeLists.txt.in b/incfastjet_CMakeLists.txt.in @@ -385,6 +385,5 @@ index 0000000..e05498f @@ -0,0 +1,2 @@ +add_subdirectory(fastjet) + --- +-- 2.39.5 (Apple Git-154) - diff --git a/CMakeLists.txt b/CMakeLists.txt index 2eebaf00..04d8daf6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,7 +28,7 @@ if (SKHEPFJ_USE_INSTALLED_FASTJET_CONTRIB) else() message("${CMAKE_CURRENT_SOURCE_DIR}/extern/fastjet-contrib") if (SKHEPFJ_PATCH_FJCONTRIB) - execute_process(COMMAND + execute_process(COMMAND git apply --whitespace=fix ../../0001-fjcontrib-top-level-only-cmake-scripts.patch WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/extern/fastjet-contrib From 4e29fa12fc6b65be0c99cc77b05dea1bf13691e8 Mon Sep 17 00:00:00 2001 From: Lindsey Gray Date: Tue, 10 Jun 2025 14:07:17 -0500 Subject: [PATCH 3/4] patch on fastjet 3.5.0 to consistently use CMAKE_INSTALL_LIBDIR --- ...L_LIBDIR-consistently-in-pyinterface.patch | 28 +++++++++++++++++++ CMakeLists.txt | 9 +++++- 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 0001-use-CMAKE_INSTALL_LIBDIR-consistently-in-pyinterface.patch diff --git a/0001-use-CMAKE_INSTALL_LIBDIR-consistently-in-pyinterface.patch b/0001-use-CMAKE_INSTALL_LIBDIR-consistently-in-pyinterface.patch new file mode 100644 index 00000000..9e6a033f --- /dev/null +++ b/0001-use-CMAKE_INSTALL_LIBDIR-consistently-in-pyinterface.patch @@ -0,0 +1,28 @@ +From fce87ff35162b911fc2241637b1f3516e4bb2d2f Mon Sep 17 00:00:00 2001 +From: Lindsey Gray +Date: Tue, 10 Jun 2025 14:04:22 -0500 +Subject: [PATCH] use CMAKE_INSTALL_LIBDIR consistently in pyinterface + +--- + pyinterface/CMakeLists.txt | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/pyinterface/CMakeLists.txt b/pyinterface/CMakeLists.txt +index 7016f179..88aa2ad4 100644 +--- a/pyinterface/CMakeLists.txt ++++ b/pyinterface/CMakeLists.txt +@@ -21,9 +21,9 @@ set_property(TARGET fastjet_swig PROPERTY SWIG_USE_TARGET_INCLUDE_DIRECTORIES TR + + # NB this is specifically for building scikit-hep/fastjet wheels + if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") +- set_target_properties(fastjet_swig PROPERTIES INSTALL_RPATH "@loader_path/../lib;@loader_path/../../../../lib") ++ set_target_properties(fastjet_swig PROPERTIES INSTALL_RPATH "@loader_path/../${CMAKE_INSTALL_LIBDIR};@loader_path/../../../../${CMAKE_INSTALL_LIBDIR}") + else() +- set_target_properties(fastjet_swig PROPERTIES INSTALL_RPATH "$ORIGIN/../lib:$ORIGIN/../../../../lib") ++ set_target_properties(fastjet_swig PROPERTIES INSTALL_RPATH "$ORIGIN/../${CMAKE_INSTALL_LIBDIR}:$ORIGIN/../../../../${CMAKE_INSTALL_LIBDIR}") + endif() + + # Unix only, Windows is different +-- +2.39.5 (Apple Git-154) + diff --git a/CMakeLists.txt b/CMakeLists.txt index 04d8daf6..ba2945f8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,6 +11,7 @@ project(fastjet VERSION ${SPLIT_VERSION_MAJOR}.${SPLIT_VERSION_MINOR} LANGUAGES option(SKHEPFJ_USE_INSTALLED_FASTJET "Use an existing installed version of fastjet" OFF) option(SKHEPFJ_USE_INSTALLED_FASTJET_CONTRIB "Use an existing installed version of fastjet-contrib" OFF) +option(SKHEPFJ_PATCH_FJCORE "Patch fastjet-contrib with CMAKE_INSTALL_LIBDIR use" ON) option(SKHEPFJ_PATCH_FJCONTRIB "Patch fastjet-contrib with cmake build" ON) set(PKG_INSTALL "fastjet") ## python package name @@ -20,13 +21,19 @@ find_package(pybind11 REQUIRED) if (SKHEPFJ_USE_INSTALLED_FASTJET) find_package(fastjet REQUIRED) else() + if (SKHEPFJ_PATCH_FJCORE) + execute_process(COMMAND + git apply --whitespace=fix ../../0001-use-CMAKE_INSTALL_LIBDIR-consistently-in-pyinterface.patch + WORKING_DIRECTORY + ${CMAKE_CURRENT_SOURCE_DIR}/extern/fastjet-core + ) + endif() add_subdirectory(${CMAKE_SOURCE_DIR}/extern/fastjet-core) endif() if (SKHEPFJ_USE_INSTALLED_FASTJET_CONTRIB) find_package(fastjetcontrib REQUIRED) else() - message("${CMAKE_CURRENT_SOURCE_DIR}/extern/fastjet-contrib") if (SKHEPFJ_PATCH_FJCONTRIB) execute_process(COMMAND git apply --whitespace=fix ../../0001-fjcontrib-top-level-only-cmake-scripts.patch From a39c9215de0d0dba7475d623c67449c76231a286 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 10 Jun 2025 19:07:58 +0000 Subject: [PATCH 4/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- ...-CMAKE_INSTALL_LIBDIR-consistently-in-pyinterface.patch | 7 +++---- CMakeLists.txt | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/0001-use-CMAKE_INSTALL_LIBDIR-consistently-in-pyinterface.patch b/0001-use-CMAKE_INSTALL_LIBDIR-consistently-in-pyinterface.patch index 9e6a033f..4257ffab 100644 --- a/0001-use-CMAKE_INSTALL_LIBDIR-consistently-in-pyinterface.patch +++ b/0001-use-CMAKE_INSTALL_LIBDIR-consistently-in-pyinterface.patch @@ -12,7 +12,7 @@ index 7016f179..88aa2ad4 100644 --- a/pyinterface/CMakeLists.txt +++ b/pyinterface/CMakeLists.txt @@ -21,9 +21,9 @@ set_property(TARGET fastjet_swig PROPERTY SWIG_USE_TARGET_INCLUDE_DIRECTORIES TR - + # NB this is specifically for building scikit-hep/fastjet wheels if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - set_target_properties(fastjet_swig PROPERTIES INSTALL_RPATH "@loader_path/../lib;@loader_path/../../../../lib") @@ -21,8 +21,7 @@ index 7016f179..88aa2ad4 100644 - set_target_properties(fastjet_swig PROPERTIES INSTALL_RPATH "$ORIGIN/../lib:$ORIGIN/../../../../lib") + set_target_properties(fastjet_swig PROPERTIES INSTALL_RPATH "$ORIGIN/../${CMAKE_INSTALL_LIBDIR}:$ORIGIN/../../../../${CMAKE_INSTALL_LIBDIR}") endif() - + # Unix only, Windows is different --- +-- 2.39.5 (Apple Git-154) - diff --git a/CMakeLists.txt b/CMakeLists.txt index ba2945f8..eb562035 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,7 @@ if (SKHEPFJ_USE_INSTALLED_FASTJET) find_package(fastjet REQUIRED) else() if (SKHEPFJ_PATCH_FJCORE) - execute_process(COMMAND + execute_process(COMMAND git apply --whitespace=fix ../../0001-use-CMAKE_INSTALL_LIBDIR-consistently-in-pyinterface.patch WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/extern/fastjet-core