From 9f51fb5b9d01232628febf597aeb388333bd3a92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Robert?= Date: Fri, 18 Sep 2020 17:32:42 +0200 Subject: [PATCH] MNT: bump mininal supported Python version from 3.6 to 3.7 --- .github/workflows/build-test-pytest.yaml | 2 +- .github/workflows/build-test.yaml | 2 +- .pre-commit-config.yaml | 8 ++++++- conftest.py | 12 ++++++++++ doc/source/installing.rst | 2 +- pyproject.toml | 12 ++-------- setup.cfg | 12 ++++------ yt/utilities/on_demand_imports.py | 17 -------------- yt/visualization/color_maps.py | 29 +----------------------- 9 files changed, 30 insertions(+), 66 deletions(-) diff --git a/.github/workflows/build-test-pytest.yaml b/.github/workflows/build-test-pytest.yaml index 045e28a2dee..f300e7fd914 100644 --- a/.github/workflows/build-test-pytest.yaml +++ b/.github/workflows/build-test-pytest.yaml @@ -31,7 +31,7 @@ jobs: tests-type: [unit] include: - os: ubuntu-latest - python-version: 3.6 + python-version: 3.7 dependencies: minimal tests-type: unit diff --git a/.github/workflows/build-test.yaml b/.github/workflows/build-test.yaml index 895ae2d1e7a..638d3056521 100644 --- a/.github/workflows/build-test.yaml +++ b/.github/workflows/build-test.yaml @@ -31,7 +31,7 @@ jobs: tests-type: [unit] include: - os: ubuntu-latest - python-version: 3.6 + python-version: 3.7 dependencies: minimal tests-type: unit - os: ubuntu-latest diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a478c31cba5..98c753bddb0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,6 +15,12 @@ yt/extern\ ci: autofix_prs: false +default_language_version: + # setup default Python runtime version for Python hooks + # that don't specify their own (e.g. black) + # 3.9 is the most supported version as of 09/19/2021 + python: python3.9 + repos: - repo: https://github.com/asottile/setup-cfg-fmt rev: v1.18.0 @@ -34,7 +40,7 @@ repos: rev: v2.29.0 hooks: - id: pyupgrade - args: [--py36-plus] + args: [--py37-plus] - repo: https://github.com/psf/black rev: 21.9b0 hooks: diff --git a/conftest.py b/conftest.py index ccdb5390739..5805f58c7d5 100644 --- a/conftest.py +++ b/conftest.py @@ -4,8 +4,10 @@ from importlib.util import find_spec from pathlib import Path +import matplotlib import pytest import yaml +from packaging.version import Version from yt.config import ytcfg from yt.utilities.answer_testing.testing_utilities import ( @@ -17,6 +19,8 @@ data_dir_load, ) +MPL_VERSION = Version(matplotlib.__version__) + def pytest_addoption(parser): """ @@ -109,6 +113,14 @@ def pytest_configure(config): ): config.addinivalue_line("filterwarnings", value) + if MPL_VERSION < Version("3.0.0"): + config.addinivalue_line( + "filterwarnings", + ( + "ignore:Using or importing the ABCs from 'collections' instead of from 'collections.abc' " + "is deprecated since Python 3.3,and in 3.9 it will stop working:DeprecationWarning" + ), + ) # at the time of writing, astropy's wheels are behind numpy's latest # version but this doesn't cause actual problems in our test suite, so # we allow this warning to pass. diff --git a/doc/source/installing.rst b/doc/source/installing.rst index 5edaee32992..7a06b243e3c 100644 --- a/doc/source/installing.rst +++ b/doc/source/installing.rst @@ -32,7 +32,7 @@ Here's a summary for most recent releases +------------+------------+----------------+-----------------+ | yt release | Python 2.7 | Python3 min | Python3 max | +============+============+================+=================+ -| 4.1.x | no | 3.7 (expected) | 3.10 (expected) | +| 4.1.x | no | 3.7 | 3.10 (expected) | +------------+------------+----------------+-----------------+ | 4.0.x | no | 3.6 | 3.9 | +------------+------------+----------------+-----------------+ diff --git a/pyproject.toml b/pyproject.toml index fe826c6a760..f2c10880fa4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,23 +4,15 @@ requires = [ # see https://github.com/numpy/numpy/pull/18389 "wheel>=0.36.2", - # cython version is imposed by that of numpy, see release notes - # https://github.com/numpy/numpy/releases/tag/v1.19.2 # Cython 3.0 is the next version after 0.29, and a major change, # we forbid it until we can properly test against it - "Cython>=0.26.1,<3.0; python_version=='3.6'", - "Cython>=0.29.21,<3.0; python_version>='3.7'", + "Cython>=0.29.21,<3.0", "oldest-supported-numpy", ] [tool.black] line-length = 88 -target-version = [ - 'py36', - 'py37', - 'py38', - 'py39', -] +target-version = ['py37'] include = '\.pyi?$' exclude = ''' /( diff --git a/setup.cfg b/setup.cfg index c327700daf5..22601d0f07b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -20,7 +20,6 @@ classifiers = Programming Language :: C Programming Language :: Python :: 3 Programming Language :: Python :: 3 :: Only - Programming Language :: Python :: 3.6 Programming Language :: Python :: 3.7 Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 @@ -38,9 +37,9 @@ project_urls = packages = find: install_requires = ipython>=2.0.0 - matplotlib!=3.4.2,>=2.0.2,<3.6 + matplotlib!=3.4.2,>=2.2.3,<3.6 more-itertools>=8.4 - numpy>=1.13.3 + numpy>=1.14.5 packaging>=20.9 pyyaml>=4.2b1 setuptools>=19.6 @@ -48,7 +47,7 @@ install_requires = toml>=0.10.2 tqdm>=3.4.0 unyt>=2.8.0 -python_requires = >=3.6,<3.12 +python_requires = >=3.7,<3.12 include_package_data = True scripts = scripts/iyt zip_safe = False @@ -94,10 +93,9 @@ mapserver = bottle minimal = ipython==2.0.0 - matplotlib==2.0.2 + matplotlib==2.2.3 more-itertools==8.4 - numpy==1.13.3 - sympy==1.2 + numpy==1.14.5 unyt==2.8.0 test = codecov~=2.0.15 diff --git a/yt/utilities/on_demand_imports.py b/yt/utilities/on_demand_imports.py index 5aacee8fad0..8d520dac6f2 100644 --- a/yt/utilities/on_demand_imports.py +++ b/yt/utilities/on_demand_imports.py @@ -1,7 +1,5 @@ import sys -from packaging.version import Version - class NotAModule: """ @@ -356,21 +354,6 @@ def ndimage(self): class h5py_imports: _name = "h5py" _err = None - - def __init__(self): - try: - import h5py - - if Version(h5py.__version__) < Version("2.4.0"): - self._err = RuntimeError( - "yt requires h5py version 2.4.0 or newer, " - "please update h5py with e.g. `python -m pip install -U h5py` " - "and try again" - ) - except ImportError: - pass - super().__init__() - _File = None @property diff --git a/yt/visualization/color_maps.py b/yt/visualization/color_maps.py index 0c6b4837c6a..210498786fc 100644 --- a/yt/visualization/color_maps.py +++ b/yt/visualization/color_maps.py @@ -1,12 +1,8 @@ import numpy as np -from matplotlib import __version__ as mpl_ver, cm as mcm, colors as cc -from packaging.version import Version +from matplotlib import cm as mcm, colors as cc from . import _colormap_data as _cm -MPL_VERSION = Version(mpl_ver) -del mpl_ver - def is_colormap(cmap): return isinstance(cmap, cc.Colormap) @@ -260,29 +256,6 @@ def show_colormaps(subset="all", filename=None): "to be 'all', 'yt_native', or a list of " "valid colormap names." ) from e - if Version("2.0.0") <= MPL_VERSION < Version("2.2.0"): - # the reason we do this filtering is to avoid spurious warnings in CI when - # testing against old versions of matplotlib (currently not older than 2.0.x) - # and we can't easily filter warnings at the level of the relevant test itself - # because it's not yet run exclusively with pytest. - # FUTURE: remove this completely when only matplotlib 2.2+ is supported - deprecated_cmaps = { - "spectral", - "spectral_r", - "Vega10", - "Vega10_r", - "Vega20", - "Vega20_r", - "Vega20b", - "Vega20b_r", - "Vega20c", - "Vega20c_r", - } - for cmap in deprecated_cmaps: - try: - maps.remove(cmap) - except ValueError: - pass maps = sorted(set(maps)) # scale the image size by the number of cmaps