diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bd5cb928..59c27058 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,7 +10,7 @@ jobs: with: envs: | - linux: py39 - - macos: py38 + - macos: py311 - linux: py310-devdeps - windows: py38-oldestdeps coverage: 'codecov' diff --git a/changelog/218.bugfix.rst b/changelog/218.bugfix.rst new file mode 100644 index 00000000..d1f69b2d --- /dev/null +++ b/changelog/218.bugfix.rst @@ -0,0 +1 @@ +Add support for Python 3.11 diff --git a/dkist/dataset/dataset.py b/dkist/dataset/dataset.py index b094d77c..529aa278 100644 --- a/dkist/dataset/dataset.py +++ b/dkist/dataset/dataset.py @@ -1,6 +1,11 @@ +import sys from pathlib import Path from textwrap import dedent -from importlib import resources + +if sys.version_info < (3, 9): + import importlib_resources +else: + import importlib.resources as importlib_resources from jsonschema.exceptions import ValidationError @@ -188,7 +193,7 @@ def from_asdf(cls, filepath): filepath = Path(filepath).expanduser() base_path = filepath.parent try: - with resources.path("dkist.io", "level_1_dataset_schema.yaml") as schema_path: + with importlib_resources.as_file(importlib_resources.files("dkist.io") / "level_1_dataset_schema.yaml") as schema_path: with asdf.open(filepath, custom_schema=schema_path.as_posix(), lazy_load=False, copy_arrays=True) as ff: ds = ff.tree['dataset'] diff --git a/dkist/io/asdf/tests/test_dataset.py b/dkist/io/asdf/tests/test_dataset.py index 18a2e2dc..90658d46 100644 --- a/dkist/io/asdf/tests/test_dataset.py +++ b/dkist/io/asdf/tests/test_dataset.py @@ -1,5 +1,10 @@ +import sys from pathlib import Path -from importlib import resources + +if sys.version_info < (3, 9): + import importlib_resources +else: + import importlib.resources as importlib_resources import numpy as np import pytest @@ -101,7 +106,7 @@ def test_asdf_tags(dataset, tmp_path): indirect=True) def test_save_dataset_with_file_schema(tagobj, tmpdir): tree = {'dataset': tagobj} - with resources.path("dkist.io", "level_1_dataset_schema.yaml") as schema_path: + with importlib_resources.as_file(importlib_resources.files("dkist.io") / "level_1_dataset_schema.yaml") as schema_path: with asdf.AsdfFile(tree, custom_schema=schema_path.as_posix()) as afile: afile.write_to(Path(tmpdir / "test.asdf")) @@ -115,7 +120,7 @@ def test_read_all_schema_versions(asdf_file): This test validates that we can successfully read a full and valid Dataset object from files with all versions of the dataset schema. """ - with resources.path("dkist.io", "level_1_dataset_schema.yaml") as schema_path: + with importlib_resources.as_file(importlib_resources.files("dkist.io") / "level_1_dataset_schema.yaml") as schema_path: with asdf.open(asdf_file) as afile: dataset = afile["dataset"] dataset.files.basepath = rootdir / "EIT" diff --git a/dkist/net/client.py b/dkist/net/client.py index 8ad58996..ab7a4115 100644 --- a/dkist/net/client.py +++ b/dkist/net/client.py @@ -1,5 +1,4 @@ import os -import cgi import json import urllib.parse import urllib.request @@ -19,6 +18,7 @@ from sunpy.net import attrs as sattrs from sunpy.net.base_client import (BaseClient, QueryResponseRow, QueryResponseTable, convert_row_to_table) +from sunpy.util.net import parse_header from dkist.utils.inventory import INVENTORY_KEY_MAP @@ -170,7 +170,7 @@ def _make_filename(path: os.PathLike, row: QueryResponseRow, if resp: cdheader = resp.headers.get("Content-Disposition", None) if cdheader: - _, params = cgi.parse_header(cdheader) + _, params = parse_header(cdheader) name = params.get('filename', "") return str(path).format(file=name, **row.response_block_map) diff --git a/setup.cfg b/setup.cfg index e2a85049..ded6c5b0 100644 --- a/setup.cfg +++ b/setup.cfg @@ -31,9 +31,10 @@ install_requires = gwcs>=0.18.0 matplotlib>=3.1 ndcube[plotting,reproject]>=2.0 - numpy>=1.17 + numpy>=1.21 parfive[ftp]>=1.3 sunpy[net,asdf]>=4 + importlib-resources; python_version<"3.9" setup_requires = setuptools_scm [options.extras_require] @@ -115,6 +116,8 @@ filterwarnings = ignore:ASDF functionality for astropy is being moved out of the astropy package to the new asdf-astropy package ignore:FLIP_TOP_BOTTOM is deprecated and will be removed in Pillow.* ignore::ResourceWarning + # Zeep relies on deprecated cgi in Python 3.11 + ignore:'cgi' is deprecated and slated for removal in Python 3.13:DeprecationWarning:zeep.utils # Oldestdeps below here ignore:`np.float` is a deprecated alias for the builtin `float`. To silence this warning, use `float` by itself.::dask.array ignore:leap-second auto-update failed due to the following exception diff --git a/tox.ini b/tox.ini index 1f090fed..b063ed3f 100644 --- a/tox.ini +++ b/tox.ini @@ -45,9 +45,9 @@ deps = oldestdeps: gwcs<0.19 oldestdeps: matplotlib<3.3 oldestdeps: ndcube<2.1 - oldestdeps: numpy<1.19 + oldestdeps: numpy<1.22 oldestdeps: parfive[ftp]<1.3 - oldestdeps: sunpy[net,asdf]<4.0.1 + oldestdeps: sunpy[net,asdf]<4.0.8 # py3.11 support added in .7 oldestdeps: setuptools<60 # Use older setuptools to prevent distutils warning [testenv:build_docs]