diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 64d78a588..74706922d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -49,7 +49,7 @@ jobs: zmq: bundled - os: macos-14 - python: "3.13-dev" + python: "3.13" zmq: bundled - os: macos-13 @@ -86,7 +86,11 @@ jobs: python: "3.12" - os: ubuntu-22.04 - python: "3.13-dev" + python: "3.13" + + - os: ubuntu-22.04 + python: "3.13" + free_threading: free_threading - os: windows-2022 python: "3.7" @@ -97,7 +101,7 @@ jobs: arch: x64 - os: windows-2022 - python: "3.13-dev" + python: "3.13" arch: x64 steps: @@ -105,6 +109,7 @@ jobs: - name: setup python uses: actions/setup-python@v5 + if: ${{ !matrix.free_threading }} with: python-version: ${{ matrix.python }} architecture: ${{ matrix.arch || 'x64' }} @@ -112,6 +117,32 @@ jobs: allow-prereleases: true cache: pip + - name: setup python (free threading) + if: ${{ matrix.free_threading }} + uses: mamba-org/setup-micromamba@v1 + with: + environment-name: nogil + condarc: | + channels: + - ad-testing/label/py313_nogil + - defaults + create-args: >- + python=${{ matrix.python-version }} + pip + + - name: activate python (free threading) + if: ${{ matrix.free_threading }} + # light activate, just add env to path + # run this in micromamba-shell + # so we don't have to for the rest + run: | + echo $PATH + echo "PATH=$PATH" >> "$GITHUB_ENV" + echo "PYTHON_GIL=0" >> "$GITHUB_ENV" + shell: micromamba-shell {0} + + + - name: setup coverage if: startsWith(matrix.python, 'pypy') || startsWith(matrix.python, '3.12') run: | @@ -127,6 +158,17 @@ jobs: run: | pip install --upgrade pip wheel pip install -r test-requirements.txt + + - name: install free-threading dependencies + if: ${{ matrix.free_threading }} + run: | + conda info + which -a python + which -a pip + # need build deps for no-build-isolation + # remove after Cython 3.1 + pip install scikit-build-core ninja packaging + pip install --upgrade --pre -i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple cython - name: remove tornado if: matrix.tornado == 'none' @@ -180,12 +222,18 @@ jobs: echo ZMQ_DRAFT_API=1 >> "$GITHUB_ENV" - name: build pyzmq + if: ${{ !matrix.free_threading }} run: | pip install -v -e . + - name: build pyzmq (free threading) + if: ${{ matrix.free_threading }} + run: | + pip install -v --no-build-isolation . + - name: import zmq run: | - python -c "import zmq" + python -I -c "import zmq" - name: run tests run: | diff --git a/examples/cython/setup.py b/examples/cython/setup.py index ef37fcbfd..b25d2d497 100644 --- a/examples/cython/setup.py +++ b/examples/cython/setup.py @@ -12,4 +12,4 @@ include_dirs=zmq.get_includes() + [numpy.get_include()], ) ] -setup(name="cython-zmq-example", ext_modules=cythonize(extensions)) +setup(name="cython-zmq-example", ext_modules=cythonize(extensions)) # type: ignore diff --git a/zmq/backend/cython/_zmq.py b/zmq/backend/cython/_zmq.py index fc16087aa..5c7b8e453 100644 --- a/zmq/backend/cython/_zmq.py +++ b/zmq/backend/cython/_zmq.py @@ -1,3 +1,4 @@ +# cython: freethreading_compatible = True """Cython backend for pyzmq""" # Copyright (C) PyZMQ Developers