Free-threaded/noGIL Python 3.13t testing experiment #289
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
pull_request: | |
branches: | |
- master | |
push: | |
branches: | |
- master | |
workflow_dispatch: | |
schedule: | |
- cron: "0 4 * * *" | |
env: | |
PIP_DISABLE_PIP_VERSION_CHECK: "1" | |
FORCE_COLOR: "3" | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
jobs: | |
test: | |
name: Regular tests / ${{ matrix.platform }} / Python ${{ matrix.python-version }} | |
runs-on: ${{ matrix.platform }} | |
strategy: | |
fail-fast: false | |
matrix: | |
platform: [ubuntu-latest, macos-13, macos-latest, windows-latest] | |
python-version: | |
["3.9", "3.10", "3.11", "3.12", "3.13", "pypy-3.9", "pypy-3.10"] | |
# TODO: disable nightly NumPy tests for now, re-enable later | |
# nightly: [[True, "nightly-"], [False, ""]] | |
steps: | |
- uses: actions/[email protected] | |
- uses: actions/[email protected] | |
with: | |
python-version: ${{ matrix.python-version }} | |
allow-prereleases: true | |
- uses: yezz123/setup-uv@v4 | |
# On PyPy, we skip SciPy because we don't have wheels | |
# available, see noxfile.py for more details. | |
- name: Run tests | |
run: uvx nox -s tests | |
# In this job, we test against the NumPy nightly wheels hosted on | |
# https://anaconda.org/scientific-python-nightly-wheels/numpy | |
# on the latest Python version available across platforms, instead of | |
# testing all Python versions and implementations on all platforms. | |
# We do not test on PyPy. | |
# | |
# However, "nox -s nightly-tests" can be used locally anywhere, on | |
# any Python version and implementation on any platform and we leave | |
# it to the user to decide what Python version to test against, which | |
# might or might not have a corresponding NumPy nightly wheel present. | |
nightlies: | |
name: Nightly tests / ${{ matrix.platform }} / Python ${{ matrix.python-version }} | |
runs-on: ${{ matrix.platform }} | |
strategy: | |
fail-fast: false | |
matrix: | |
platform: [ubuntu-latest, macos-13, macos-latest, windows-latest] | |
python-version: ["3.x"] | |
steps: | |
- uses: actions/[email protected] | |
- uses: actions/[email protected] | |
with: | |
python-version: ${{ matrix.python-version }} | |
allow-prereleases: true | |
- uses: yezz123/setup-uv@v4 | |
- name: Run tests against nightly wheels for NumPy and SciPy | |
run: uvx nox -s nightly-tests | |
# In this job, we test with the free-threaded (no-GIL) Python 3.13t | |
# interpreter on all platforms. This is a special job and uses the | |
# "free-threading" session in noxfile.py. This job is available only | |
# for Python 3.13t at the time of writing and uses the nightly wheels | |
# for NumPy and SciPy, since free-threaded builds for either of them | |
# are not available on PyPI yet. | |
free-threaded-testing: | |
name: "Free-threading tests / ${{ matrix.platform }} / Python ${{ matrix.python-version }} / Plugin ${{ matrix.plugin }}" | |
runs-on: ${{ matrix.platform }} | |
# Temporarily disable this environment variable to see if this fixes the message as follows: | |
# "Fatal Python error: config_read_gil: Disabling the GIL is not supported by this build" | |
# env: | |
# PYTHON_GIL: "0" | |
strategy: | |
fail-fast: false | |
matrix: | |
platform: [ubuntu-latest, macos-13, macos-latest, windows-latest] | |
python-version: ["3.13t"] | |
plugin: ["none", "pytest-run-parallel", "pytest-freethreaded"] | |
steps: | |
- uses: actions/[email protected] | |
- uses: Quansight-Labs/setup-python@b9ab292c751a42bcd2bb465b7fa202ea2c3f5796 # v5.3.1 | |
with: | |
python-version: ${{ matrix.python-version }} | |
allow-prereleases: true | |
- uses: yezz123/setup-uv@ab6be5a42627f19dc36e57b548592a5e52cece4a # v4.1 | |
with: | |
uv-venv: "venv" | |
# 1. Test suite with free-threading enabled, but no free-threading-specific plugins | |
- name: Run free-threaded tests on ${{ matrix.platform}} | |
if: ${{ matrix.plugin == 'none' }} | |
run: uvx nox -s free-threading | |
# 2. Test suite with free-threading enabled, plus free-threading-specific plugins | |
- name: Install dependencies for free-threaded tests with ${{ matrix.plugin }} on ${{ matrix.platform}} | |
if: ${{ matrix.plugin != 'none' }} | |
env: | |
UV_INDEX_URL: "https://pypi.anaconda.org/scientific-python-nightly-wheels/simple" | |
UV_PRERELEASE: "allow" | |
UV_INDEX_STRATEGY: "first-index" | |
UV_NO_CACHE: "true" | |
run: | | |
python -VV | |
uv pip install --upgrade --only-binary :all: numpy scipy | |
- name: Run free-threaded tests with ${{ matrix.plugin }} on ${{ matrix.platform}} | |
if: ${{ matrix.plugin != 'none' }} | |
run: | | |
python -VV | |
uv pip install -e . | |
uv pip install pytest ${{ matrix.plugin }} | |
if [ "${{ matrix.plugin }}" == "pytest-run-parallel" ]; then | |
PYTHON_GIL="0" pytest --parallel-threads 5 | |
elif [ "${{ matrix.plugin }}" == "pytest-freethreaded" ]; then | |
PYTHON_GIL="0" pytest --threads 5 | |
fi |