From a73a78a167df7e9c0257e168dba2ffc65534becf Mon Sep 17 00:00:00 2001 From: "Martin K. Scherer" Date: Thu, 7 Oct 2021 21:54:42 +0200 Subject: [PATCH 01/33] remove requirement for setuptools.pkg_resources Fixes #5676 Now depends on importlib-metadata for Python major version < 3.8 --- setup.cfg | 2 +- xarray/__init__.py | 18 ++++++++++++++---- xarray/backends/plugins.py | 10 ++++++++-- xarray/core/formatting_html.py | 14 ++++++++------ 4 files changed, 31 insertions(+), 13 deletions(-) diff --git a/setup.cfg b/setup.cfg index aa8ca8df0ff..4860704d77d 100644 --- a/setup.cfg +++ b/setup.cfg @@ -78,7 +78,7 @@ python_requires = >=3.7 install_requires = numpy >= 1.17 pandas >= 1.0 - setuptools >= 40.4 # For pkg_resources + importlib-metadata; python_version < '3.8' [options.extras_require] io = diff --git a/xarray/__init__.py b/xarray/__init__.py index eb35bbb2d18..3a04bfa8631 100644 --- a/xarray/__init__.py +++ b/xarray/__init__.py @@ -1,5 +1,3 @@ -import pkg_resources - from . import testing, tutorial, ufuncs from .backends.api import ( load_dataarray, @@ -28,13 +26,25 @@ from .core.parallel import map_blocks from .core.variable import Coordinate, IndexVariable, Variable, as_variable from .util.print_versions import show_versions - try: - __version__ = pkg_resources.get_distribution("xarray").version + try: + from importlib.metadata import version, PackageNotFoundError + except ImportError: + try: + from importlib_metadata import version, PackageNotFoundError + except ImportError: + raise + + try: + __version__ = version("xarray") + except PackageNotFoundError: + raise + del version, PackageNotFoundError except Exception: # Local copy or not installed with setuptools. # Disable minimum version checks on downstream libraries. __version__ = "999" + raise # A hardcoded __all__ variable is necessary to appease # `mypy --strict` running in projects that import xarray. diff --git a/xarray/backends/plugins.py b/xarray/backends/plugins.py index 08c1bec8325..7e4894c00e1 100644 --- a/xarray/backends/plugins.py +++ b/xarray/backends/plugins.py @@ -95,8 +95,14 @@ def build_engines(pkg_entrypoints): @functools.lru_cache(maxsize=1) def list_engines(): - pkg_entrypoints = pkg_resources.iter_entry_points("xarray.backends") - return build_engines(pkg_entrypoints) + try: + from importlib.metadata import Distribution + except ImportError: + from importlib_metadata import Distrubtion + importlib_entrypoints = (entry_point for entry_point + in Distribution.from_name("xarray").entry_points + if entry_point.module == "xarray.backends") + return build_engines(importlib_entrypoints) def guess_engine(store_spec): diff --git a/xarray/core/formatting_html.py b/xarray/core/formatting_html.py index 2a480427d4e..ad642ddd06b 100644 --- a/xarray/core/formatting_html.py +++ b/xarray/core/formatting_html.py @@ -3,8 +3,6 @@ from functools import lru_cache, partial from html import escape -import pkg_resources - from .formatting import inline_variable_array_repr, short_data_repr from .options import _get_boolean_with_default @@ -14,10 +12,14 @@ @lru_cache(None) def _load_static_files(): """Lazily load the resource files into memory the first time they are needed""" - return [ - pkg_resources.resource_string("xarray", fname).decode("utf8") - for fname in STATIC_FILES - ] + import pathlib + parent = pathlib.Path(__file__).parent / "../" + result = [] + for fname in STATIC_FILES: + with open(parent / fname) as fh: + result.append(fh.read().encode("utf8")) + + return result def short_data_repr_html(array): From 9d14a016c1bfde9103b3cfec9ffa5268f4e96374 Mon Sep 17 00:00:00 2001 From: "Martin K. Scherer" Date: Thu, 7 Oct 2021 21:59:37 +0200 Subject: [PATCH 02/33] doh --- xarray/backends/plugins.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/xarray/backends/plugins.py b/xarray/backends/plugins.py index 7e4894c00e1..b62f5bcd881 100644 --- a/xarray/backends/plugins.py +++ b/xarray/backends/plugins.py @@ -3,8 +3,6 @@ import itertools import warnings -import pkg_resources - from .common import BACKEND_ENTRYPOINTS, BackendEntrypoint STANDARD_BACKENDS_ORDER = ["netcdf4", "h5netcdf", "scipy"] From 6104a059794db4c417a93c13532310924e6237e3 Mon Sep 17 00:00:00 2001 From: "Martin K. Scherer" Date: Thu, 7 Oct 2021 22:00:25 +0200 Subject: [PATCH 03/33] doh2 --- xarray/backends/plugins.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xarray/backends/plugins.py b/xarray/backends/plugins.py index b62f5bcd881..ee6413ede11 100644 --- a/xarray/backends/plugins.py +++ b/xarray/backends/plugins.py @@ -96,7 +96,7 @@ def list_engines(): try: from importlib.metadata import Distribution except ImportError: - from importlib_metadata import Distrubtion + from importlib_metadata import Distribution importlib_entrypoints = (entry_point for entry_point in Distribution.from_name("xarray").entry_points if entry_point.module == "xarray.backends") From d500090d5b224743e294c42ce27d139a42b10fd7 Mon Sep 17 00:00:00 2001 From: "Martin K. Scherer" Date: Thu, 7 Oct 2021 22:02:05 +0200 Subject: [PATCH 04/33] doh3, no reraise for fallback version number --- xarray/__init__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/xarray/__init__.py b/xarray/__init__.py index 3a04bfa8631..9e820d2d728 100644 --- a/xarray/__init__.py +++ b/xarray/__init__.py @@ -44,7 +44,6 @@ # Local copy or not installed with setuptools. # Disable minimum version checks on downstream libraries. __version__ = "999" - raise # A hardcoded __all__ variable is necessary to appease # `mypy --strict` running in projects that import xarray. From 7537b33a1aaca08d219fc7060c49146f3e61d951 Mon Sep 17 00:00:00 2001 From: "Martin K. Scherer" Date: Thu, 7 Oct 2021 22:09:17 +0200 Subject: [PATCH 05/33] black formatting --- xarray/__init__.py | 1 + xarray/backends/plugins.py | 8 +++++--- xarray/core/formatting_html.py | 1 + 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/xarray/__init__.py b/xarray/__init__.py index 9e820d2d728..f41a6c654ae 100644 --- a/xarray/__init__.py +++ b/xarray/__init__.py @@ -26,6 +26,7 @@ from .core.parallel import map_blocks from .core.variable import Coordinate, IndexVariable, Variable, as_variable from .util.print_versions import show_versions + try: try: from importlib.metadata import version, PackageNotFoundError diff --git a/xarray/backends/plugins.py b/xarray/backends/plugins.py index ee6413ede11..6d2953d7754 100644 --- a/xarray/backends/plugins.py +++ b/xarray/backends/plugins.py @@ -97,9 +97,11 @@ def list_engines(): from importlib.metadata import Distribution except ImportError: from importlib_metadata import Distribution - importlib_entrypoints = (entry_point for entry_point - in Distribution.from_name("xarray").entry_points - if entry_point.module == "xarray.backends") + importlib_entrypoints = ( + entry_point + for entry_point in Distribution.from_name("xarray").entry_points + if entry_point.module == "xarray.backends" + ) return build_engines(importlib_entrypoints) diff --git a/xarray/core/formatting_html.py b/xarray/core/formatting_html.py index ad642ddd06b..82b9a6d227d 100644 --- a/xarray/core/formatting_html.py +++ b/xarray/core/formatting_html.py @@ -13,6 +13,7 @@ def _load_static_files(): """Lazily load the resource files into memory the first time they are needed""" import pathlib + parent = pathlib.Path(__file__).parent / "../" result = [] for fname in STATIC_FILES: From 4dcc37171bc9037f4f14127d9bfc45abdbf7c754 Mon Sep 17 00:00:00 2001 From: "Martin K. Scherer" Date: Thu, 7 Oct 2021 22:10:44 +0200 Subject: [PATCH 06/33] ordering --- xarray/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xarray/__init__.py b/xarray/__init__.py index f41a6c654ae..15d8e41bce2 100644 --- a/xarray/__init__.py +++ b/xarray/__init__.py @@ -29,10 +29,10 @@ try: try: - from importlib.metadata import version, PackageNotFoundError + from importlib.metadata import PackageNotFoundError, version except ImportError: try: - from importlib_metadata import version, PackageNotFoundError + from importlib_metadata import PackageNotFoundError, version except ImportError: raise From 2fc65375a4f20633ed1e9920e92d18614166d1ea Mon Sep 17 00:00:00 2001 From: "Martin K. Scherer" Date: Thu, 7 Oct 2021 22:14:48 +0200 Subject: [PATCH 07/33] all this lifetime wasted by fucking linting tools --- xarray/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xarray/__init__.py b/xarray/__init__.py index 15d8e41bce2..91641dd7d00 100644 --- a/xarray/__init__.py +++ b/xarray/__init__.py @@ -32,7 +32,7 @@ from importlib.metadata import PackageNotFoundError, version except ImportError: try: - from importlib_metadata import PackageNotFoundError, version + from importlib_metadata import PackageNotFoundError, version # type: ignore[no-redef] except ImportError: raise From b482d68887e963ab22cb52cca4307dad1f613893 Mon Sep 17 00:00:00 2001 From: "Martin K. Scherer" Date: Fri, 8 Oct 2021 00:36:41 +0200 Subject: [PATCH 08/33] precommit --- xarray/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/xarray/__init__.py b/xarray/__init__.py index 91641dd7d00..4698a9be4bb 100644 --- a/xarray/__init__.py +++ b/xarray/__init__.py @@ -32,7 +32,10 @@ from importlib.metadata import PackageNotFoundError, version except ImportError: try: - from importlib_metadata import PackageNotFoundError, version # type: ignore[no-redef] + from importlib_metadata import ( # type: ignore[no-redef] + PackageNotFoundError, + version, + ) except ImportError: raise From c38b81219b0e0f39ca869292834ca390a3691439 Mon Sep 17 00:00:00 2001 From: Illviljan <14371165+Illviljan@users.noreply.github.com> Date: Sun, 24 Oct 2021 07:31:14 +0200 Subject: [PATCH 09/33] remove python 3.7 as min supported version --- .github/workflows/ci.yaml | 2 +- setup.cfg | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e774803dda7..a22750b3c19 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -38,7 +38,7 @@ jobs: matrix: os: ["ubuntu-latest", "macos-latest", "windows-latest"] # Bookend python versions - python-version: ["3.7", "3.9"] + python-version: ["3.8", "3.9"] steps: - uses: actions/checkout@v2 with: diff --git a/setup.cfg b/setup.cfg index aa8ca8df0ff..be74a20a087 100644 --- a/setup.cfg +++ b/setup.cfg @@ -64,7 +64,6 @@ classifiers = Intended Audience :: Science/Research Programming Language :: Python Programming Language :: Python :: 3 - Programming Language :: Python :: 3.7 Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 @@ -74,7 +73,7 @@ classifiers = packages = find: zip_safe = False # https://mypy.readthedocs.io/en/latest/installed_packages.html include_package_data = True -python_requires = >=3.7 +python_requires = >=3.8 install_requires = numpy >= 1.17 pandas >= 1.0 From 3c286ef5d07c9c413dfc1169b41cce3f94d2b884 Mon Sep 17 00:00:00 2001 From: Illviljan <14371165+Illviljan@users.noreply.github.com> Date: Sun, 24 Oct 2021 07:40:31 +0200 Subject: [PATCH 10/33] remove 3.7 from min_deps --- .../{py37-bare-minimum.yml => py38-bare-minimum.yml} | 2 +- .../{py37-min-all-deps.yml => py38-min-all-deps.yml} | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename ci/requirements/{py37-bare-minimum.yml => py38-bare-minimum.yml} (93%) rename ci/requirements/{py37-min-all-deps.yml => py38-min-all-deps.yml} (98%) diff --git a/ci/requirements/py37-bare-minimum.yml b/ci/requirements/py38-bare-minimum.yml similarity index 93% rename from ci/requirements/py37-bare-minimum.yml rename to ci/requirements/py38-bare-minimum.yml index 408cf76fdd6..0f56f98f139 100644 --- a/ci/requirements/py37-bare-minimum.yml +++ b/ci/requirements/py38-bare-minimum.yml @@ -3,7 +3,7 @@ channels: - conda-forge - nodefaults dependencies: - - python=3.7 + - python=3.8 - coveralls - pip - pytest diff --git a/ci/requirements/py37-min-all-deps.yml b/ci/requirements/py38-min-all-deps.yml similarity index 98% rename from ci/requirements/py37-min-all-deps.yml rename to ci/requirements/py38-min-all-deps.yml index 7c3230f87b0..4b7db3b0037 100644 --- a/ci/requirements/py37-min-all-deps.yml +++ b/ci/requirements/py38-min-all-deps.yml @@ -7,7 +7,7 @@ dependencies: # Run ci/min_deps_check.py to verify that this file respects the policy. # When upgrading python, numpy, or pandas, must also change # doc/installing.rst and setup.py. - - python=3.7 + - python=3.8 - boto3=1.13 - bottleneck=1.3 - cartopy=0.17 From 03719243e33f23bc5579ccfeb164be93c2ebe66d Mon Sep 17 00:00:00 2001 From: Illviljan <14371165+Illviljan@users.noreply.github.com> Date: Sun, 24 Oct 2021 07:42:56 +0200 Subject: [PATCH 11/33] Update ci-additional.yaml --- .github/workflows/ci-additional.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci-additional.yaml b/.github/workflows/ci-additional.yaml index 0b59e199b39..0c3fed2095e 100644 --- a/.github/workflows/ci-additional.yaml +++ b/.github/workflows/ci-additional.yaml @@ -40,8 +40,8 @@ jobs: os: ["ubuntu-latest"] env: [ - "py37-bare-minimum", - "py37-min-all-deps", + "py38-bare-minimum", + "py38-min-all-deps", "py38-all-but-dask", "py38-flaky", ] @@ -169,5 +169,5 @@ jobs: - name: minimum versions policy run: | mamba install -y pyyaml conda python-dateutil - python ci/min_deps_check.py ci/requirements/py37-bare-minimum.yml - python ci/min_deps_check.py ci/requirements/py37-min-all-deps.yml + python ci/min_deps_check.py ci/requirements/py38-bare-minimum.yml + python ci/min_deps_check.py ci/requirements/py38-min-all-deps.yml From 4f6454a22697ecff65fafa30c52d2c7d089df305 Mon Sep 17 00:00:00 2001 From: Illviljan <14371165+Illviljan@users.noreply.github.com> Date: Sun, 24 Oct 2021 08:34:32 +0200 Subject: [PATCH 12/33] test increasing dask --- ci/requirements/py38-min-all-deps.yml | 4 ++-- doc/getting-started-guide/installing.rst | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ci/requirements/py38-min-all-deps.yml b/ci/requirements/py38-min-all-deps.yml index 4b7db3b0037..283b34ea95c 100644 --- a/ci/requirements/py38-min-all-deps.yml +++ b/ci/requirements/py38-min-all-deps.yml @@ -15,8 +15,8 @@ dependencies: - cfgrib=0.9 - cftime=1.1 - coveralls - - dask=2.24 - - distributed=2.24 + - dask=2.30 + - distributed=2.30 - h5netcdf=0.8 - h5py=2.10 - hdf5=1.10 diff --git a/doc/getting-started-guide/installing.rst b/doc/getting-started-guide/installing.rst index 93738da9d9b..b2b98e9579c 100644 --- a/doc/getting-started-guide/installing.rst +++ b/doc/getting-started-guide/installing.rst @@ -6,7 +6,7 @@ Installation Required dependencies --------------------- -- Python (3.7 or later) +- Python (3.8 or later) - setuptools (40.4 or later) - `numpy `__ (1.17 or later) - `pandas `__ (1.0 or later) From 8f14e8b9add8a16997644cb2a98ee99ab0c08c18 Mon Sep 17 00:00:00 2001 From: Illviljan <14371165+Illviljan@users.noreply.github.com> Date: Sun, 24 Oct 2021 08:40:28 +0200 Subject: [PATCH 13/33] test increasing numba --- ci/requirements/py38-min-all-deps.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/requirements/py38-min-all-deps.yml b/ci/requirements/py38-min-all-deps.yml index 283b34ea95c..99213cdb483 100644 --- a/ci/requirements/py38-min-all-deps.yml +++ b/ci/requirements/py38-min-all-deps.yml @@ -29,7 +29,7 @@ dependencies: # (see https://github.com/Unidata/netcdf4-python/issues/1090) # bumping the netCDF4 version is currently blocked by #4491 - netcdf4=1.5.3 - - numba=0.49 + - numba=0.51 - numpy=1.17 - pandas=1.0 - pint=0.15 From 69ca3ddd1b8460595ad6a826927aaa8f17275ea8 Mon Sep 17 00:00:00 2001 From: Illviljan <14371165+Illviljan@users.noreply.github.com> Date: Sun, 24 Oct 2021 08:46:47 +0200 Subject: [PATCH 14/33] Update ci-additional.yaml --- .github/workflows/ci-additional.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci-additional.yaml b/.github/workflows/ci-additional.yaml index 0c3fed2095e..304feed2f16 100644 --- a/.github/workflows/ci-additional.yaml +++ b/.github/workflows/ci-additional.yaml @@ -75,7 +75,7 @@ jobs: mamba-version: "*" activate-environment: xarray-tests auto-update-conda: false - python-version: 3.8 + python-version: 3.9 use-only-tar-bz2: true - name: Install conda dependencies @@ -128,7 +128,7 @@ jobs: mamba-version: "*" activate-environment: xarray-tests auto-update-conda: false - python-version: "3.8" + python-version: "3.9" - name: Install conda dependencies run: | @@ -164,7 +164,7 @@ jobs: channel-priority: strict mamba-version: "*" auto-update-conda: false - python-version: "3.8" + python-version: "3.9" - name: minimum versions policy run: | From a60a74f98fcda9edad21bb3d2ab68053d8161707 Mon Sep 17 00:00:00 2001 From: Illviljan <14371165+Illviljan@users.noreply.github.com> Date: Tue, 26 Oct 2021 22:40:55 +0200 Subject: [PATCH 15/33] remove setuptools from CI --- ci/requirements/environment-windows.yml | 1 - ci/requirements/environment.yml | 1 - ci/requirements/py38-all-but-dask.yml | 1 - ci/requirements/py38-bare-minimum.yml | 1 - ci/requirements/py38-min-all-deps.yml | 1 - 5 files changed, 5 deletions(-) diff --git a/ci/requirements/environment-windows.yml b/ci/requirements/environment-windows.yml index 78ead40d5a2..bfdb5787388 100644 --- a/ci/requirements/environment-windows.yml +++ b/ci/requirements/environment-windows.yml @@ -36,7 +36,6 @@ dependencies: - rasterio - scipy - seaborn - - setuptools - sparse - toolz - zarr diff --git a/ci/requirements/environment.yml b/ci/requirements/environment.yml index f64ca3677cc..fb807959bbe 100644 --- a/ci/requirements/environment.yml +++ b/ci/requirements/environment.yml @@ -40,7 +40,6 @@ dependencies: - rasterio - scipy - seaborn - - setuptools - sparse - toolz - zarr diff --git a/ci/requirements/py38-all-but-dask.yml b/ci/requirements/py38-all-but-dask.yml index 3f82990f3b5..8feccea0b6e 100644 --- a/ci/requirements/py38-all-but-dask.yml +++ b/ci/requirements/py38-all-but-dask.yml @@ -36,7 +36,6 @@ dependencies: - rasterio - scipy - seaborn - - setuptools - sparse - toolz - zarr diff --git a/ci/requirements/py38-bare-minimum.yml b/ci/requirements/py38-bare-minimum.yml index 0f56f98f139..e877f163632 100644 --- a/ci/requirements/py38-bare-minimum.yml +++ b/ci/requirements/py38-bare-minimum.yml @@ -12,4 +12,3 @@ dependencies: - pytest-xdist - numpy=1.17 - pandas=1.0 - - setuptools=40.4 diff --git a/ci/requirements/py38-min-all-deps.yml b/ci/requirements/py38-min-all-deps.yml index 99213cdb483..2a31a23fce9 100644 --- a/ci/requirements/py38-min-all-deps.yml +++ b/ci/requirements/py38-min-all-deps.yml @@ -44,7 +44,6 @@ dependencies: - rasterio=1.1 - scipy=1.4 - seaborn=0.10 - - setuptools=40.4 - sparse=0.8 - toolz=0.10 - zarr=2.4 From f5124aebf9aeef4209c7db67b9e67a3604e96edb Mon Sep 17 00:00:00 2001 From: Illviljan <14371165+Illviljan@users.noreply.github.com> Date: Tue, 26 Oct 2021 22:55:58 +0200 Subject: [PATCH 16/33] undo dask/numba tests --- ci/requirements/py38-min-all-deps.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ci/requirements/py38-min-all-deps.yml b/ci/requirements/py38-min-all-deps.yml index 2a31a23fce9..b9fd9b9fc1e 100644 --- a/ci/requirements/py38-min-all-deps.yml +++ b/ci/requirements/py38-min-all-deps.yml @@ -15,8 +15,8 @@ dependencies: - cfgrib=0.9 - cftime=1.1 - coveralls - - dask=2.30 - - distributed=2.30 + - dask=2.24 + - distributed=2.24 - h5netcdf=0.8 - h5py=2.10 - hdf5=1.10 @@ -29,7 +29,7 @@ dependencies: # (see https://github.com/Unidata/netcdf4-python/issues/1090) # bumping the netCDF4 version is currently blocked by #4491 - netcdf4=1.5.3 - - numba=0.51 + - numba=0.49 - numpy=1.17 - pandas=1.0 - pint=0.15 From 28c5dfa1bd8025f72223d7e95ca6458c2499fc25 Mon Sep 17 00:00:00 2001 From: Illviljan <14371165+Illviljan@users.noreply.github.com> Date: Tue, 26 Oct 2021 23:30:23 +0200 Subject: [PATCH 17/33] Remove importlib_metadata --- setup.cfg | 1 - xarray/__init__.py | 11 +---------- xarray/backends/plugins.py | 6 ++---- 3 files changed, 3 insertions(+), 15 deletions(-) diff --git a/setup.cfg b/setup.cfg index ecc45af66bb..3f45c13e076 100644 --- a/setup.cfg +++ b/setup.cfg @@ -77,7 +77,6 @@ python_requires = >=3.8 install_requires = numpy >= 1.17 pandas >= 1.0 - importlib-metadata; python_version < '3.8' [options.extras_require] io = diff --git a/xarray/__init__.py b/xarray/__init__.py index 4698a9be4bb..9840e9917bd 100644 --- a/xarray/__init__.py +++ b/xarray/__init__.py @@ -28,16 +28,7 @@ from .util.print_versions import show_versions try: - try: - from importlib.metadata import PackageNotFoundError, version - except ImportError: - try: - from importlib_metadata import ( # type: ignore[no-redef] - PackageNotFoundError, - version, - ) - except ImportError: - raise + from importlib.metadata import PackageNotFoundError, version try: __version__ = version("xarray") diff --git a/xarray/backends/plugins.py b/xarray/backends/plugins.py index 3abcd04b0fe..754adee0062 100644 --- a/xarray/backends/plugins.py +++ b/xarray/backends/plugins.py @@ -93,10 +93,8 @@ def build_engines(pkg_entrypoints): @functools.lru_cache(maxsize=1) def list_engines(): - try: - from importlib.metadata import Distribution - except ImportError: - from importlib_metadata import Distribution + from importlib.metadata import Distribution + importlib_entrypoints = ( entry_point for entry_point in Distribution.from_name("xarray").entry_points From 2b3f4f222d7c0fe75a9b41b37e06e84e279fb574 Mon Sep 17 00:00:00 2001 From: Illviljan <14371165+Illviljan@users.noreply.github.com> Date: Wed, 27 Oct 2021 16:16:48 +0200 Subject: [PATCH 18/33] remove 3.7 compats --- xarray/core/options.py | 88 +++++++++++------------------------------- 1 file changed, 23 insertions(+), 65 deletions(-) diff --git a/xarray/core/options.py b/xarray/core/options.py index 14f77306316..dfc248e5e2d 100644 --- a/xarray/core/options.py +++ b/xarray/core/options.py @@ -1,75 +1,33 @@ import sys import warnings +from typing import TYPE_CHECKING, Literal, TypedDict, Union from .utils import FrozenDict -# TODO: Remove this check once python 3.7 is not supported: -if sys.version_info >= (3, 8): - from typing import TYPE_CHECKING, Literal, TypedDict, Union - - if TYPE_CHECKING: - try: - from matplotlib.colors import Colormap - except ImportError: - Colormap = str - - class T_Options(TypedDict): - arithmetic_join: Literal["inner", "outer", "left", "right", "exact"] - cmap_divergent: Union[str, "Colormap"] - cmap_sequential: Union[str, "Colormap"] - display_max_rows: int - display_style: Literal["text", "html"] - display_width: int - display_expand_attrs: Literal["default", True, False] - display_expand_coords: Literal["default", True, False] - display_expand_data_vars: Literal["default", True, False] - display_expand_data: Literal["default", True, False] - enable_cftimeindex: bool - file_cache_maxsize: int - keep_attrs: Literal["default", True, False] - warn_for_unclosed_files: bool - use_bottleneck: bool - - -else: - # See GH5624, this is a convoluted way to allow type-checking to use - # `TypedDict` and `Literal` without requiring typing_extensions as a - # required dependency to _run_ the code (it is required to type-check). - try: - from typing import TYPE_CHECKING, Union - - from typing_extensions import Literal, TypedDict - - if TYPE_CHECKING: - try: - from matplotlib.colors import Colormap - except ImportError: - Colormap = str - - class T_Options(TypedDict): - arithmetic_join: Literal["inner", "outer", "left", "right", "exact"] - cmap_divergent: Union[str, "Colormap"] - cmap_sequential: Union[str, "Colormap"] - display_max_rows: int - display_style: Literal["text", "html"] - display_width: int - display_expand_attrs: Literal["default", True, False] - display_expand_coords: Literal["default", True, False] - display_expand_data_vars: Literal["default", True, False] - display_expand_data: Literal["default", True, False] - enable_cftimeindex: bool - file_cache_maxsize: int - keep_attrs: Literal["default", True, False] - warn_for_unclosed_files: bool - use_bottleneck: bool +if TYPE_CHECKING: + try: + from matplotlib.colors import Colormap except ImportError: - from typing import TYPE_CHECKING, Any, Dict, Hashable - - if TYPE_CHECKING: - raise - else: - T_Options = Dict[Hashable, Any] + Colormap = str + + +class T_Options(TypedDict): + arithmetic_join: Literal["inner", "outer", "left", "right", "exact"] + cmap_divergent: Union[str, "Colormap"] + cmap_sequential: Union[str, "Colormap"] + display_max_rows: int + display_style: Literal["text", "html"] + display_width: int + display_expand_attrs: Literal["default", True, False] + display_expand_coords: Literal["default", True, False] + display_expand_data_vars: Literal["default", True, False] + display_expand_data: Literal["default", True, False] + enable_cftimeindex: bool + file_cache_maxsize: int + keep_attrs: Literal["default", True, False] + warn_for_unclosed_files: bool + use_bottleneck: bool OPTIONS: T_Options = { From 82dcdff64da4a019e8082b5b734b1a4070a83dad Mon Sep 17 00:00:00 2001 From: Illviljan <14371165+Illviljan@users.noreply.github.com> Date: Wed, 27 Oct 2021 16:22:20 +0200 Subject: [PATCH 19/33] Remove 3.7 compat --- xarray/core/npcompat.py | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/xarray/core/npcompat.py b/xarray/core/npcompat.py index 6e22c8cf0a4..182ce206027 100644 --- a/xarray/core/npcompat.py +++ b/xarray/core/npcompat.py @@ -39,19 +39,9 @@ from numpy.typing import ArrayLike, DTypeLike except ImportError: # fall back for numpy < 1.20, ArrayLike adapted from numpy.typing._array_like - if sys.version_info >= (3, 8): - from typing import Protocol + from typing import Protocol - HAVE_PROTOCOL = True - else: - try: - from typing_extensions import Protocol - except ImportError: - HAVE_PROTOCOL = False - else: - HAVE_PROTOCOL = True - - if TYPE_CHECKING or HAVE_PROTOCOL: + if TYPE_CHECKING: class _SupportsArray(Protocol): def __array__(self) -> np.ndarray: From 390927150e5b718d04fb4ebba8928ba5e8d14618 Mon Sep 17 00:00:00 2001 From: Illviljan <14371165+Illviljan@users.noreply.github.com> Date: Wed, 27 Oct 2021 17:45:51 +0200 Subject: [PATCH 20/33] remove sys --- xarray/core/npcompat.py | 1 - xarray/core/options.py | 1 - 2 files changed, 2 deletions(-) diff --git a/xarray/core/npcompat.py b/xarray/core/npcompat.py index 182ce206027..8d1e8cddb99 100644 --- a/xarray/core/npcompat.py +++ b/xarray/core/npcompat.py @@ -28,7 +28,6 @@ # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -import sys from distutils.version import LooseVersion from typing import TYPE_CHECKING, Any, Sequence, TypeVar, Union diff --git a/xarray/core/options.py b/xarray/core/options.py index dfc248e5e2d..564d6d5cded 100644 --- a/xarray/core/options.py +++ b/xarray/core/options.py @@ -1,4 +1,3 @@ -import sys import warnings from typing import TYPE_CHECKING, Literal, TypedDict, Union From c6a58713824d02b0a5a50b04e5045fb3c5b450d3 Mon Sep 17 00:00:00 2001 From: Illviljan <14371165+Illviljan@users.noreply.github.com> Date: Wed, 27 Oct 2021 22:51:23 +0200 Subject: [PATCH 21/33] Update options.py --- xarray/core/options.py | 1 - 1 file changed, 1 deletion(-) diff --git a/xarray/core/options.py b/xarray/core/options.py index 564d6d5cded..7ca09e06985 100644 --- a/xarray/core/options.py +++ b/xarray/core/options.py @@ -3,7 +3,6 @@ from .utils import FrozenDict - if TYPE_CHECKING: try: from matplotlib.colors import Colormap From 005a3fab8c6252daa88d9142dc90cfe138a91ef7 Mon Sep 17 00:00:00 2001 From: Illviljan <14371165+Illviljan@users.noreply.github.com> Date: Mon, 27 Dec 2021 01:31:45 +0100 Subject: [PATCH 22/33] Update whats-new.rst --- doc/whats-new.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/whats-new.rst b/doc/whats-new.rst index 1c4b49097a3..e179fa4f1b9 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -30,6 +30,10 @@ Breaking changes Deprecations ~~~~~~~~~~~~ +- Support for ``python 3.7`` has been dropped. + ``setuptools`` is no longer a dependency (:pull:`5892`). + By `Jimmy Westling `_. + Bug fixes ~~~~~~~~~ From 8619df7d806ed3900d2a091da1cb200836732af4 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 27 Dec 2021 00:33:09 +0000 Subject: [PATCH 23/33] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- doc/whats-new.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/whats-new.rst b/doc/whats-new.rst index e179fa4f1b9..7c851d4b273 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -30,7 +30,7 @@ Breaking changes Deprecations ~~~~~~~~~~~~ -- Support for ``python 3.7`` has been dropped. +- Support for ``python 3.7`` has been dropped. ``setuptools`` is no longer a dependency (:pull:`5892`). By `Jimmy Westling `_. From eb197d7b3b0527b8b84f99a1edaf17df65c91314 Mon Sep 17 00:00:00 2001 From: Illviljan <14371165+Illviljan@users.noreply.github.com> Date: Sat, 1 Jan 2022 23:48:03 +0100 Subject: [PATCH 24/33] Run flaky/all but dask with latest python version --- .github/workflows/ci-additional.yaml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci-additional.yaml b/.github/workflows/ci-additional.yaml index 31b63abfdc2..c21f1f60d70 100644 --- a/.github/workflows/ci-additional.yaml +++ b/.github/workflows/ci-additional.yaml @@ -40,10 +40,13 @@ jobs: os: ["ubuntu-latest"] env: [ + # Minimum python version: "py38-bare-minimum", "py38-min-all-deps", - "py38-all-but-dask", - "py38-flaky", + + # Latest python version: + "py39-all-but-dask", + "py39-flaky", ] steps: - uses: actions/checkout@v2 @@ -52,7 +55,7 @@ jobs: - name: Set environment variables run: | - if [[ ${{ matrix.env }} == "py38-flaky" ]] ; + if [[ ${{ matrix.env }} == "py39-flaky" ]] ; then echo "CONDA_ENV_FILE=ci/requirements/environment.yml" >> $GITHUB_ENV echo "PYTEST_EXTRA_FLAGS=--run-flaky --run-network-tests" >> $GITHUB_ENV From 3f54e82330353230a5e44bda883512011c95c402 Mon Sep 17 00:00:00 2001 From: Illviljan <14371165+Illviljan@users.noreply.github.com> Date: Sat, 1 Jan 2022 23:54:11 +0100 Subject: [PATCH 25/33] fix all_but_dask file as well --- .../{py38-all-but-dask.yml => py39-all-but-dask.yml} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename ci/requirements/{py38-all-but-dask.yml => py39-all-but-dask.yml} (97%) diff --git a/ci/requirements/py38-all-but-dask.yml b/ci/requirements/py39-all-but-dask.yml similarity index 97% rename from ci/requirements/py38-all-but-dask.yml rename to ci/requirements/py39-all-but-dask.yml index 111cddc14f8..21217e79c7c 100644 --- a/ci/requirements/py38-all-but-dask.yml +++ b/ci/requirements/py39-all-but-dask.yml @@ -3,7 +3,7 @@ channels: - conda-forge - nodefaults dependencies: - - python=3.8 + - python=3.9 - black - aiobotocore - boto3 From db992298545da39bdbe748625996ded25049fe15 Mon Sep 17 00:00:00 2001 From: Illviljan <14371165+Illviljan@users.noreply.github.com> Date: Tue, 4 Jan 2022 18:24:07 +0100 Subject: [PATCH 26/33] Update dataarray.py --- xarray/core/dataarray.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/xarray/core/dataarray.py b/xarray/core/dataarray.py index b8e63c9f2f7..7dba14cc188 100644 --- a/xarray/core/dataarray.py +++ b/xarray/core/dataarray.py @@ -11,6 +11,7 @@ Hashable, Iterable, List, + Literal, Mapping, Optional, Sequence, @@ -91,12 +92,6 @@ from .types import T_DataArray, T_Xarray -# TODO: Remove this check once python 3.7 is not supported: -if sys.version_info >= (3, 8): - from typing import Literal -else: - from typing_extensions import Literal - def _infer_coords_and_dims( shape, coords, dims From 262bd346875aaf4ef48921cc294dda3e75de5653 Mon Sep 17 00:00:00 2001 From: Illviljan <14371165+Illviljan@users.noreply.github.com> Date: Tue, 4 Jan 2022 18:30:57 +0100 Subject: [PATCH 27/33] Update dataarray.py --- xarray/core/dataarray.py | 1 - 1 file changed, 1 deletion(-) diff --git a/xarray/core/dataarray.py b/xarray/core/dataarray.py index 7dba14cc188..c982dab1085 100644 --- a/xarray/core/dataarray.py +++ b/xarray/core/dataarray.py @@ -1,7 +1,6 @@ from __future__ import annotations import datetime -import sys import warnings from typing import ( TYPE_CHECKING, From be4d2bd3fa97c5fa3fc960e47631449608db1a70 Mon Sep 17 00:00:00 2001 From: Illviljan <14371165+Illviljan@users.noreply.github.com> Date: Tue, 4 Jan 2022 21:49:50 +0100 Subject: [PATCH 28/33] Update doc/whats-new.rst Co-authored-by: keewis --- doc/whats-new.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/doc/whats-new.rst b/doc/whats-new.rst index 0fa8033025a..381e07d4174 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -40,8 +40,7 @@ Deprecations By `Tom Nicholas `_. -- Support for ``python 3.7`` has been dropped. - ``setuptools`` is no longer a dependency (:pull:`5892`). +- Support for ``python 3.7`` has been dropped. (:pull:`5892`) By `Jimmy Westling `_. - Coercing a dataset to bool, e.g. ``bool(ds)``, is being deprecated and will raise an From 2f3b6dae16e322df0ea848a18e65e7d9de235b2f Mon Sep 17 00:00:00 2001 From: Keewis Date: Wed, 5 Jan 2022 19:50:19 +0100 Subject: [PATCH 29/33] update the install guide --- doc/getting-started-guide/installing.rst | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/doc/getting-started-guide/installing.rst b/doc/getting-started-guide/installing.rst index 050e837f2e3..6f437a2dc4c 100644 --- a/doc/getting-started-guide/installing.rst +++ b/doc/getting-started-guide/installing.rst @@ -6,11 +6,9 @@ Installation Required dependencies --------------------- -- Python (3.7 or later) -- `importlib_metadata `__ (1.4 or later, Python 3.7 only) -- ``typing_extensions`` (3.7 or later, Python 3.7 only) -- `numpy `__ (1.17 or later) -- `pandas `__ (1.0 or later) +- Python (3.8 or later) +- `numpy `__ (1.18 or later) +- `pandas `__ (1.1 or later) .. _optional-dependencies: @@ -103,7 +101,7 @@ release is guaranteed to work. You can see the actual minimum tested versions: -``_ +``_ .. _installation-instructions: From b80d0dd3c87416dfa0c122ef3ddda592195d9c9f Mon Sep 17 00:00:00 2001 From: Keewis Date: Wed, 5 Jan 2022 19:51:50 +0100 Subject: [PATCH 30/33] remove py37 only dependencies --- setup.cfg | 2 -- 1 file changed, 2 deletions(-) diff --git a/setup.cfg b/setup.cfg index cd3125613d9..f9e0afa6445 100644 --- a/setup.cfg +++ b/setup.cfg @@ -77,8 +77,6 @@ python_requires = >=3.8 install_requires = numpy >= 1.18 pandas >= 1.1 - importlib-metadata; python_version < '3.8' - typing_extensions >= 3.7; python_version < '3.8' [options.extras_require] io = From ea3901a475f901bdff765667e22118818f21fa24 Mon Sep 17 00:00:00 2001 From: Keewis Date: Wed, 5 Jan 2022 20:00:16 +0100 Subject: [PATCH 31/33] don't install importlib-metadata and typing_extensions into min-deps envs --- ci/requirements/py38-bare-minimum.yml | 2 -- ci/requirements/py38-min-all-deps.yml | 2 -- 2 files changed, 4 deletions(-) diff --git a/ci/requirements/py38-bare-minimum.yml b/ci/requirements/py38-bare-minimum.yml index ae57f99e8fa..c6e3ac504a8 100644 --- a/ci/requirements/py38-bare-minimum.yml +++ b/ci/requirements/py38-bare-minimum.yml @@ -12,5 +12,3 @@ dependencies: - pytest-xdist - numpy=1.18 - pandas=1.1 - - typing_extensions=3.7 - - importlib-metadata=2.0 diff --git a/ci/requirements/py38-min-all-deps.yml b/ci/requirements/py38-min-all-deps.yml index d3828f3b0b3..b396ca79f38 100644 --- a/ci/requirements/py38-min-all-deps.yml +++ b/ci/requirements/py38-min-all-deps.yml @@ -24,7 +24,6 @@ dependencies: - hdf5=1.10 - hypothesis - iris=2.4 - - importlib-metadata=2.0 - lxml=4.6 # Optional dep of pydap - matplotlib-base=3.3 - nc-time-axis=1.2 @@ -49,7 +48,6 @@ dependencies: - seaborn=0.11 - sparse=0.11 - toolz=0.11 - - typing_extensions=3.7 - zarr=2.5 - pip: - numbagg==0.1 From 2499be1560629166f2df48b345a0e918e192b9fe Mon Sep 17 00:00:00 2001 From: Keewis Date: Wed, 5 Jan 2022 20:02:18 +0100 Subject: [PATCH 32/33] update the requirements file --- requirements.txt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/requirements.txt b/requirements.txt index 0fa83c8ccc1..729a3655125 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,5 @@ # it exists to let GitHub build the repository dependency graph # https://help.github.com/en/github/visualizing-repository-data-with-graphs/listing-the-packages-that-a-repository-depends-on -numpy >= 1.17 -pandas >= 1.0 -setuptools >= 40.4 -typing-extensions >= 3.7 +numpy >= 1.18 +pandas >= 1.1 From 729789a32bee71c8b825adce40d96feab7410d94 Mon Sep 17 00:00:00 2001 From: Keewis Date: Wed, 5 Jan 2022 21:45:49 +0100 Subject: [PATCH 33/33] add back the optional typing_extensions dependency --- ci/requirements/py38-min-all-deps.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/ci/requirements/py38-min-all-deps.yml b/ci/requirements/py38-min-all-deps.yml index b396ca79f38..a6459b92ccb 100644 --- a/ci/requirements/py38-min-all-deps.yml +++ b/ci/requirements/py38-min-all-deps.yml @@ -48,6 +48,7 @@ dependencies: - seaborn=0.11 - sparse=0.11 - toolz=0.11 + - typing_extensions=3.7 - zarr=2.5 - pip: - numbagg==0.1