diff --git a/.gitattributes b/.gitattributes index 97aa3f333..994bf8275 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1 @@ -neptune/_version.py export-subst +src/neptune/_version.py export-subst diff --git a/CHANGELOG.md b/CHANGELOG.md index 90d7e5eb6..b3a36a71e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ### Fixes - Update jsonschema requirement with explicit `format` specifier ([#1010](https://github.com/neptune-ai/neptune-client/pull/1010)) - Escape inputs to SQL in Artifact LocalFileHashStorage ([#1034](https://github.com/neptune-ai/neptune-client/pull/1034)) +- Version checking with importlib and versioneer config update ([#1048](https://github.com/neptune-ai/neptune-client/pull/1048)) ### Changes - More consistent and strict way of git repository, source files and entrypoint detection ([#1007](https://github.com/neptune-ai/neptune-client/pull/1007)) diff --git a/requirements.txt b/requirements.txt index 648c21a8c..afd8ee42c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -17,3 +17,4 @@ dataclasses>=0.6; python_version<"3.7" swagger-spec-validator>=2.7.4 psutil jsonschema[format]<4.0.0 +importlib-metadata<4; python_version<"3.8.0" diff --git a/src/neptune/__init__.py b/src/neptune/__init__.py index a116ed1d5..4419cfdbb 100644 --- a/src/neptune/__init__.py +++ b/src/neptune/__init__.py @@ -13,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # -from neptune._version import get_versions from neptune.legacy import ( ANONYMOUS, ANONYMOUS_API_TOKEN, @@ -46,5 +45,4 @@ set_property, stop, ) - -__version__ = get_versions()["version"] +from neptune.version import __version__ diff --git a/src/neptune/_version.py b/src/neptune/_version.py index 120b32dec..a1a0d21bb 100644 --- a/src/neptune/_version.py +++ b/src/neptune/_version.py @@ -44,7 +44,8 @@ def get_config(): cfg.style = "pep440" cfg.tag_prefix = "" cfg.parentdir_prefix = "" - cfg.versionfile_source = "neptune/_version.py" + cfg.versionfile_source = "src/neptune/_version.py" + cfg.versionfile_build = "neptune/_version.py" cfg.verbose = False return cfg diff --git a/src/neptune/new/version.py b/src/neptune/new/version.py index 1928c86f9..c1e0c0722 100644 --- a/src/neptune/new/version.py +++ b/src/neptune/new/version.py @@ -13,9 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # -from packaging import version +from packaging.version import parse -from neptune._version import get_versions +from neptune.version import __version__ -version = version.parse(get_versions()["version"]) -del get_versions +version = parse(__version__) diff --git a/src/neptune/version.py b/src/neptune/version.py new file mode 100644 index 000000000..881f5c138 --- /dev/null +++ b/src/neptune/version.py @@ -0,0 +1,33 @@ +# +# Copyright (c) 2022, Neptune Labs Sp. z o.o. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import sys + +if sys.version_info >= (3, 8): + from importlib.metadata import ( + PackageNotFoundError, + version, + ) +else: + from importlib_metadata import ( + PackageNotFoundError, + version, + ) + +try: + __version__ = version("neptune-client") +except PackageNotFoundError: + # package is not installed + pass