From 0048818297fa0eca269dac7a27cb3d92ca64fe52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Robert?= Date: Wed, 9 Aug 2023 09:54:21 +0200 Subject: [PATCH] TST: start testing nightlies on CPython 3.12 --- .github/workflows/bleeding-edge.yaml | 19 +++++++++++++------ conftest.py | 21 ++++++++++++++++++--- pyproject.toml | 4 ++++ 3 files changed, 35 insertions(+), 9 deletions(-) diff --git a/.github/workflows/bleeding-edge.yaml b/.github/workflows/bleeding-edge.yaml index d3bc23e6a13..1d97abae681 100644 --- a/.github/workflows/bleeding-edge.yaml +++ b/.github/workflows/bleeding-edge.yaml @@ -37,23 +37,30 @@ jobs: - name: Set up Python (newest testable version) uses: actions/setup-python@v4 with: - # the '-dev' suffix allows to use alphas and betas if no final release is available yet - # this version should be upgraded as often as possible, typically once a year when numpy - # and Cython are known to be compatible - python-version: '3.11-dev' + # the '-dev' suffix allows to use pre-releases if no final release is available yet + # this version should be upgraded as often as possible, typically once a year when + # Cython, numpy and matplotlib are known to be compatible + python-version: '3.12-dev' - name: Install dependencies # PyYAML needs to be installed in isolation for now, because of a known # incompatibility with Cython 3 # see https://github.com/yaml/pyyaml/issues/601 # and https://github.com/cython/cython/issues/4568 + # Cython 3.0.2 has a defect on Python 3.12, so we install the -fixed- dev version + # from source for now. + # see https://github.com/cython/cython/issues/5724 + # Cython can be installed from PyPI binaries again when the patch is included + # in a release (likely in version 3.0.3) run: | python -m pip install --upgrade pip python -m pip install --upgrade setuptools wheel - python -m pip install --pre --upgrade --extra-index https://pypi.anaconda.org/scientific-python-nightly-wheels/simple numpy matplotlib - python -m pip install --pre cython ewah-bool-utils + python -m pip install --pre --only-binary ":all:" numpy matplotlib \ + --extra-index https://pypi.anaconda.org/scientific-python-nightly-wheels/simple + python -m pip install --pre ewah-bool-utils python -m pip install git+https://github.com/yt-project/unyt.git python -m pip install --pre pytest PyYAML + python -m pip install git+https://github.com/cython/cython.git - name: Build # --no-build-isolation is used to guarantee that build time dependencies diff --git a/conftest.py b/conftest.py index 781a1cf3bcd..9fa238c6885 100644 --- a/conftest.py +++ b/conftest.py @@ -1,5 +1,6 @@ import os import shutil +import sys import tempfile from importlib.metadata import version from importlib.util import find_spec @@ -22,7 +23,13 @@ MPL_VERSION = Version(version("matplotlib")) NUMPY_VERSION = Version(version("numpy")) PILLOW_VERSION = Version(version("pillow")) -SETUPTOOLS_VERSION = Version(version("setuptools")) + +# setuptools does not ship with the standard lib starting in Python 3.12, so we need to +# be resilient if it's not available at runtime +if find_spec("setuptools") is not None: + SETUPTOOLS_VERSION = Version(version("setuptools")) +else: + SETUPTOOLS_VERSION = None def pytest_addoption(parser): @@ -105,7 +112,7 @@ def pytest_configure(config): ): config.addinivalue_line("filterwarnings", value) - if SETUPTOOLS_VERSION >= Version("67.3.0"): + if SETUPTOOLS_VERSION is not None and SETUPTOOLS_VERSION >= Version("67.3.0"): # may be triggered by multiple dependencies # see https://github.com/glue-viz/glue/issues/2364 # see https://github.com/matplotlib/matplotlib/issues/25244 @@ -116,7 +123,7 @@ def pytest_configure(config): r"is preferred to `pkg_resources\.declare_namespace`\.:DeprecationWarning", ) - if SETUPTOOLS_VERSION >= Version("67.5.0"): + if SETUPTOOLS_VERSION is not None and SETUPTOOLS_VERSION >= Version("67.5.0"): # may be triggered by multiple dependencies # see https://github.com/glue-viz/glue/issues/2364 # see https://github.com/matplotlib/matplotlib/issues/25244 @@ -162,6 +169,14 @@ def pytest_configure(config): ), ) + if sys.version_info >= (3, 12): + # already patched (but not released) upstream: + # https://github.com/dateutil/dateutil/pull/1285 + config.addinivalue_line( + "filterwarnings", + r"ignore:datetime\.datetime\.utcfromtimestamp\(\) is deprecated:DeprecationWarning", + ) + def pytest_collection_modifyitems(config, items): r""" diff --git a/pyproject.toml b/pyproject.toml index dad0d494009..823254da5e9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,10 @@ requires = [ "setuptools>=61.2", + # for the upper pin in Cython # see https://github.com/yt-project/yt/issues/4044 + # TODO: bump minimal Cython version to 3.0.3 when released + # see https://github.com/yt-project/yt/issues/4675 "Cython>=3.0, <3.1", "numpy>=1.25, <2.0", "ewah-bool-utils>=1.0.2", @@ -32,6 +35,7 @@ classifiers = [ "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Topic :: Scientific/Engineering :: Astronomy", "Topic :: Scientific/Engineering :: Physics", "Topic :: Scientific/Engineering :: Visualization",