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 1 commit
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
6 changes: 6 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@ jobs:
python-version: "3.10"
pytest-extra-options: "-W ignore::ImportWarning -k 'not (test_correlation or test_interpolate or test_mcsolve)'"

# Builds without Cython at runtime. This is a core feature;
# everything should be able to run this.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should update the comment to mention why we have an extra non-Cython run for 3.12.

- case-name: Python 3.12
os: ubuntu-latest
python-version: "3.12"

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(_Cython.__version__.split()[0]) >= _version2int("3.12.0"):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand this elif condition. We appear to be comparing a Python version to a Cython version?

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
4 changes: 4 additions & 0 deletions qutip/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,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 not qutip.settings.has_cython:
pytest.skip("Cython not available at runtime.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit uncomfortable relying on QuTiP's own detection magic to skip tests. If it ends up being wrong in some cases Cython tests will be silently skipped in CI.

Perhaps let's just check against the Python version and skip if it's Python 3.12?



@pytest.hookimpl(trylast=True)
Expand Down