From aff199e1a656263bf972ee0807c7447f4fe0c617 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Robert?= Date: Sun, 4 Aug 2024 12:33:06 +0200 Subject: [PATCH 1/2] DEP: drop support for CPython 3.10 and numpy<1.25 --- .github/workflows/ci.yml | 17 ++++++++-------- pyproject.toml | 10 ++++----- setup.py | 2 +- src/gpgi/_backports.py | 44 ---------------------------------------- src/gpgi/_typing.py | 8 +------- src/gpgi/types.py | 21 ++----------------- 6 files changed, 16 insertions(+), 86 deletions(-) delete mode 100644 src/gpgi/_backports.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d7e277a..4ee7bcf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,7 +28,7 @@ jobs: python-version: 3.x - uses: yezz123/setup-uv@v4 with: - uv-version: 0.2.18 + uv-version: 0.2.33 uv-venv: .venv - run: uv pip install check-manifest build - name: Check build @@ -43,7 +43,6 @@ jobs: os: - ubuntu-latest python-version: - - '3.10' - '3.11' - '3.12' marker: [''] # needed to avoid collision with PY_LIB job @@ -57,7 +56,7 @@ jobs: # test with minimal requirements - marker: minimal os: ubuntu-20.04 - python-version: '3.10' + python-version: '3.11' deps: minimal # test GPGI_PY_LIB @@ -76,7 +75,7 @@ jobs: - uses: yezz123/setup-uv@v4 with: - uv-version: 0.2.18 + uv-version: 0.2.33 uv-venv: .venv - if: matrix.deps == 'minimal' @@ -122,7 +121,7 @@ jobs: - uses: yezz123/setup-uv@v4 with: - uv-version: 0.2.18 + uv-version: 0.2.33 uv-venv: .venv - name: Build library @@ -176,7 +175,7 @@ jobs: - uses: yezz123/setup-uv@v4 with: - uv-version: 0.2.18 + uv-version: 0.2.33 uv-venv: .venv - run: uv pip install 'coverage[toml]' @@ -204,7 +203,7 @@ jobs: strategy: matrix: python-version: - - '3.10' + - '3.11' - '3.12' runs-on: ubuntu-latest name: type check @@ -220,7 +219,7 @@ jobs: - uses: yezz123/setup-uv@v4 with: - uv-version: 0.2.18 + uv-version: 0.2.33 uv-venv: .venv - name: Build @@ -251,7 +250,7 @@ jobs: - uses: yezz123/setup-uv@v4 with: - uv-version: 0.2.18 + uv-version: 0.2.33 uv-venv: .venv - name: Build diff --git a/pyproject.toml b/pyproject.toml index b1897ee..c22c0da 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,12 +19,10 @@ classifiers = [ "Programming Language :: Cython", "Programming Language :: Python :: 3", ] -requires-python = ">=3.10" +requires-python = ">=3.11" dependencies = [ # keep in sync with NPY_TARGET_VERSION (setup.py) - # https://github.com/scipy/oldest-supported-numpy/issues/76#issuecomment-1628865694 - "numpy>=1.23, <3", - "typing-extensions>=4.1.0 ; python_version < '3.11'", + "numpy>=1.25, <3", ] [project.readme] @@ -103,7 +101,7 @@ convention = "numpy" "_backports.py" = ["D"] [tool.mypy] -python_version = "3.10" +python_version = "3.11" show_error_codes = true pretty = true warn_return_any = true @@ -124,7 +122,7 @@ filterwarnings = [ ] [tool.cibuildwheel] -build = "cp310-* cp311-* cp312-*" +build = "cp311-* cp312-*" build-frontend = "build[uv]" build-verbosity = 1 test-skip = "*-musllinux*" diff --git a/setup.py b/setup.py index 52a44a7..457b5a9 100644 --- a/setup.py +++ b/setup.py @@ -28,7 +28,7 @@ include_dirs=[np.get_include()], define_macros=[ # keep in sync with runtime requirements (pyproject.toml) - ("NPY_TARGET_VERSION", "NPY_1_23_API_VERSION"), + ("NPY_TARGET_VERSION", "NPY_1_25_API_VERSION"), ("NPY_NO_DEPRECATED_API", "NPY_1_7_API_VERSION"), ], ) diff --git a/src/gpgi/_backports.py b/src/gpgi/_backports.py deleted file mode 100644 index 3341491..0000000 --- a/src/gpgi/_backports.py +++ /dev/null @@ -1,44 +0,0 @@ -import sys - -if sys.version_info >= (3, 11): - pass -else: - from enum import Enum - - # vendored from Python 3.11.0 - class ReprEnum(Enum): - """ - Only changes the repr(), leaving str() and format() to the mixed-in type. - """ - - class StrEnum(str, ReprEnum): - """ - Enum where members are also (and must be) strings - """ - - def __new__(cls, *values): - "values must already be of type `str`" - if len(values) > 3: - raise TypeError(f"too many arguments for str(): {values!r}") - if len(values) == 1: - # it must be a string - if not isinstance(values[0], str): - raise TypeError(f"{values[0]!r} is not a string") - if len(values) >= 2: - # check that encoding argument is a string - if not isinstance(values[1], str): - raise TypeError(f"encoding must be a string, not {values[1]!r}") - if len(values) == 3: - # check that errors argument is a string - if not isinstance(values[2], str): - raise TypeError(f"errors must be a string, not {values[2]!r}") - value = str(*values) - member = str.__new__(cls, value) - member._value_ = value - return member - - def _generate_next_value_(name, start, count, last_values): - """ - Return the lower-cased version of the member name. - """ - return name.lower() diff --git a/src/gpgi/_typing.py b/src/gpgi/_typing.py index c6d20f7..5cfdc94 100644 --- a/src/gpgi/_typing.py +++ b/src/gpgi/_typing.py @@ -1,14 +1,8 @@ -import sys -from typing import TypedDict, TypeVar +from typing import NotRequired, TypedDict, TypeVar import numpy as np import numpy.typing as npt -if sys.version_info >= (3, 11): - from typing import NotRequired -else: - from typing_extensions import NotRequired - Real = TypeVar("Real", np.float32, np.float64) RealArray = npt.NDArray[Real] HCIArray = npt.NDArray[np.uint16] diff --git a/src/gpgi/types.py b/src/gpgi/types.py index af999f5..7782a15 100644 --- a/src/gpgi/types.py +++ b/src/gpgi/types.py @@ -4,15 +4,15 @@ import enum import math -import sys import warnings from abc import ABC, abstractmethod from copy import deepcopy +from enum import StrEnum from functools import cached_property, partial, reduce from itertools import chain from textwrap import indent from time import monotonic_ns -from typing import TYPE_CHECKING, Any, Literal, Protocol, cast +from typing import TYPE_CHECKING, Any, Literal, Protocol, Self, assert_never, cast import numpy as np @@ -31,15 +31,6 @@ ) from ._typing import FieldMap, Name -if sys.version_info >= (3, 11): - from enum import StrEnum - from typing import Self, assert_never -else: - from typing_extensions import Self, assert_never - - from ._backports import StrEnum - - if TYPE_CHECKING: from ._typing import HCIArray, RealArray @@ -53,14 +44,6 @@ class Geometry(StrEnum): SPHERICAL = enum.auto() EQUATORIAL = enum.auto() - if sys.version_info >= (3, 11): - pass - else: - - def __str__(self) -> str: - r"""Return str(self).""" - return self.name.lower() - class DepositionMethod(enum.Enum): NEAREST_GRID_POINT = enum.auto() From 7ca0e3607fb275ac470478ed3aee08d4b45f16f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Robert?= Date: Sun, 4 Aug 2024 12:41:02 +0200 Subject: [PATCH 2/2] TST: forbid mpl 3.9.1 on windows (no wheels available) --- requirements/tests.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/requirements/tests.txt b/requirements/tests.txt index ad1d4f3..99934c9 100644 --- a/requirements/tests.txt +++ b/requirements/tests.txt @@ -2,3 +2,5 @@ coverage[toml]>=6.5 pytest>=7.0.0 pytest-mpl>=0.16.1 matplotlib>=3.5 +# https://github.com/matplotlib/matplotlib/issues/28551 +matplotlib!=3.9.1 ; platform_system=='Windows'