Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 3.12 to action, but without cython support #2294

Merged
merged 6 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ jobs:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
env:
# Set up wheels matrix. This is CPython 3.6--3.11 for all OS targets.
CIBW_BUILD: "cp3{6,7,8,9,10,11}-*"
# Set up wheels matrix. This is CPython 3.6--3.12 for all OS targets.
CIBW_BUILD: "cp3{6,7,8,9,10,11,12}-*"
# Numpy and SciPy do not supply wheels for i686 or win32 for
# Python 3.10+, so we skip those:
CIBW_SKIP: "*-musllinux* cp3{8,9,10,11}-manylinux_i686 cp3{8,9,10,11}-win32"
CIBW_SKIP: "*-musllinux* cp3{8,9,10,11,12}-manylinux_i686 cp3{8,9,10,11,12}-win32"
OVERRIDE_VERSION: ${{ github.event.inputs.override_version }}

steps:
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,13 @@ jobs:
python-version: "3.10"
pytest-extra-options: "-W ignore::ImportWarning -k 'not (test_correlation or test_interpolate or test_mcsolve)'"

# Cython 0.29 (pyximport) and python 3.12 do not play well together.
# Qutip will ignore cython in this case.
- case-name: Python 3.12
os: ubuntu-latest
python-version: "3.12"
pytest-extra-options: "-W ignore:Runtime:UserWarning -W ignore:datetime:DeprecationWarning"

steps:
- uses: actions/checkout@v3

Expand Down
8 changes: 7 additions & 1 deletion qutip/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,24 +54,30 @@
pass
else:
from qutip.utilities import _version2int
import sys
_cy_require = "0.29.20"
_cy_unsupported = "3.0.0"
if _version2int(_Cython.__version__) < _version2int(_cy_require):
warnings.warn(
"Old version of Cython detected: needed {}, got {}."
.format(_cy_require, _Cython.__version__)
)
if _version2int(_Cython.__version__) >= _version2int(_cy_unsupported):
elif _version2int(_Cython.__version__) >= _version2int(_cy_unsupported):
warnings.warn(
"The new version of Cython, (>= 3.0.0) is not supported."
.format(_Cython.__version__)
)
elif _version2int(sys.version.split()[0]) >= _version2int("3.12.0"):
warnings.warn(
"Runtime cython compilation does not work on Python 3.12."
)
else:
# Setup pyximport
import qutip.cy.pyxbuilder as _pyxbuilder
_pyxbuilder.install()
del _pyxbuilder, _Cython, _version2int
qutip.settings.has_cython = True
del sys


# -----------------------------------------------------------------------------
Expand Down
5 changes: 5 additions & 0 deletions qutip/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pytest
import functools
import os
import sys
import tempfile
import numpy as np
from qutip.utilities import _version2int
Expand Down Expand Up @@ -32,6 +33,10 @@ def _skip_cython_tests_if_unavailable(item):
# importorskip does not have maxversion
if _version2int(_Cython.__version__) >= _version2int("3.0.0"):
pytest.skip("cython 3.0.0 not supported")
return
import qutip
Ericgig marked this conversation as resolved.
Show resolved Hide resolved
if _version2int(sys.version.split()[0]) >= _version2int("3.12.0"):
pytest.skip("Cython not available at runtime with python >=3.12.")


@pytest.hookimpl(trylast=True)
Expand Down