Skip to content

Commit 6108cf3

Browse files
authored
Switching to scikit-build-core instead of meson for building (#215)
* swtiching to scikit-build-core instead of meson for building * supporting older versions of numpy * just build universal2 on mac * removing meson script * remove old windows updates * windows build fix * shell * install python differently on windwos * allow external in tests * simplfy on windows * run mac cross compile * adding cirrus mac arm64 build * simplifying cibuildwheel env variables * something strange * env vars and checkout on cirrus * consolidating * skip musl build and windows tests * concurrency and skip 3.8 wheel * fewer tests * wait for cirrus * typo * update minimum python version * artifacts names
1 parent 38e3988 commit 6108cf3

10 files changed

Lines changed: 186 additions & 197 deletions

File tree

.cirrus.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
cirrus_wheels_macos_arm64_task:
2+
macos_instance:
3+
image: ghcr.io/cirruslabs/macos-monterey-xcode:latest
4+
env:
5+
PATH: /opt/homebrew/opt/python@3.10/bin:$PATH
6+
CIBW_ENVIRONMENT: >
7+
MACOSX_DEPLOYMENT_TARGET=12.0
8+
_PYTHON_HOST_PLATFORM="macosx-12.0-arm64"
9+
SPS_HOME="${CIRRUS_WORKING_DIR}/src/fsps/libfsps"
10+
PKG_CONFIG_PATH: /opt/arm64-builds/lib/pkgconfig
11+
CMAKE_PREFIX_PATH: /opt/arm64-builds/
12+
REPAIR_PATH: /usr/local/gfortran/lib:/opt/arm64-builds/lib
13+
CIBW_REPAIR_WHEEL_COMMAND_MACOS: >
14+
DYLD_LIBRARY_PATH=/usr/local/gfortran/lib:/opt/arm64-builds/lib delocate-listdeps {wheel} &&
15+
DYLD_LIBRARY_PATH=/usr/local/gfortran/lib:/opt/arm64-builds/lib delocate-wheel --require-archs {delocate_archs} -w {dest_dir} {wheel}
16+
17+
clone_script: |
18+
if [ -z "$CIRRUS_PR" ]; then
19+
git clone --recursive --branch=$CIRRUS_BRANCH https://x-access-token:${CIRRUS_REPO_CLONE_TOKEN}@github.com/${CIRRUS_REPO_FULL_NAME}.git $CIRRUS_WORKING_DIR
20+
git reset --hard $CIRRUS_CHANGE_IN_REPO
21+
else
22+
git clone --recursive https://x-access-token:${CIRRUS_REPO_CLONE_TOKEN}@github.com/${CIRRUS_REPO_FULL_NAME}.git $CIRRUS_WORKING_DIR
23+
git fetch origin pull/$CIRRUS_PR/head:pull/$CIRRUS_PR
24+
git reset --hard $CIRRUS_CHANGE_IN_REPO
25+
fi
26+
27+
setup_python_script:
28+
- brew install python@3.10
29+
- ln -s python3 /opt/homebrew/opt/python@3.10/bin/python
30+
- which python
31+
32+
system_info_script:
33+
- uname -m
34+
- python -c "import platform;print(platform.python_version());print(platform.system());print(platform.machine())"
35+
36+
install_cibuildwheel_script:
37+
- python -m pip install cibuildwheel==2.14.1
38+
39+
cibuildwheel_script:
40+
- cibuildwheel
41+
42+
artifacts:
43+
path: "wheelhouse/*"

.github/workflows/release.yml

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,41 +6,30 @@ on:
66
branches: [main]
77
pull_request:
88

9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
913
jobs:
1014
build_wheels:
11-
name: Build wheel for ${{ matrix.python[0] }}-${{ matrix.buildplat[1] }} ${{ matrix.buildplat[2] }}
12-
runs-on: ${{ matrix.buildplat[0] }}
15+
name: Build wheel for ${{ matrix.os }}
16+
runs-on: ${{ matrix.os }}
1317
strategy:
1418
fail-fast: false
1519
matrix:
16-
buildplat:
17-
- [ubuntu-22.04, manylinux, x86_64]
18-
- [macos-12, macosx, x86_64]
19-
- [windows-2019, win, AMD64]
20-
python: [["cp38", "3.8"], ["cp39", "3.9"], ["cp310", "3.10"]]
20+
os:
21+
- "ubuntu-latest"
22+
- "macos-latest"
23+
# - "windows-latest"
2124
steps:
2225
- uses: actions/checkout@v3
2326
with:
2427
submodules: true
2528
fetch-depth: 0
26-
- uses: actions/setup-python@v4
27-
with:
28-
python-version: ${{ matrix.python[1]}}
29-
- name: Set up Windows
30-
run: |
31-
choco install rtools -y --no-progress --force --version=4.0.0.20220206
32-
echo "c:\rtools40\ucrt64\bin;" >> $env:GITHUB_PATH
33-
if: ${{ runner.os == 'Windows' }}
3429
- name: Set up macOS
3530
run: brew unlink gfortran && brew link --overwrite gfortran
3631
if: ${{ runner.os == 'macOS' }}
37-
- uses: pypa/cibuildwheel@v2.13.1
38-
env:
39-
CIBW_BUILD: ${{ matrix.python[0] }}-${{ matrix.buildplat[1] }}*
40-
CIBW_ARCHS: ${{ matrix.buildplat[2] }}
41-
CIBW_ENVIRONMENT_PASS_LINUX: RUNNER_OS
42-
CIBW_TEST_COMMAND_LINUX: "SPS_HOME={project}/src/fsps/libfsps python {project}/tests/simple.py"
43-
SPS_HOME: ${{ github.workspace }}/src/fsps/libfsps
32+
- uses: pypa/cibuildwheel@v2.14.0
4433
- uses: actions/upload-artifact@v3
4534
with:
4635
path: ./wheelhouse/*.whl
@@ -51,21 +40,33 @@ jobs:
5140
steps:
5241
- uses: actions/checkout@v3
5342
with:
54-
submodules: true
5543
fetch-depth: 0
5644
- uses: actions/setup-python@v4
57-
name: Install Python
5845
with:
59-
python-version: "3.9"
60-
- name: Build sdist
46+
python-version: "3.10"
47+
- name: Install dependencies
6148
run: |
6249
python -m pip install -U pip
63-
python -m pip install -U build
64-
python -m build --sdist .
50+
python -m pip install -U build twine
51+
- name: Build sdist
52+
run: python -m build --sdist .
53+
- name: Check the sdist
54+
run: python -m twine check dist/*.tar.gz
6555
- uses: actions/upload-artifact@v3
6656
with:
6757
path: dist/*.tar.gz
6858

59+
wait_for_cirrus:
60+
name: Wait for Cirrus CI to finish building macOS arm64 wheels
61+
runs-on: ubuntu-latest
62+
steps:
63+
- uses: getsentry/action-wait-for-cirrus@v1.0.0
64+
with:
65+
task: cirrus_wheels_macos_arm64
66+
commit: ${{ github.event.pull_request.head.sha || github.sha }}
67+
timeout-minutes: 15
68+
- run: ls dist
69+
6970
upload_pypi:
7071
needs: [build_wheels, build_sdist]
7172
runs-on: ubuntu-latest

.github/workflows/tests.yml

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,26 @@ on:
66
branches: [main]
77
pull_request:
88

9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
913
jobs:
1014
tests:
1115
name: "py${{ matrix.python-version }} / ${{ matrix.os }} / ${{ matrix.nox-session }}"
1216
runs-on: ${{ matrix.os }}
1317
strategy:
1418
fail-fast: false
1519
matrix:
16-
python-version: ["3.8", "3.9", "3.10"]
20+
python-version: ["3.9", "3.11"]
1721
os: [ubuntu-latest]
1822
nox-session: ["tests"]
1923
include:
2024
- os: macos-latest
21-
python-version: "3.10"
22-
nox-session: "tests"
23-
- os: windows-latest
24-
python-version: "3.10"
25+
python-version: "3.11"
2526
nox-session: "tests"
2627
- os: ubuntu-latest
27-
python-version: "3.10"
28+
python-version: "3.11"
2829
nox-session: "options"
2930
steps:
3031
- name: Clone the repo
@@ -36,6 +37,7 @@ jobs:
3637
uses: actions/setup-python@v4
3738
with:
3839
python-version: ${{ matrix.python-version }}
40+
# if: ${{ runner.os != 'Windows' }}
3941
- name: Set up Linux
4042
run: |
4143
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
@@ -45,11 +47,6 @@ jobs:
4547
- name: Set up macOS
4648
run: brew unlink gfortran && brew link --overwrite gfortran
4749
if: ${{ runner.os == 'macOS' }}
48-
- name: Set up Windows
49-
run: |
50-
choco install rtools -y --no-progress --force --version=4.0.0.20220206
51-
echo "c:\rtools40\ucrt64\bin;" >> $env:GITHUB_PATH
52-
if: ${{ runner.os == 'Windows' }}
5350
- name: Cache pip packages
5451
uses: actions/cache@v3
5552
with:
@@ -73,7 +70,7 @@ jobs:
7370
run: python -m nox --non-interactive --no-error-on-missing-interpreters -s ${{ matrix.nox-session }}-${{ matrix.python-version }}
7471
env:
7572
SPS_HOME: ${{ github.workspace }}/src/fsps/libfsps
76-
73+
7774
docs:
7875
if: github.event_name != 'pull_request'
7976
name: "docs"

CMakeLists.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
cmake_minimum_required(VERSION 3.17.2...3.26)
2+
project(${SKBUILD_PROJECT_NAME} LANGUAGES C Fortran)
3+
4+
find_package(
5+
Python
6+
COMPONENTS Interpreter Development.Module NumPy
7+
REQUIRED)
8+
9+
# Find the f2py headers
10+
execute_process(
11+
COMMAND "${PYTHON_EXECUTABLE}"
12+
"${CMAKE_CURRENT_SOURCE_DIR}/tools/f2py_include.py"
13+
OUTPUT_VARIABLE F2PY_INCLUDE_DIR
14+
OUTPUT_STRIP_TRAILING_WHITESPACE)
15+
16+
add_subdirectory(src/fsps)

meson.build

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

noxfile.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33

44
import nox
55

6-
ALL_PYTHON_VS = ["3.8", "3.9", "3.10"]
6+
ALL_PYTHON_VS = ["3.8", "3.9", "3.10", "3.11"]
77

88

9-
def _run_with_sps_home(session, *args, **kwargs):
9+
def _run_with_sps_home(session: nox.Session, *args, **kwargs):
1010
sps_home = os.environ.get(
1111
"SPS_HOME", Path(__file__).parent / "src" / "fsps" / "libfsps"
1212
)
1313
kwargs["env"] = dict(kwargs.get("env", {}), SPS_HOME=str(sps_home))
14-
return session.run(*args, **kwargs)
14+
return session.run(*args, **kwargs, external=True)
1515

1616

1717
@nox.session(python=ALL_PYTHON_VS)
@@ -26,7 +26,6 @@ def tests(session):
2626
"-n",
2727
"2",
2828
"--durations=0",
29-
"-v",
3029
"tests/tests.py",
3130
)
3231

pyproject.toml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ authors = [
55
{ name="Dan Foreman-Mackey", email="foreman.mackey@gmail.com" },
66
]
77
readme = "README.rst"
8-
requires-python = ">=3.7"
8+
requires-python = ">=3.9"
99
license = { text = "MIT License" }
1010
classifiers = [
1111
"Development Status :: 5 - Production/Stable",
@@ -27,12 +27,20 @@ test = ["pytest", "pytest-xdist"]
2727
"Bug Tracker" = "https://github.com/dfm/python-fsps/issues"
2828

2929
[build-system]
30-
build-backend = 'mesonpy'
31-
requires = ["meson-python>=0.8.1", "wheel", "oldest-supported-numpy", "setuptools_scm"]
30+
requires = ["scikit-build-core", "oldest-supported-numpy"]
31+
build-backend = "scikit_build_core.build"
32+
33+
[tool.scikit-build]
34+
ninja.minimum-version = "1.10"
35+
cmake.minimum-version = "3.17.2"
36+
sdist.exclude = ["src/fsps/libfsps"]
37+
sdist.include = ["src/fsps/libfsps/src/*.f90", "src/fsps/libfsps/LICENSE", "src/fsps/libfsps/README", "src/fsps/fsps_version.py"]
38+
metadata.version.provider = "scikit_build_core.metadata.setuptools_scm"
3239

3340
[tool.setuptools_scm]
3441
write_to = "src/fsps/fsps_version.py"
3542

3643
[tool.cibuildwheel]
37-
skip = "cp36-* *-win32 *-manylinux_i686 pp*"
44+
skip = "pp* *-win32 *-musllinux_* *-manylinux_i686"
3845
test-command = "python {project}/tests/simple.py"
46+
environment = {SPS_HOME = "$(pwd)/src/fsps/libfsps"}

src/fsps/CMakeLists.txt

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Generate the f2py wrappers
2+
set(F2PY_SOURCES
3+
"${CMAKE_CURRENT_BINARY_DIR}/_fspsmodule.c"
4+
"${CMAKE_CURRENT_BINARY_DIR}/_fsps-f2pywrappers2.f90"
5+
)
6+
add_custom_command(
7+
OUTPUT ${F2PY_SOURCES}
8+
DEPENDS fsps.f90
9+
VERBATIM
10+
COMMAND "${Python_EXECUTABLE}" -m numpy.f2py
11+
"${CMAKE_CURRENT_SOURCE_DIR}/fsps.f90" -m _fsps --lower
12+
--build-dir "${CMAKE_CURRENT_BINARY_DIR}")
13+
14+
# List out the explicit FSPS sources; we don't use a glob here since
15+
# the 'src' directory includes some executables that we don't want to
16+
# include here.
17+
set(
18+
FSPS_SOURCES
19+
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/sps_vars.f90"
20+
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/sps_utils.f90"
21+
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/add_agb_dust.f90"
22+
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/add_bs.f90"
23+
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/add_dust.f90"
24+
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/add_nebular.f90"
25+
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/add_remnants.f90"
26+
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/add_xrb.f90"
27+
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/agn_dust.f90"
28+
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/attn_curve.f90"
29+
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/compsp.f90"
30+
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/csp_gen.f90"
31+
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/funcint.f90"
32+
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/get_lumdist.f90"
33+
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/get_tuniv.f90"
34+
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/getindx.f90"
35+
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/getmags.f90"
36+
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/getspec.f90"
37+
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/igm_absorb.f90"
38+
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/imf.f90"
39+
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/imf_weight.f90"
40+
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/intsfwght.f90"
41+
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/linterp.f90"
42+
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/linterparr.f90"
43+
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/locate.f90"
44+
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/mod_gb.f90"
45+
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/mod_hb.f90"
46+
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/pz_convol.f90"
47+
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/sbf.f90"
48+
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/setup_tabular_sfh.f90"
49+
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/sfh_weight.f90"
50+
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/sfhinfo.f90"
51+
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/sfhlimit.f90"
52+
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/sfhstat.f90"
53+
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/smoothspec.f90"
54+
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/spec_bin.f90"
55+
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/sps_setup.f90"
56+
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/ssp_gen.f90"
57+
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/tsum.f90"
58+
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/vacairconv.f90"
59+
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/write_isochrone.f90"
60+
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/ztinterp.f90"
61+
)
62+
63+
# Define the Python library
64+
python_add_library(
65+
_fsps
66+
MODULE
67+
"${CMAKE_CURRENT_SOURCE_DIR}/fsps.f90"
68+
${FSPS_SOURCES}
69+
${F2PY_SOURCES}
70+
"${F2PY_INCLUDE_DIR}/fortranobject.c"
71+
WITH_SOABI)
72+
target_link_libraries(_fsps PUBLIC Python::NumPy)
73+
target_include_directories(_fsps PUBLIC "${F2PY_INCLUDE_DIR}")
74+
install(TARGETS _fsps DESTINATION ${SKBUILD_PROJECT_NAME})

0 commit comments

Comments
 (0)