diff --git a/CHANGELOG.md b/CHANGELOG.md index 243b284..73643a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 0.1.5 - 2024-11-04 + +* Fix `ImportError` with Python >= 3.13 + ## 0.1.4 - 2024-10-21 * Add `--skip` options to `earthkit-dateseq previous/next` diff --git a/pyproject.toml b/pyproject.toml index 9970c12..eb861a1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "earthkit-time" -version = "0.1.4" +version = "0.1.5" requires-python = ">= 3.8" description = "Date and time manipulation routines for the use of weather data" license = {file = "LICENSE"} diff --git a/src/earthkit/time/data/__init__.py b/src/earthkit/time/data/__init__.py index 6733e67..970d0e1 100644 --- a/src/earthkit/time/data/__init__.py +++ b/src/earthkit/time/data/__init__.py @@ -2,10 +2,14 @@ import os import pathlib from importlib import resources -from typing import Optional, TextIO, Tuple +import types +from typing import Optional, TextIO, Tuple, Union import yaml +# importlib.resources.Packages is removed from Python >= 3.13 +Package = Union[types.ModuleType, str] + PACKAGE = "earthkit.time.data" @@ -17,7 +21,7 @@ def _extract_package(path: str) -> Tuple[str, str]: return (PACKAGE + "." + ".".join(parts[:-1])), parts[-1] -def _is_resource(package: resources.Package, name: str) -> bool: +def _is_resource(package: Package, name: str) -> bool: if hasattr(resources, "files"): # Python >= 3.9 return resources.files(package).joinpath(name).is_file() else: @@ -25,8 +29,8 @@ def _is_resource(package: resources.Package, name: str) -> bool: def _open_text( - package: resources.Package, - resource: resources.Resource, + package: Package, + resource: str, encoding: str = "utf-8", errors: str = "strict", ) -> TextIO: