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
16 changes: 13 additions & 3 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- uses: pre-commit/action@v3.0.0
- uses: actions/checkout@v7
- uses: actions/setup-python@v7
with:
python-version: "3.x"
# Run pre-commit directly (with its cache) rather than via
# pre-commit/action, whose latest release still pins the deprecated
# Node 20 actions/cache internally.
- uses: actions/cache@v6
with:
path: ~/.cache/pre-commit
key: pre-commit-3|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
- run: python -m pip install pre-commit
- run: pre-commit run --show-diff-on-failure --color=always --all-files
106 changes: 35 additions & 71 deletions .github/workflows/pypi-build-test-publish.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: PyPI 🐍 Wheel 🎡
name: PyPI 🐍 Publish 📦

on:
release:
Expand All @@ -7,93 +7,57 @@ on:

jobs:

build_wheels:
name: Build wheel for cp${{ matrix.python }}-${{ matrix.platform_id }}
runs-on: ${{ matrix.os }}

strategy:
fail-fast: true
matrix:
os: [ubuntu-latest, macos-latest]
python: [39, 310, 311, 312, 313, 314, 315]
arch: [x86, arm]
include:
- os: ubuntu-latest
arch: x86
platform_id: manylinux_x86_64
cibw_arch: auto
- os: macos-latest
arch: x86
platform_id: macosx_x86_64
cibw_arch: x86_64
- os: macos-latest
arch: arm
platform_id: macosx_arm64
cibw_arch: arm64
exclude:
- os: ubuntu-latest
arch: arm
build:
name: Build pure-Python distribution
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Get history and tags for SCM versioning
- uses: actions/checkout@v7
with:
# Full history + tags: setuptools_scm derives the release version
# from the tag, so a shallow clone produces a wrong version.
fetch-depth: 0

- uses: actions/setup-python@v7
with:
python-version: "3.12"

- name: Build sdist and wheel
run: |
git fetch --prune --unshallow
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
python -m pip install --upgrade pip build twine
python -m build

- name: Check distribution metadata
run: twine check dist/*

- name: Build wheels
uses: pypa/cibuildwheel@v3.3.0
env:
CIBW_BUILD: cp${{ matrix.python }}-${{ matrix.platform_id }}
CIBW_ARCHS_LINUX: ${{ matrix.cibw_arch }}
CIBW_ARCHS_MACOS: ${{ matrix.cibw_arch }}
CIBW_TEST_SKIP: "*_aarch64, *macosx*, *_arm64, *_universal2:arm64"
- name: Verify the wheel is pure Python
run: |
ls -l dist/
test "$(ls dist/*.whl | wc -l)" -eq 1
ls dist/ | grep -q -- '-py3-none-any\.whl$'

- name: Upload Build Artifact
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v7
with:
name: nuspacesim-gh-pypi-artifact-${{ matrix.os }}-${{ matrix.cibw_arch }}-cp${{ matrix.python }}-${{ github.run_id }}
path: wheelhouse/*.whl
retention-days: 1
name: nuspacesim-dist-${{ github.run_id }}
path: dist/*
retention-days: 5

publish:
name: Publish wheels to PyPI
name: Publish distribution to PyPI
runs-on: ubuntu-latest
needs: build_wheels

strategy:
fail-fast: true
matrix:
os: [ubuntu-latest, macos-latest]
python: [39, 310, 311, 312, 313, 314, 315]
arch: [x86, arm]
include:
- os: ubuntu-latest
arch: x86
platform_id: manylinux_x86_64
cibw_arch: auto
- os: macos-latest
arch: x86
platform_id: macosx_x86_64
cibw_arch: x86_64
- os: macos-latest
arch: arm
platform_id: macosx_arm64
cibw_arch: arm64
exclude:
- os: ubuntu-latest
arch: arm
needs: build

steps:
- name: Download Build Artifacts
uses: actions/download-artifact@v4
uses: actions/download-artifact@v8
with:
name: nuspacesim-gh-pypi-artifact-${{ matrix.os }}-${{ matrix.cibw_arch }}-cp${{ matrix.python }}-${{ github.run_id }}
path: wheelhouse/
name: nuspacesim-dist-${{ github.run_id }}
path: dist/

- name: Publish a Python distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_SECRET }}
packages_dir: wheelhouse/
packages_dir: dist/
100 changes: 57 additions & 43 deletions .github/workflows/pypi-build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,70 +8,84 @@ on:
paths:
- 'src/**'
- 'test/**'
- setup.py
- setup.cfg
- pyproject.toml
- '.github/workflows/**'
pull_request:
branches: [ main ]
workflow_dispatch:

jobs:

build_wheels:
name: Wheel cp${{ matrix.python }}-${{ matrix.os }}-${{ matrix.arch }}
test:
name: Test py${{ matrix.python }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
# Matches the support declared in setup.cfg (python_requires + the
# Programming Language classifiers). Add a version here and there
# together.
os: [ubuntu-latest, macos-latest]
python: [39, 310, 311, 312, 313, 314, 315]
arch: [x86, arm]
include:
- os: ubuntu-latest
arch: x86
platform_id: manylinux_x86_64
cibw_arch: auto
# - os: ubuntu-latest
# arch: arm
# platform_id: manylinux_aarch64
# cibw_arch: aarch64
- os: macos-latest
arch: x86
platform_id: macosx_x86_64
cibw_arch: x86_64
- os: macos-latest
arch: arm
platform_id: macosx_arm64
cibw_arch: arm64
exclude:
- os: ubuntu-latest
arch: arm
python: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]

steps:
- uses: actions/checkout@v3
- name: Get history and tags for SCM versioning
- uses: actions/checkout@v7
with:
# Full history + tags: setuptools_scm derives the version from them.
fetch-depth: 0

- uses: actions/setup-python@v7
with:
python-version: ${{ matrix.python }}

- name: Install package and test dependencies
run: |
git fetch --prune --unshallow
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
python -m pip install --upgrade pip
python -m pip install . pytest

- name: Run test suite
# Run from a scratch directory so the installed package is exercised
# rather than the source tree next to it.
run: |
mkdir -p ${{ runner.temp }}/run && cd ${{ runner.temp }}/run
pytest -q ${{ github.workspace }}/test

build:
name: Build pure-Python distribution
runs-on: ubuntu-latest
needs: test

- name: Set up QEMU for ARM on Linux
if: matrix.arch == 'arm' && matrix.os == 'ubuntu-latest'
uses: docker/setup-qemu-action@v2
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0

- uses: actions/setup-python@v7
with:
platforms: all
python-version: "3.12"

- name: Build wheels
uses: pypa/cibuildwheel@v3.3.0
env:
CIBW_BUILD: cp${{ matrix.python }}-${{ matrix.platform_id }}
CIBW_ARCHS_LINUX: ${{ matrix.cibw_arch }}
CIBW_ARCHS_MACOS: ${{ matrix.cibw_arch }}
CIBW_TEST_SKIP: "*_aarch64, *macosx*, *_arm64, *_universal2:arm64"
- name: Build sdist and wheel
run: |
python -m pip install --upgrade pip build twine
python -m build

- name: Check distribution metadata
run: twine check dist/*

- name: Verify the wheel is pure Python
# nuspacesim has no compiled extensions, so the build must produce a
# single universal py3-none-any wheel. A platform-tagged wheel here means
# a binary dependency crept back in and the packaging needs revisiting.
run: |
ls -l dist/
test "$(ls dist/*.whl | wc -l)" -eq 1
ls dist/ | grep -q -- '-py3-none-any\.whl$'

- name: Upload Build Artifact
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v7
with:
name: nuspacesim-gh-pypi-artifact-${{ matrix.os }}-${{ matrix.cibw_arch }}-cp${{ matrix.python }}-${{ github.run_id }}
path: wheelhouse/*.whl
name: nuspacesim-dist-${{ github.run_id }}
path: dist/*
retention-days: 1
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ repos:
rev: v2.7.0
hooks:
- id: setup-cfg-fmt
args: ["--include-version-classifiers", "--max-py-version=3.13"]
args: ["--include-version-classifiers", "--max-py-version=3.14"]
3 changes: 0 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ version_scheme = 'post-release'
local_scheme = 'no-local-version'
parentdir_prefix_version = 'nuspacesim-'

[tool.cibuildwheel]
test-requires = "pytest"
test-command = "pytest {project}/test"
[tool.black]
line-length = 88
skip-string-normalization = false
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ classifiers =
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
Programming Language :: Python :: 3.13
Programming Language :: Python :: 3.14
keywords =
NASA
neutrinos
Expand All @@ -39,7 +40,6 @@ install_requires =
tomli-w
tomli;python_version<"3.11"
python_requires = >=3.9
ext_package = nuspacesim
package_dir =
= src
zip_safe = False
Expand Down