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

DEP: drop support for CPython 3.8 #4659

Merged
merged 9 commits into from
Sep 6, 2023
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,6 @@ ef783151bfd7c6777fa25e9e06f95fe47653b3aa

# apply linting to ipynb files
ec8bb45ea1603f3862041fa9e8ec274afd9bbbfd

# auto upgrade typing idioms from Python 3.8 to 3.9
4cfd370a8445abd4620e3853c2c047ee3d649fd7
2 changes: 1 addition & 1 deletion .github/workflows/build-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
test-runner: [pytest]
include:
- os: ubuntu-latest
python-version: '3.8'
python-version: '3.9'
dependencies: minimal
tests-type: unit
test-runner: pytest
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/type-checking.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
# run with oldest support python version
# run with oldest supported python version
# so that we always get compatible versions of
# core dependencies at type-check time
python-version: '3.8'
python-version: '3.9'

- 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 @@ -35,7 +35,7 @@ jobs:
with:
output-dir: dist
env:
CIBW_BUILD: "cp38-* cp39-* cp310-* cp311-* cp312-*"
CIBW_BUILD: "cp39-* cp310-* cp311-* cp312-*"
CIBW_SKIP: "*-musllinux_*" # numpy doesn't have wheels for musllinux so we can't build some quickly and without bloating
CIBW_ARCHS_LINUX: "x86_64"
CIBW_ARCHS_MACOS: x86_64 arm64
Expand Down
29 changes: 10 additions & 19 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@
# keep in sync with .github/workflows/wheels.yaml
requires = [
"setuptools>=61.2",
"importlib_resources>=1.3;python_version < '3.9'",

# see https://github.com/yt-project/yt/issues/4044
"Cython>=3.0, <3.1",

# TODO: simplify requirement after numpy 1.26.0 final is released
"oldest-supported-numpy ; python_version < '3.9'",
"numpy>=1.25, <2.0 ; python_version >= '3.9' and python_version < '3.12.0rc1'",
"numpy>=1.25, <2.0 ; python_version < '3.12.0rc1'",
"numpy>=1.26.0b1, <2.0; python_version >= '3.12.0rc1'",

# TODO: simplify requirement after ewah-bool-utils 1.1.0 final is released
Expand Down Expand Up @@ -37,7 +35,6 @@ classifiers = [
"Programming Language :: C",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
Expand All @@ -48,23 +45,19 @@ classifiers = [
keywords = [
"astronomy astrophysics visualization amr adaptivemeshrefinement",
]
requires-python = ">=3.8"
requires-python = ">=3.9"
dependencies = [
"cmyt>=1.1.2",
"ewah-bool-utils>=1.0.2",
"ipywidgets>=8.0.0",
"matplotlib>=3.5",
"more-itertools>=8.4",
# when Python 3.8 is dropped, keep minimal requirement in sync with NPY_TARGET_VERSION
# upper cap should be lifted when build-time requirement is bumped to >=2.0, see
# https://github.com/scipy/oldest-supported-numpy/issues/76#issuecomment-1628865694
"numpy>=1.17.5,<2.0",
"numpy>=1.19.3, <2.0", # keep minimal requirement in sync with NPY_TARGET_VERSION
"packaging>=20.9",
"pillow>=6.2.1", # transitive dependency via MPL (>=3.3)
"pillow>=8.0.0",
"tomli-w>=0.4.0",
"tqdm>=3.4.0",
"unyt>=2.9.2,<3.0", # see https://github.com/yt-project/yt/issues/4162
"importlib_resources>=1.3;python_version < '3.9'",
"tomli>=1.2.3;python_version < '3.11'",
"typing-extensions>=4.1.0;python_version < '3.11'",
]
Expand Down Expand Up @@ -140,7 +133,7 @@ ytdata = ["yt[HDF5]"]
# "full" should contain all optional dependencies intended for users (not devs)
# in particular it should enable support for all frontends
full = [
"cartopy>=0.22.0; python_version >= '3.9'",
"cartopy>=0.22.0",
"firefly>=3.2.0",
"glueviz>=0.13.3",
"ipython>=2.0.0",
Expand Down Expand Up @@ -219,13 +212,12 @@ minimal = [
"ipywidgets==8.0.0",
"matplotlib==3.5",
"more-itertools==8.4",
"numpy==1.17.5",
"numpy==1.19.3",
"packaging==20.9",
"pillow==6.2.1",
"pillow==8.0.0",
"tomli-w==0.4.0",
"tqdm==3.4.0",
"unyt==2.9.2",
"importlib_resources==1.3;python_version < '3.9'",
"tomli==1.2.3;python_version < '3.11'",
"typing-extensions==4.1.0;python_version < '3.11'",
]
Expand All @@ -239,11 +231,10 @@ test = [
"nose-timer~=1.0.0; python_version < '3.10'",
]
typecheck = [
"mypy==1.0.0",
"mypy==1.5.1",
"types-PyYAML==6.0.12.2",
"types-chardet==5.0.4",
"types-requests==2.28.11.5",
"importlib_resources==1.3;python_version < '3.9'",
"typing-extensions==4.1.0;python_version < '3.11'",
]

Expand All @@ -260,7 +251,7 @@ namespaces = false

[tool.black]
line-length = 88
target-version = ['py38']
target-version = ['py39']
include = '\.pyi?$'
exclude = '''
/(
Expand Down Expand Up @@ -488,7 +479,7 @@ ignore = [


[tool.mypy]
python_version = 3.8
python_version = 3.9
show_error_codes = true
ignore_missing_imports = true
warn_unused_configs = true
Expand Down
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
from collections import defaultdict
from distutils.ccompiler import get_default_compiler
from importlib import resources as importlib_resources

from setuptools import Distribution, setup

Expand All @@ -10,7 +11,6 @@
check_for_openmp,
check_for_pyembree,
create_build_ext,
get_ewah_bool_utils_path,
install_ccompiler,
)

Expand Down Expand Up @@ -49,7 +49,8 @@
"yt/frontends/artio/artio_headers/",
],
"STD_LIBS": std_libs,
"EWAH_LIBS": std_libs + [get_ewah_bool_utils_path()],
"EWAH_LIBS": std_libs
+ [os.path.abspath(importlib_resources.files("ewah_bool_utils"))],
"OMP_ARGS": omp_args,
"FIXED_INTERP": "yt/utilities/lib/fixed_interpolator.cpp",
"ARTIO_SOURCE": sorted(glob.glob("yt/frontends/artio/artio_headers/*.c")),
Expand Down
19 changes: 3 additions & 16 deletions setupext.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@
from setuptools.command.build_ext import build_ext as _build_ext
from setuptools.command.sdist import sdist as _sdist
from setuptools.errors import CompileError, LinkError

if sys.version_info >= (3, 9):
import importlib.resources as importlib_resources
else:
import importlib_resources
import importlib.resources as importlib_resources

log = logging.getLogger("setupext")

Expand Down Expand Up @@ -204,12 +200,6 @@ def check_CPP14_flags(possible_compile_flags):
)
return []

def get_ewah_bool_utils_path():
if sys.version_info >= (3, 9):
return os.path.abspath(importlib_resources.files("ewah_bool_utils"))
else:
from pkg_resources import resource_filename
return os.path.dirname(os.path.abspath(resource_filename("ewah_bool_utils", "ewah_bool_wrap.pxd")))

def check_for_pyembree(std_libs):
embree_libs = []
Expand Down Expand Up @@ -411,12 +401,9 @@ def finalize_options(self):

define_macros = [
("NPY_NO_DEPRECATED_API", "NPY_1_7_API_VERSION"),
]
if sys.version_info >= (3, 9):
# keep in sync with runtime requirements (pyproject.toml)
define_macros.append(("NPY_TARGET_VERSION", "NPY_1_18_API_VERSION"))
else:
pass
("NPY_TARGET_VERSION", "NPY_1_19_API_VERSION"),
]

if self.define is None:
self.define = define_macros
Expand Down
3 changes: 1 addition & 2 deletions tests/unpin_requirements.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import re
import sys
from typing import List

import tomli_w

Expand All @@ -12,7 +11,7 @@
PINNED_VERSION_REGEXP = re.compile(r",?(<|<=|==)([0-9a-z]+\.?)+")


def unpin_requirements(requirements: List[str]) -> List[str]:
def unpin_requirements(requirements: list[str]) -> list[str]:
return [re.sub(PINNED_VERSION_REGEXP, "", _) for _ in requirements]


Expand Down
4 changes: 2 additions & 2 deletions yt/_maintenance/deprecation.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import warnings
from functools import wraps
from types import FunctionType
from typing import Dict, Optional
from typing import Optional


def issue_deprecation_warning(
Expand Down Expand Up @@ -45,7 +45,7 @@ def issue_deprecation_warning(
warnings.warn(msg, DeprecationWarning, stacklevel=stacklevel)


def future_positional_only(positions2names: Dict[int, str], /, **depr_kwargs):
def future_positional_only(positions2names: dict[int, str], /, **depr_kwargs):
"""Warn users when using a future positional-only argument as keyword.
Note that positional-only arguments are available from Python 3.8
See https://www.python.org/dev/peps/pep-0570/
Expand Down
18 changes: 9 additions & 9 deletions yt/_typing.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
from typing import List, Optional, Tuple, Union
from typing import Optional, Union

import unyt as un
from numpy import ndarray

FieldDescT = Tuple[str, Tuple[str, List[str], Optional[str]]]
KnownFieldsT = Tuple[FieldDescT, ...]
FieldDescT = tuple[str, tuple[str, list[str], Optional[str]]]
KnownFieldsT = tuple[FieldDescT, ...]

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

ParticleCoordinateTuple = Tuple[
ParticleCoordinateTuple = tuple[
str, # particle type
Tuple[ndarray, ndarray, ndarray], # xyz
tuple[ndarray, ndarray, ndarray], # xyz
Union[float, ndarray], # hsml
]

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

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

# types that can be converted to un.unyt_quantity
Quantity = Union[un.unyt_quantity, Tuple[float, Unit]]
Quantity = Union[un.unyt_quantity, tuple[float, Unit]]
12 changes: 6 additions & 6 deletions yt/data_objects/data_containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import weakref
from collections import defaultdict
from contextlib import contextmanager
from typing import TYPE_CHECKING, List, Optional, Tuple
from typing import TYPE_CHECKING, Optional

import numpy as np

Expand Down Expand Up @@ -66,14 +66,14 @@ class YTDataContainer(abc.ABC):

_chunk_info = None
_num_ghost_zones = 0
_con_args: Tuple[str, ...] = ()
_con_args: tuple[str, ...] = ()
_skip_add = False
_container_fields: Tuple[AnyFieldKey, ...] = ()
_tds_attrs: Tuple[str, ...] = ()
_tds_fields: Tuple[str, ...] = ()
_container_fields: tuple[AnyFieldKey, ...] = ()
_tds_attrs: tuple[str, ...] = ()
_tds_fields: tuple[str, ...] = ()
_field_cache = None
_index = None
_key_fields: List[str]
_key_fields: list[str]

def __init__(self, ds: Optional["Dataset"], field_parameters) -> None:
"""
Expand Down
3 changes: 1 addition & 2 deletions yt/data_objects/index_subobjects/grid_patch.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import weakref
from typing import List

import numpy as np

Expand Down Expand Up @@ -270,7 +269,7 @@ def retrieve_ghost_zones(self, n_zones, fields, all_levels=False, smoothed=False

def get_vertex_centered_data(
self,
fields: List[FieldKey],
fields: list[FieldKey],
smoothed: bool = True,
no_ghost: bool = False,
):
Expand Down
3 changes: 1 addition & 2 deletions yt/data_objects/index_subobjects/octree_subset.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from contextlib import contextmanager
from functools import cached_property
from itertools import product, repeat
from typing import Tuple

import numpy as np
from unyt import unyt_array
Expand Down Expand Up @@ -39,7 +38,7 @@ class OctreeSubset(YTSelectionContainer):
_num_ghost_zones = 0
_type_name = "octree_subset"
_skip_add = True
_con_args: Tuple[str, ...] = ("base_region", "domain", "ds")
_con_args: tuple[str, ...] = ("base_region", "domain", "ds")
_domain_offset = 0
_cell_count = -1
_block_order = "C"
Expand Down
3 changes: 1 addition & 2 deletions yt/data_objects/particle_filters.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import copy
from contextlib import contextmanager
from typing import Dict

from yt.fields.field_info_container import NullFunc, TranslationFunc
from yt.funcs import mylog
from yt.utilities.exceptions import YTIllDefinedFilter

# One to one mapping
filter_registry: Dict[str, "ParticleFilter"] = {}
filter_registry: dict[str, "ParticleFilter"] = {}


class DummyFieldInfo:
Expand Down
3 changes: 1 addition & 2 deletions yt/data_objects/selection_objects/data_selection_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import uuid
from collections import defaultdict
from contextlib import contextmanager
from typing import Tuple

import numpy as np
from more_itertools import always_iterable
Expand Down Expand Up @@ -1398,7 +1397,7 @@ def _get_bbox(self):
"""
return self.ds.domain_left_edge, self.ds.domain_right_edge

def get_bbox(self) -> Tuple[unyt_array, unyt_array]:
def get_bbox(self) -> tuple[unyt_array, unyt_array]:
"""
Return the bounding box for this data container.
"""
Expand Down
Loading