From 92a802225ab87e4479b09e27163c5641f51609b3 Mon Sep 17 00:00:00 2001 From: Harrison Cook Date: Fri, 25 Oct 2024 09:55:06 +0000 Subject: [PATCH 1/2] Fix __version__ import - Use standard try-except --- CHANGELOG.md | 1 + src/anemoi/datasets/__init__.py | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ce17238e..642ccf5e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ Keep it human-readable, your future self will thank you! - Remove upstream dependencies from downstream-ci workflow (temporary) (#83) - ci: pin python versions to 3.9 ... 3.12 for checks (#93) +- Fix `__version__` import in init ## [0.5.7](https://github.com/ecmwf/anemoi-datasets/compare/0.5.6...0.5.7) - 2024-10-09 diff --git a/src/anemoi/datasets/__init__.py b/src/anemoi/datasets/__init__.py index 36f95cdd..f89fc476 100644 --- a/src/anemoi/datasets/__init__.py +++ b/src/anemoi/datasets/__init__.py @@ -5,15 +5,21 @@ # granted to it by virtue of its status as an intergovernmental organisation # nor does it submit to any jurisdiction. -from ._version import __version__ from .data import MissingDateError from .data import add_dataset_path from .data import add_named_dataset from .data import list_dataset_names from .data import open_dataset +try: + # NOTE: the `_version.py` file must not be present in the git repository + # as it is generated by setuptools at install time + from ._version import __version__ # type: ignore +except ImportError: # pragma: no cover + # Local copy or not installed with setuptools + __version__ = "999" + __all__ = [ - "__version__", "add_dataset_path", "add_named_dataset", "list_dataset_names", From 05717ee4f0e3536c5b21e2c9d3433b7f7cb933da Mon Sep 17 00:00:00 2001 From: Florian Pinault Date: Fri, 25 Oct 2024 10:41:33 +0000 Subject: [PATCH 2/2] fix shebang --- tools/make-sample-dataset.py | 1 + tools/upload-sample-dataset.py | 1 + 2 files changed, 2 insertions(+) diff --git a/tools/make-sample-dataset.py b/tools/make-sample-dataset.py index 990d4364..27222108 100755 --- a/tools/make-sample-dataset.py +++ b/tools/make-sample-dataset.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # (C) Copyright 2024 Anemoi contributors. # # This software is licensed under the terms of the Apache Licence Version 2.0 diff --git a/tools/upload-sample-dataset.py b/tools/upload-sample-dataset.py index 7678480b..586f7fdf 100755 --- a/tools/upload-sample-dataset.py +++ b/tools/upload-sample-dataset.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # (C) Copyright 2024 Anemoi contributors. # # This software is licensed under the terms of the Apache Licence Version 2.0