Skip to content

Commit

Permalink
Merge pull request #4979 from neutrinoceros/dep/drop_cp39
Browse files Browse the repository at this point in the history
DEP: drop support for Python 3.9
  • Loading branch information
Xarthisius authored Oct 7, 2024
2 parents 2e65cb9 + 00cf11a commit 0e6a608
Show file tree
Hide file tree
Showing 109 changed files with 313 additions and 579 deletions.
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,6 @@ ec8bb45ea1603f3862041fa9e8ec274afd9bbbfd

# migration: black -> ruff-format
3214662dc7d53f7ac56b3589c5a27ef075f83ab4

# auto upgrade syntax from Python 3.9 to 3.10
e86625e780b77a42aedad711e5a9a945ce650974
55 changes: 41 additions & 14 deletions .github/workflows/build-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,43 +22,51 @@ jobs:
# run all tests even if e.g. image tests fail early
fail-fast: false
matrix:
os: [
macos-latest,
windows-latest,
ubuntu-latest,
]
os:
- ubuntu-latest
- macos-latest
python-version: ['3.12']
dependencies: [full]
tests-type: [unit]
test-runner: [pytest]
venv-loc: [bin]
include:
- os: windows-latest
python-version: '3.12'
dependencies: full
tests-type: unit
test-runner: pytest
venv-loc: Scripts
- os: ubuntu-20.04
python-version: '3.9.2'
python-version: '3.10.3'
dependencies: minimal
tests-type: unit
test-runner: pytest
venv-loc: bin
- os: ubuntu-latest
# this job is necessary for non-answer, 'yield' based tests
# because pytest doesn't support such tests, and nose is not
# compatible with Python 3.10
python-version: '3.9'
# because pytest doesn't support such tests
python-version: '3.10'
dependencies: full
tests-type: unit
test-runner: nose
venv-loc: bin
- os: ubuntu-latest
# answer tests use 'yield', so they require nose
# they are also attached to a specific, occasionally updated, Python version
# but it does *not* have to match the current minimal supported version
python-version: '3.9'
python-version: '3.10'
dependencies: full
tests-type: answer
test-runner: nose
venv-loc: bin
- os: ubuntu-latest
# minimal tests with latest Python and no optional dependencies
python-version: '3.x'
dependencies: ''
tests-type: unit
test-runner: pytest
venv-loc: bin

runs-on: ${{ matrix.os }}

Expand All @@ -84,15 +92,34 @@ jobs:
shell: bash
env:
dependencies: ${{ matrix.dependencies }}
run: source ./tests/ci_install.sh
run: |
python -m venv .venv
source .venv/${{matrix.venv-loc}}/activate
source ./tests/ci_install.sh
- name: Install and patch nosetest
if: matrix.test-runner == 'nose'
run: |
source .venv/${{matrix.venv-loc}}/activate
python -m pip install -r nose_requirements.txt
find .venv/lib/python${{matrix.python-version}}/site-packages/nose -name '*.py' \
-exec sed -i -e s/collections.Callable/collections.abc.Callable/g '{}' ';'
- name: Show final env
run: |
source .venv/${{matrix.venv-loc}}/activate
python -m pip list
- run: python -m pip list
- name: Run Unit Tests (pytest)
if: matrix.test-runner == 'pytest'
run: pytest --color=yes
run: |
source .venv/${{matrix.venv-loc}}/activate
pytest --color=yes
- name: Run Tests (nose)
if: matrix.test-runner == 'nose'
run: cat nose_ignores.txt | xargs python -m nose -c nose_unit.cfg --traverse-namespace
run: |
source .venv/${{matrix.venv-loc}}/activate
cat nose_ignores.txt | xargs python -m nose -c nose_unit.cfg --traverse-namespace
image-tests:
name: Image tests
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/type-checking.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
# run with oldest supported python version
# so that we always get compatible versions of
# core dependencies at type-check time
python-version: '3.9'
python-version: '3.10'

- name: Build
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/wheels.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.9'
python-version: '3.10'

- name: Build sdist
run: pipx run build --sdist
Expand Down
2 changes: 0 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ repos:
args: [
--fix,
--show-fixes,
# the following line can be removed after support for Python 3.9 is dropped
--extend-select=B905, # zip-without-explicit-strict
]

- repo: https://github.com/pre-commit/pygrep-hooks
Expand Down
3 changes: 2 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,5 @@ recursive-include yt/frontends/amrvac *.par
recursive-exclude requirements *.txt
exclude minimal_requirements.txt
exclude .codecov.yml .coveragerc .git-blame-ignore-revs .gitmodules .hgchurn .mailmap
exclude .pre-commit-config.yaml clean.sh nose_answer.cfg nose_unit.cfg nose_ignores.txt
exclude .pre-commit-config.yaml clean.sh
exclude nose_answer.cfg nose_unit.cfg nose_ignores.txt nose_requirements.txt
6 changes: 6 additions & 0 deletions doc/source/developing/testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@ Answer Testing
an `older version of this documentation <https://yt-project.org/docs/4.0.0/developing/testing.html#answer-testing>`_
decribes how the ``nose`` tests work.

.. note::
Given that nose never had support for Python 3.10 (which as of yt 4.4 is our
oldest supported version), it is necessary to patch it to get tests running.
This is the command we run on CI to this end
``find .venv/lib/python3.10/site-packages/nose -name '*.py' -exec sed -i -e s/collections.Callable/collections.abc.Callable/g '{}' ';'``

What Do Answer Tests Do
^^^^^^^^^^^^^^^^^^^^^^^

Expand Down
4 changes: 3 additions & 1 deletion doc/source/installing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ Here's a summary for most recent releases
+------------+------------+----------------+-----------------+
| yt release | Python 2.7 | Python3 min | Python3 max |
+============+============+================+=================+
| 4.3.x | no | 3.9 | 3.12 (expected) |
| 4.4.x | no | 3.10.3 | 3.13 (expected) |
+------------+------------+----------------|-----------------|
| 4.3.x | no | 3.9.2 | 3.12 |
+------------+------------+----------------+-----------------+
| 4.2.x | no | 3.8 | 3.11 |
+------------+------------+----------------+-----------------+
Expand Down
10 changes: 4 additions & 6 deletions minimal_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This file was autogenerated by uv via the following command:
# uv pip compile pyproject.toml --python=3.9 --python-platform=x86_64-unknown-linux-gnu --resolution=lowest-direct --no-build
# uv pip compile pyproject.toml --python=3.10 --python-platform=x86_64-unknown-linux-gnu --resolution=lowest-direct --no-build
cmyt==1.1.2
# via yt (pyproject.toml)
colorspacious==1.1.2
Expand All @@ -22,7 +22,7 @@ more-itertools==8.4.0
# cmyt
mpmath==1.3.0
# via sympy
numpy==1.19.3
numpy==1.21.3
# via
# yt (pyproject.toml)
# cmyt
Expand All @@ -35,7 +35,7 @@ packaging==20.9
# yt (pyproject.toml)
# matplotlib
# setuptools-scm
pillow==8.0.0
pillow==8.3.2
# via
# yt (pyproject.toml)
# matplotlib
Expand All @@ -62,8 +62,6 @@ tomli-w==0.4.0
tqdm==3.4.0
# via yt (pyproject.toml)
typing-extensions==4.4.0
# via
# yt (pyproject.toml)
# setuptools-scm
# via yt (pyproject.toml)
unyt==2.9.2
# via yt (pyproject.toml)
3 changes: 3 additions & 0 deletions nose_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
nose~=1.3.7
nose-exclude
nose-timer~=1.0.0
14 changes: 5 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ classifiers = [
"Programming Language :: C",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
Expand All @@ -39,19 +38,19 @@ classifiers = [
keywords = [
"astronomy astrophysics visualization amr adaptivemeshrefinement",
]
requires-python = ">=3.9.2"
requires-python = ">=3.10.3"

# keep in sync with minimal_requirements.txt
dependencies = [
"cmyt>=1.1.2",
"ewah-bool-utils>=1.2.0",
"matplotlib>=3.5",
"more-itertools>=8.4",
"numpy>=1.19.3, <3", # keep minimal requirement in sync with NPY_TARGET_VERSION
"numpy>=1.21.3, <3", # keep minimal requirement in sync with NPY_TARGET_VERSION
# https://github.com/numpy/numpy/issues/27037
"numpy!=2.0.1 ; platform_machine=='arm64' and platform_system=='Darwin'",
"packaging>=20.9",
"pillow>=8.0.0",
"pillow>=8.3.2",
"tomli-w>=0.4.0",
"tqdm>=3.4.0",
"unyt>=2.9.2",
Expand Down Expand Up @@ -200,9 +199,6 @@ test = [
"pytest>=6.1",
"pytest-mpl>=0.16.1",
"sympy!=1.10,!=1.9", # see https://github.com/sympy/sympy/issues/22241
"nose~=1.3.7; python_version < '3.10'",
"nose-exclude; python_version < '3.10'",
"nose-timer~=1.0.0; python_version < '3.10'",
"imageio!=2.35.0", # see https://github.com/yt-project/yt/issues/4966
]

Expand Down Expand Up @@ -456,7 +452,7 @@ ignore = [


[tool.mypy]
python_version = 3.9
python_version = '3.10'
show_error_codes = true
ignore_missing_imports = true
warn_unused_configs = true
Expand All @@ -466,7 +462,7 @@ show_error_context = true
exclude = "(test_*|lodgeit)"

[tool.cibuildwheel]
build = "cp39-* cp310-* cp311-* cp312-* cp313-*"
build = "cp310-* cp311-* cp312-* cp313-*"
build-verbosity = 1
test-skip = "*-musllinux*"
test-extras = "test"
Expand Down
2 changes: 1 addition & 1 deletion setupext.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ def get_python_include_dirs():
NUMPY_MACROS = [
("NPY_NO_DEPRECATED_API", "NPY_1_7_API_VERSION"),
# keep in sync with runtime requirements (pyproject.toml)
("NPY_TARGET_VERSION", "NPY_1_19_API_VERSION"),
("NPY_TARGET_VERSION", "NPY_1_21_API_VERSION"),
]


Expand Down
5 changes: 0 additions & 5 deletions tests/ci_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ cp tests/matplotlibrc .

# Step 1: pre-install required packages
if [[ ${dependencies} == "full" || ${dependencies} == "cartopy" ]]; then
# upgrading pip to guarantee installing extra dependencies with [full] is supported
# this is only necessary for some versions of Python 3.8 and 3.9
# see https://github.com/yt-project/yt/issues/4270
python -m pip install 'pip>=21.2'

case ${RUNNER_OS} in
linux|Linux)
sudo apt-get -qqy update
Expand Down
15 changes: 0 additions & 15 deletions yt/_maintenance/backports.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,3 @@ def _generate_next_value_(name, start, count, last_values): # noqa B902
Return the lower-cased version of the member name.
"""
return name.lower()


builtin_zip = zip
if sys.version_info >= (3, 10):
zip = builtin_zip
else:
# this function is deprecated in more_itertools
# because it is superseded by the standard library
from more_itertools import zip_equal

def zip(*args, strict=False):
if strict:
return zip_equal(*args)
else:
return builtin_zip(*args)
3 changes: 1 addition & 2 deletions yt/_maintenance/deprecation.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import warnings
from functools import wraps
from types import FunctionType
from typing import Optional


def issue_deprecation_warning(
msg: str,
*,
stacklevel: int,
since: str,
removal: Optional[str] = None,
removal: str | None = None,
):
"""
Parameters
Expand Down
13 changes: 5 additions & 8 deletions yt/_maintenance/numpy2_compat.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
# avoid deprecation warnings in numpy >= 2.0

from importlib.metadata import version
import numpy as np

from packaging.version import Version

NUMPY_VERSION = Version(version("numpy"))

if NUMPY_VERSION >= Version("2.0.0dev0"):
from numpy import trapezoid as trapezoid # type: ignore [attr-defined]
if hasattr(np, "trapezoid"):
# np.trapz is deprecated in numpy 2.0 in favor of np.trapezoid
trapezoid = np.trapezoid
else:
from numpy import trapz as trapezoid # type: ignore [attr-defined] # noqa: F401
trapezoid = np.trapz # type: ignore [attr-defined] # noqa: NPY201
14 changes: 7 additions & 7 deletions yt/_typing.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
from typing import Any, Optional, Union
from typing import Any, Optional, TypeAlias

import numpy as np
import unyt as un

FieldDescT = tuple[str, tuple[str, list[str], Optional[str]]]
FieldDescT = tuple[str, tuple[str, list[str], str | None]]
KnownFieldsT = tuple[FieldDescT, ...]

ParticleType = str
FieldType = str
FieldName = str
FieldKey = tuple[FieldType, FieldName]
ImplicitFieldKey = FieldName
AnyFieldKey = Union[FieldKey, ImplicitFieldKey]
DomainDimensions = Union[tuple[int, ...], list[int], np.ndarray]
AnyFieldKey = FieldKey | ImplicitFieldKey
DomainDimensions = tuple[int, ...] | list[int] | np.ndarray

ParticleCoordinateTuple = tuple[
str, # particle type
tuple[np.ndarray, np.ndarray, np.ndarray], # xyz
Union[float, np.ndarray], # hsml
float | np.ndarray, # hsml
]

# Geometry specific types
AxisName = str
AxisOrder = tuple[AxisName, AxisName, AxisName]

# types that can be converted to un.Unit
Unit = Union[un.Unit, str]
Unit: TypeAlias = un.Unit | str

# types that can be converted to un.unyt_quantity
Quantity = Union[un.unyt_quantity, tuple[float, Unit]]
Quantity = un.unyt_quantity | tuple[float, Unit]

# np.ndarray[...] syntax is runtime-valid from numpy 1.22, we quote it until our minimal
# runtime requirement is bumped to, or beyond this version
Expand Down
4 changes: 0 additions & 4 deletions yt/data_objects/analyzer_objects.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import inspect
import sys

from yt.utilities.object_registries import analysis_task_registry

if sys.version_info < (3, 10):
from yt._maintenance.backports import zip


class AnalysisTask:
def __init_subclass__(cls, *args, **kwargs):
Expand Down
Loading

0 comments on commit 0e6a608

Please sign in to comment.