Skip to content

Commit 141966a

Browse files
committed
scikit-build-core based wheels using fastjet cmake; linux, macos, windows
1 parent 0520645 commit 141966a

File tree

14 files changed

+305
-371
lines changed

14 files changed

+305
-371
lines changed

.github/workflows/ci.yml

Lines changed: 70 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,35 +34,39 @@ jobs:
3434
fail-fast: false
3535
matrix:
3636
python-version: ["3.9", "3.13"]
37-
runs-on: [ubuntu-latest, ubuntu-24.04-arm, macos-latest]
37+
runs-on: [ubuntu-latest, ubuntu-24.04-arm, macos-latest, windows-latest]
3838
arch: [auto64]
3939
steps:
4040
- uses: actions/checkout@v4
4141
with:
4242
submodules: recursive
43+
fetch-depth: 0
4344

4445
- uses: actions/setup-python@v5
4546
with:
4647
python-version: ${{ matrix.python-version }}
4748

49+
- name: Install compiler tools on windows
50+
if: runner.os == 'windows'
51+
run: |
52+
choco install boost-msvc-14.1
53+
vcpkg.exe install cgal getopt
54+
4855
- name: Install compiler tools on macOS
4956
if: runner.os == 'macOS'
5057
run: |
51-
brew install make automake swig gmp mpfr boost libtool
58+
brew reinstall gfortran
59+
brew install swig boost cgal gmp mpfr
5260
5361
- name: Install extra deps on Linux
5462
if: runner.os == 'Linux'
55-
run: sudo apt-get update && sudo apt-get install -y libboost-dev libmpfr-dev swig autoconf libtool
63+
run: sudo apt-get update && sudo apt-get install -y libboost-dev libmpfr-dev swig libcgal-dev
5664

57-
- name: Install package (MacOS)
65+
- name: Install package (macOS)
5866
if: runner.os == 'macOS'
5967
run: |
6068
eval "$(/opt/homebrew/bin/brew shellenv)"
6169
export PATH="/opt/homebrew/opt/make/libexec/gnubin:/opt/homebrew/opt/libtool/libexec/gnubin:$PATH"
62-
export CPPFLAGS+="-I/opt/homebrew/include -L/opt/homebrew/lib"
63-
export CXXFLAGS+="-I/opt/homebrew/include -L/opt/homebrew/lib"
64-
export CFLAGS+="-I/opt/homebrew/include -L/opt/homebrew/lib"
65-
export LDFLAGS+="-L/opt/homebrew/lib"
6670
python -m pip install '.[test]' -v
6771
6872
- name: Install package (Linux)
@@ -71,6 +75,18 @@ jobs:
7175
echo $PATH
7276
python -m pip install '.[test]' -v
7377
78+
- name: Install package (windows)
79+
if: runner.os == 'windows'
80+
run: |
81+
$Env:Path
82+
$Env:CGAL_DIR = 'C:\vcpkg\packages\cgal_x64-windows\share\cgal'
83+
$Env:GMP_INC_DIR = 'C:\vcpkg\packages\gmp_x64-windows\include'
84+
$Env:GMP_LIB_DIR = 'C:\vcpkg\packages\gmp_x64-windows\lib'
85+
$Env:MPFR_INC_DIR = 'C:\vcpkg\packages\mpfr_x64-windows\include'
86+
$Env:MPFR_LIB_DIR = 'C:\vcpkg\packages\mpfr_x64-windows\lib'
87+
$Env:CMAKE_PREFIX_PATH = "C:\vcpkg\packages\getopt-win32_x64-windows\share\unofficial-getopt-win32;$Env:CMAKE_PREFIX_PATH"
88+
python -m pip install '.[test]' -v -C"cmake.define.GMP_DLL_TO_COPY"="C:\\vcpkg\\packages\\gmp_x64-windows\\bin\\gmp-10.dll" -C"cmake.define.FASTJET_ENABLE_DEBUG"="OFF" -C"cmake.define.SISCONE_ENABLE_DEBUG"="OFF"
89+
7490
- name: List installed Python packages
7591
run: python -m pip list
7692

@@ -83,25 +99,33 @@ jobs:
8399
strategy:
84100
fail-fast: false
85101
matrix:
86-
os: [ubuntu-latest, ubuntu-24.04-arm, macos-latest, macos-13]
102+
os: [ubuntu-latest, ubuntu-24.04-arm, macos-latest, macos-13, windows-latest]
87103
python: [313]
88104
arch: [auto64]
89105

90106
steps:
91107
- uses: actions/checkout@v4
92108
with:
93109
submodules: recursive
110+
fetch-depth: 0
94111

95112
- name: Install compiler tools on macOS
96113
if: runner.os == 'macOS'
97114
run: |
98-
brew install make automake swig mpfr boost libtool
99-
echo "PATH=/opt/homebrew/opt/make/libexec/gnubin:/opt/homebrew/opt/libtool/libexec/gnubin:$PATH" >> "$GITHUB_ENV"
100-
echo "CPPFLAGS=-I/opt/homebrew/include -L/opt/homebrew/lib $CPPFLAGS" >> "$GITHUB_ENV"
101-
echo "CXXFLAGS=-I/opt/homebrew/include -L/opt/homebrew/lib $CXXFLAGS" >> "$GITHUB_ENV"
102-
echo "CFLAGS=-I/opt/homebrew/include -L/opt/homebrew/lib $CFLAGS" >> "$GITHUB_ENV"
103-
echo "LDFLAGS=-L/opt/homebrew/lib $LDFLAGS" >> "$GITHUB_ENV"
104115
echo "MACOSX_DEPLOYMENT_TARGET=11.0" >> "$GITHUB_ENV"
116+
brew uninstall gcc@12 gcc@13 gnupg gnutls isl libmpc nettle gcc mpfr gmp --ignore-dependencies
117+
brew install m4 make automake autoconf libtool swig boost cgal --ignore-dependencies
118+
echo "PATH=/opt/homebrew/opt/make/libexec/gnubin:/opt/homebrew/opt/libtool/libexec/gnubin:$PATH" >> "$GITHUB_ENV"
119+
120+
- name: Install compiler tools on windows
121+
if: runner.os == 'windows'
122+
run: |
123+
choco install boost-msvc-14.1
124+
vcpkg.exe install cgal getopt
125+
126+
- name: Install extra deps on Linux
127+
if: runner.os == 'Linux'
128+
run: sudo apt-get update && sudo apt-get install -y libboost-dev libmpfr-dev swig libcgal-dev
105129

106130
- name: Clone gmp
107131
if: runner.os == 'macOS'
@@ -110,7 +134,7 @@ jobs:
110134
repository: gmp-mirror/gmp-6.3
111135
path: gmp-6.3
112136

113-
- name: Build gmp from source for MACOSX_DEPLOYMENT_TARGET
137+
- name: Build gmp from source for MACOSX_DEPLOYMENT_TARGET=11.0
114138
if: runner.os == 'macOS'
115139
working-directory: gmp-6.3
116140
run: |
@@ -124,11 +148,40 @@ jobs:
124148
make --jobs
125149
make install
126150
151+
- name: Get mpfr release
152+
if: runner.os == 'macOS'
153+
run: |
154+
curl -Lk https://www.mpfr.org/mpfr-current/mpfr-4.2.2.tar.gz -o mpfr-4.2.2.tar.gz
155+
tar -xzf mpfr-4.2.2.tar.gz
156+
157+
- name: Build mpfr from source for MACOSX_DEPLOYMENT_TARGET=11.0
158+
if: runner.os == 'macOS'
159+
working-directory: mpfr-4.2.2
160+
run: |
161+
autoreconf -i -f
162+
./configure --help
163+
./configure \
164+
--prefix=$(brew --prefix) \
165+
--with-gmp=$(brew --prefix)
166+
make --jobs
167+
make install
168+
127169
- uses: pypa/[email protected]
128170
env:
129171
CIBW_ARCHS: ${{ matrix.arch }}
130172
CIBW_BUILD: cp${{ matrix.python }}-*
131-
CIBW_BUILD_VERBOSITY: 2
173+
CIBW_BUILD_VERBOSITY: 1
174+
CIBW_CONFIG_SETTINGS_WINDOWS: >
175+
"cmake.define.GMP_DLL_TO_COPY"="C:\\\\vcpkg\\\\packages\\\\gmp_x64-windows\\\\bin\\\\gmp-10.dll"
176+
"cmake.define.unofficial-getopt-win32_DIR"="C:\\vcpkg\\packages\\getopt-win32_x64-windows\\share\\unofficial-getopt-win32"
177+
"cmake.define.FASTJET_ENABLE_DEBUG"="OFF"
178+
"cmake.define.SISCONE_ENABLE_DEBUG"="OFF"
179+
CIBW_ENVIRONMENT_WINDOWS: >
180+
CGAL_DIR='C:\vcpkg\packages\cgal_x64-windows\share\cgal'
181+
GMP_INC_DIR='C:\vcpkg\packages\gmp_x64-windows\include'
182+
GMP_LIB_DIR='C:\vcpkg\packages\gmp_x64-windows\lib'
183+
MPFR_INC_DIR='C:\vcpkg\packages\mpfr_x64-windows\include'
184+
MPFR_LIB_DIR='C:\vcpkg\packages\mpfr_x64-windows\lib'
132185
133186
- name: Upload wheels
134187
uses: actions/upload-artifact@v4

.github/workflows/wheels.yml

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ jobs:
1717
- uses: actions/checkout@v4
1818
with:
1919
submodules: recursive
20+
fetch-depth: 0
2021

2122
- name: Build SDist
2223
run: pipx run build --sdist
@@ -33,24 +34,28 @@ jobs:
3334
fail-fast: false
3435
matrix:
3536
python: [39, 310, 311, 312, 313]
36-
os: [ubuntu-latest, ubuntu-24.04-arm, macos-latest, macos-13]
37+
os: [ubuntu-latest, ubuntu-24.04-arm, macos-latest, macos-13, windows-latest]
3738
arch: [auto64]
3839

3940
steps:
4041
- uses: actions/checkout@v4
4142
with:
4243
submodules: recursive
44+
fetch-depth: 0
4345

4446
- name: Install compiler tools on macOS
4547
if: runner.os == 'macOS'
4648
run: |
47-
brew install make automake swig mpfr boost libtool
48-
echo "PATH=/opt/homebrew/opt/make/libexec/gnubin:/opt/homebrew/opt/libtool/libexec/gnubin:$PATH" >> "$GITHUB_ENV"
49-
echo "CPPFLAGS=-I/opt/homebrew/include -L/opt/homebrew/lib $CPPFLAGS" >> "$GITHUB_ENV"
50-
echo "CXXFLAGS=-I/opt/homebrew/include -L/opt/homebrew/lib $CXXFLAGS" >> "$GITHUB_ENV"
51-
echo "CFLAGS=-I/opt/homebrew/include -L/opt/homebrew/lib $CFLAGS" >> "$GITHUB_ENV"
52-
echo "LDFLAGS=-L/opt/homebrew/lib $LDFLAGS" >> "$GITHUB_ENV"
5349
echo "MACOSX_DEPLOYMENT_TARGET=11.0" >> "$GITHUB_ENV"
50+
brew uninstall gcc@12 gcc@13 gnupg gnutls isl libmpc nettle gcc mpfr gmp --ignore-dependencies
51+
brew install m4 make automake autoconf libtool swig boost cgal --ignore-dependencies
52+
echo "PATH=/opt/homebrew/opt/make/libexec/gnubin:/opt/homebrew/opt/libtool/libexec/gnubin:$PATH" >> "$GITHUB_ENV"
53+
54+
- name: Install compiler tools on windows
55+
if: runner.os == 'windows'
56+
run: |
57+
choco install boost-msvc-14.1
58+
vcpkg.exe install cgal getopt
5459
5560
- name: Clone gmp
5661
if: runner.os == 'macOS'
@@ -74,11 +79,40 @@ jobs:
7479
make --jobs
7580
make install
7681
82+
- name: Get mpfr release
83+
if: runner.os == 'macOS'
84+
run: |
85+
curl -Lk https://www.mpfr.org/mpfr-current/mpfr-4.2.2.tar.gz -o mpfr-4.2.2.tar.gz
86+
tar -xzf mpfr-4.2.2.tar.gz
87+
88+
- name: Build mpfr from source for MACOSX_DEPLOYMENT_TARGET=11.0
89+
if: runner.os == 'macOS'
90+
working-directory: mpfr-4.2.2
91+
run: |
92+
autoreconf -i -f
93+
./configure --help
94+
./configure \
95+
--prefix=$(brew --prefix) \
96+
--with-gmp=$(brew --prefix)
97+
make --jobs
98+
make install
99+
77100
- uses: pypa/[email protected]
78101
env:
79102
CIBW_ARCHS: ${{ matrix.arch }}
80103
CIBW_BUILD: cp${{ matrix.python }}-*
81-
CIBW_BUILD_VERBOSITY: 2
104+
CIBW_BUILD_VERBOSITY: 1
105+
CIBW_CONFIG_SETTINGS_WINDOWS: >
106+
"cmake.define.GMP_DLL_TO_COPY"="C:\\\\vcpkg\\\\packages\\\\gmp_x64-windows\\\\bin\\\\gmp-10.dll"
107+
"cmake.define.unofficial-getopt-win32_DIR"="C:\\vcpkg\\packages\\getopt-win32_x64-windows\\share\\unofficial-getopt-win32"
108+
"cmake.define.FASTJET_ENABLE_DEBUG"="OFF"
109+
"cmake.define.SISCONE_ENABLE_DEBUG"="OFF"
110+
CIBW_ENVIRONMENT_WINDOWS: >
111+
CGAL_DIR='C:\vcpkg\packages\cgal_x64-windows\share\cgal'
112+
GMP_INC_DIR='C:\vcpkg\packages\gmp_x64-windows\include'
113+
GMP_LIB_DIR='C:\vcpkg\packages\gmp_x64-windows\lib'
114+
MPFR_INC_DIR='C:\vcpkg\packages\mpfr_x64-windows\include'
115+
MPFR_LIB_DIR='C:\vcpkg\packages\mpfr_x64-windows\lib'
82116
83117
- name: Upload wheels
84118
uses: actions/upload-artifact@v4
@@ -98,7 +132,7 @@ jobs:
98132

99133
- name: Install extra deps on Linux
100134
if: runner.os == 'Linux'
101-
run: sudo apt-get update && sudo apt-get install -y libboost-dev swig autoconf libtool
135+
run: sudo apt-get update && sudo apt-get install -y libboost-dev swig autoconf libtool libcgal-dev
102136

103137
- name: test sdist
104138
run: python -m pip install dist/*.tar.gz

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
src/fastjet/version.py
12
_swig.py
23
_fastjet_core
34
*.so.[0-9]

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
url = https://gitlab.com/fastjet/fastjet.git
44
[submodule "fastjet-contrib"]
55
path = extern/fastjet-contrib
6-
url = https://github.com/cms-externals/fastjet-contrib.git
6+
url = https://github.com/lgray/fastjet-contrib.git

.pre-commit-config.yaml

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,11 @@ repos:
4141
hooks:
4242
- id: setup-cfg-fmt
4343

44-
- repo: https://github.com/pycqa/flake8
45-
rev: 7.2.0
44+
- repo: https://github.com/astral-sh/ruff-pre-commit
45+
rev: v0.11.4
4646
hooks:
47-
- id: flake8
48-
exclude: docs/conf.py
49-
additional_dependencies: [flake8-bugbear, flake8-print]
50-
51-
- repo: https://github.com/mgedmin/check-manifest
52-
rev: "0.50"
53-
hooks:
54-
- id: check-manifest
55-
stages: [manual]
47+
- id: ruff
48+
args: [--fix, --show-fixes]
5649

5750
- repo: https://github.com/pre-commit/mirrors-clang-format
5851
rev: "v20.1.0"

CMakeLists.txt

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
cmake_minimum_required(VERSION 3.15...4.0)
2+
3+
if(NOT SKBUILD_PROJECT_VERSION)
4+
set(SKBUILD_PROJECT_VERSION "0.0.0") # provided by scikit-build-core
5+
endif()
6+
string(REPLACE "." ";" VERSION_SPLIT ${SKBUILD_PROJECT_VERSION})
7+
list(GET VERSION_SPLIT 0 SPLIT_VERSION_MAJOR)
8+
list(GET VERSION_SPLIT 1 SPLIT_VERSION_MINOR)
9+
10+
project(fastjet VERSION ${SPLIT_VERSION_MAJOR}.${SPLIT_VERSION_MINOR} LANGUAGES CXX)
11+
12+
set(PKG_INSTALL "fastjet") ## python package name
13+
14+
include(FetchContent)
15+
16+
find_package(pybind11 REQUIRED)
17+
18+
find_package(CGAL)
19+
if (NOT CGAL_FOUND)
20+
FetchContent_Declare(CGAL
21+
GIT_REPOSITORY https://github.com/CGAL/cgal.git
22+
GIT_TAG v6.0.1
23+
)
24+
FetchContent_MakeAvailable(CGAL)
25+
endif()
26+
27+
#FetchContent_Declare(fastjet
28+
# SOURCE_DIR ${CMAKE_SOURCE_DIR}/extern/fastjet-core
29+
# 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"
30+
# )
31+
#FetchContent_MakeAvailable(fastjet)
32+
33+
add_subdirectory(${CMAKE_SOURCE_DIR}/extern/fastjet-core)
34+
add_subdirectory(${CMAKE_SOURCE_DIR}/extern/fastjet-contrib)
35+
36+
pybind11_add_module(_ext MODULE src/_ext.cpp)
37+
target_link_libraries(_ext PRIVATE fastjet::fastjet)
38+
target_link_libraries(_ext PRIVATE EnergyCorrelator LundPlane Nsubjettiness RecursiveTools)
39+
target_include_directories(_ext PRIVATE ${CMAKE_BINARY_DIR}/include)
40+
#set_target_properties(_ext PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE)
41+
#set_target_properties(_ext PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE)
42+
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
43+
set_target_properties(_ext PROPERTIES INSTALL_RPATH "@loader_path/lib")
44+
else()
45+
set_target_properties(_ext PROPERTIES INSTALL_RPATH "$ORIGIN/lib")
46+
endif()
47+
48+
if (MSVC AND FASTJET_ENABLE_CGAL)
49+
message("-- Copying ${GMP_DLL_TO_COPY} to project area!")
50+
install(FILES ${GMP_DLL_TO_COPY} DESTINATION ${CMAKE_INSTALL_PREFIX})
51+
endif()
52+
install(TARGETS _ext LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX})

MANIFEST.in

Lines changed: 0 additions & 6 deletions
This file was deleted.

extern/fastjet-contrib

Submodule fastjet-contrib updated 223 files

extern/fastjet-core

Submodule fastjet-core updated from 0648cfc to af81ba8

0 commit comments

Comments
 (0)