Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .cirrus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
cirrus_wheels_macos_arm64_task:
macos_instance:
image: ghcr.io/cirruslabs/macos-monterey-xcode:latest
env:
PATH: /opt/homebrew/opt/python@3.10/bin:$PATH
CIBW_ENVIRONMENT: >
MACOSX_DEPLOYMENT_TARGET=12.0
_PYTHON_HOST_PLATFORM="macosx-12.0-arm64"
SPS_HOME="${CIRRUS_WORKING_DIR}/src/fsps/libfsps"
PKG_CONFIG_PATH: /opt/arm64-builds/lib/pkgconfig
CMAKE_PREFIX_PATH: /opt/arm64-builds/
REPAIR_PATH: /usr/local/gfortran/lib:/opt/arm64-builds/lib
CIBW_REPAIR_WHEEL_COMMAND_MACOS: >
DYLD_LIBRARY_PATH=/usr/local/gfortran/lib:/opt/arm64-builds/lib delocate-listdeps {wheel} &&
DYLD_LIBRARY_PATH=/usr/local/gfortran/lib:/opt/arm64-builds/lib delocate-wheel --require-archs {delocate_archs} -w {dest_dir} {wheel}

clone_script: |
if [ -z "$CIRRUS_PR" ]; then
git clone --recursive --branch=$CIRRUS_BRANCH https://x-access-token:${CIRRUS_REPO_CLONE_TOKEN}@github.com/${CIRRUS_REPO_FULL_NAME}.git $CIRRUS_WORKING_DIR
git reset --hard $CIRRUS_CHANGE_IN_REPO
else
git clone --recursive https://x-access-token:${CIRRUS_REPO_CLONE_TOKEN}@github.com/${CIRRUS_REPO_FULL_NAME}.git $CIRRUS_WORKING_DIR
git fetch origin pull/$CIRRUS_PR/head:pull/$CIRRUS_PR
git reset --hard $CIRRUS_CHANGE_IN_REPO
fi

setup_python_script:
- brew install python@3.10
- ln -s python3 /opt/homebrew/opt/python@3.10/bin/python
- which python

system_info_script:
- uname -m
- python -c "import platform;print(platform.python_version());print(platform.system());print(platform.machine())"

install_cibuildwheel_script:
- python -m pip install cibuildwheel==2.14.1

cibuildwheel_script:
- cibuildwheel

artifacts:
path: "wheelhouse/*"
57 changes: 29 additions & 28 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,30 @@ on:
branches: [main]
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build_wheels:
name: Build wheel for ${{ matrix.python[0] }}-${{ matrix.buildplat[1] }} ${{ matrix.buildplat[2] }}
runs-on: ${{ matrix.buildplat[0] }}
name: Build wheel for ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
buildplat:
- [ubuntu-22.04, manylinux, x86_64]
- [macos-12, macosx, x86_64]
- [windows-2019, win, AMD64]
python: [["cp38", "3.8"], ["cp39", "3.9"], ["cp310", "3.10"]]
os:
- "ubuntu-latest"
- "macos-latest"
# - "windows-latest"
steps:
- uses: actions/checkout@v3
with:
submodules: true
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python[1]}}
- name: Set up Windows
run: |
choco install rtools -y --no-progress --force --version=4.0.0.20220206
echo "c:\rtools40\ucrt64\bin;" >> $env:GITHUB_PATH
if: ${{ runner.os == 'Windows' }}
- name: Set up macOS
run: brew unlink gfortran && brew link --overwrite gfortran
if: ${{ runner.os == 'macOS' }}
- uses: pypa/cibuildwheel@v2.13.1
env:
CIBW_BUILD: ${{ matrix.python[0] }}-${{ matrix.buildplat[1] }}*
CIBW_ARCHS: ${{ matrix.buildplat[2] }}
CIBW_ENVIRONMENT_PASS_LINUX: RUNNER_OS
CIBW_TEST_COMMAND_LINUX: "SPS_HOME={project}/src/fsps/libfsps python {project}/tests/simple.py"
SPS_HOME: ${{ github.workspace }}/src/fsps/libfsps
- uses: pypa/cibuildwheel@v2.14.0
- uses: actions/upload-artifact@v3
with:
path: ./wheelhouse/*.whl
Expand All @@ -51,21 +40,33 @@ jobs:
steps:
- uses: actions/checkout@v3
with:
submodules: true
fetch-depth: 0
- uses: actions/setup-python@v4
name: Install Python
with:
python-version: "3.9"
- name: Build sdist
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install -U pip
python -m pip install -U build
python -m build --sdist .
python -m pip install -U build twine
- name: Build sdist
run: python -m build --sdist .
- name: Check the sdist
run: python -m twine check dist/*.tar.gz
- uses: actions/upload-artifact@v3
with:
path: dist/*.tar.gz

wait_for_cirrus:
name: Wait for Cirrus CI to finish building macOS arm64 wheels
runs-on: ubuntu-latest
steps:
- uses: getsentry/action-wait-for-cirrus@v1.0.0
with:
task: cirrus_wheels_macos_arm64
commit: ${{ github.event.pull_request.head.sha || github.sha }}
timeout-minutes: 15
- run: ls dist

upload_pypi:
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
Expand Down
21 changes: 9 additions & 12 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,26 @@ on:
branches: [main]
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
tests:
name: "py${{ matrix.python-version }} / ${{ matrix.os }} / ${{ matrix.nox-session }}"
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10"]
python-version: ["3.9", "3.11"]
os: [ubuntu-latest]
nox-session: ["tests"]
include:
- os: macos-latest
python-version: "3.10"
nox-session: "tests"
- os: windows-latest
python-version: "3.10"
python-version: "3.11"
nox-session: "tests"
- os: ubuntu-latest
python-version: "3.10"
python-version: "3.11"
nox-session: "options"
steps:
- name: Clone the repo
Expand All @@ -36,6 +37,7 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
# if: ${{ runner.os != 'Windows' }}
- name: Set up Linux
run: |
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
Expand All @@ -45,11 +47,6 @@ jobs:
- name: Set up macOS
run: brew unlink gfortran && brew link --overwrite gfortran
if: ${{ runner.os == 'macOS' }}
- name: Set up Windows
run: |
choco install rtools -y --no-progress --force --version=4.0.0.20220206
echo "c:\rtools40\ucrt64\bin;" >> $env:GITHUB_PATH
if: ${{ runner.os == 'Windows' }}
- name: Cache pip packages
uses: actions/cache@v3
with:
Expand All @@ -73,7 +70,7 @@ jobs:
run: python -m nox --non-interactive --no-error-on-missing-interpreters -s ${{ matrix.nox-session }}-${{ matrix.python-version }}
env:
SPS_HOME: ${{ github.workspace }}/src/fsps/libfsps

docs:
if: github.event_name != 'pull_request'
name: "docs"
Expand Down
16 changes: 16 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
cmake_minimum_required(VERSION 3.17.2...3.26)
project(${SKBUILD_PROJECT_NAME} LANGUAGES C Fortran)

find_package(
Python
COMPONENTS Interpreter Development.Module NumPy
REQUIRED)

# Find the f2py headers
execute_process(
COMMAND "${PYTHON_EXECUTABLE}"
"${CMAKE_CURRENT_SOURCE_DIR}/tools/f2py_include.py"
OUTPUT_VARIABLE F2PY_INCLUDE_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE)

add_subdirectory(src/fsps)
40 changes: 0 additions & 40 deletions meson.build

This file was deleted.

7 changes: 3 additions & 4 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@

import nox

ALL_PYTHON_VS = ["3.8", "3.9", "3.10"]
ALL_PYTHON_VS = ["3.8", "3.9", "3.10", "3.11"]


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


@nox.session(python=ALL_PYTHON_VS)
Expand All @@ -26,7 +26,6 @@ def tests(session):
"-n",
"2",
"--durations=0",
"-v",
"tests/tests.py",
)

Expand Down
16 changes: 12 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ authors = [
{ name="Dan Foreman-Mackey", email="foreman.mackey@gmail.com" },
]
readme = "README.rst"
requires-python = ">=3.7"
requires-python = ">=3.9"
license = { text = "MIT License" }
classifiers = [
"Development Status :: 5 - Production/Stable",
Expand All @@ -27,12 +27,20 @@ test = ["pytest", "pytest-xdist"]
"Bug Tracker" = "https://github.com/dfm/python-fsps/issues"

[build-system]
build-backend = 'mesonpy'
requires = ["meson-python>=0.8.1", "wheel", "oldest-supported-numpy", "setuptools_scm"]
requires = ["scikit-build-core", "oldest-supported-numpy"]
build-backend = "scikit_build_core.build"

[tool.scikit-build]
ninja.minimum-version = "1.10"
cmake.minimum-version = "3.17.2"
sdist.exclude = ["src/fsps/libfsps"]
sdist.include = ["src/fsps/libfsps/src/*.f90", "src/fsps/libfsps/LICENSE", "src/fsps/libfsps/README", "src/fsps/fsps_version.py"]
metadata.version.provider = "scikit_build_core.metadata.setuptools_scm"

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

[tool.cibuildwheel]
skip = "cp36-* *-win32 *-manylinux_i686 pp*"
skip = "pp* *-win32 *-musllinux_* *-manylinux_i686"
test-command = "python {project}/tests/simple.py"
environment = {SPS_HOME = "$(pwd)/src/fsps/libfsps"}
74 changes: 74 additions & 0 deletions src/fsps/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Generate the f2py wrappers
set(F2PY_SOURCES
"${CMAKE_CURRENT_BINARY_DIR}/_fspsmodule.c"
"${CMAKE_CURRENT_BINARY_DIR}/_fsps-f2pywrappers2.f90"
)
add_custom_command(
OUTPUT ${F2PY_SOURCES}
DEPENDS fsps.f90
VERBATIM
COMMAND "${Python_EXECUTABLE}" -m numpy.f2py
"${CMAKE_CURRENT_SOURCE_DIR}/fsps.f90" -m _fsps --lower
--build-dir "${CMAKE_CURRENT_BINARY_DIR}")

# List out the explicit FSPS sources; we don't use a glob here since
# the 'src' directory includes some executables that we don't want to
# include here.
set(
FSPS_SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/sps_vars.f90"
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/sps_utils.f90"
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/add_agb_dust.f90"
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/add_bs.f90"
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/add_dust.f90"
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/add_nebular.f90"
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/add_remnants.f90"
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/add_xrb.f90"
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/agn_dust.f90"
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/attn_curve.f90"
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/compsp.f90"
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/csp_gen.f90"
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/funcint.f90"
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/get_lumdist.f90"
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/get_tuniv.f90"
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/getindx.f90"
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/getmags.f90"
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/getspec.f90"
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/igm_absorb.f90"
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/imf.f90"
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/imf_weight.f90"
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/intsfwght.f90"
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/linterp.f90"
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/linterparr.f90"
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/locate.f90"
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/mod_gb.f90"
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/mod_hb.f90"
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/pz_convol.f90"
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/sbf.f90"
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/setup_tabular_sfh.f90"
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/sfh_weight.f90"
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/sfhinfo.f90"
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/sfhlimit.f90"
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/sfhstat.f90"
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/smoothspec.f90"
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/spec_bin.f90"
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/sps_setup.f90"
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/ssp_gen.f90"
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/tsum.f90"
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/vacairconv.f90"
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/write_isochrone.f90"
"${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/ztinterp.f90"
)

# Define the Python library
python_add_library(
_fsps
MODULE
"${CMAKE_CURRENT_SOURCE_DIR}/fsps.f90"
${FSPS_SOURCES}
${F2PY_SOURCES}
"${F2PY_INCLUDE_DIR}/fortranobject.c"
WITH_SOABI)
target_link_libraries(_fsps PUBLIC Python::NumPy)
target_include_directories(_fsps PUBLIC "${F2PY_INCLUDE_DIR}")
install(TARGETS _fsps DESTINATION ${SKBUILD_PROJECT_NAME})
Loading