Skip to content

Commit

Permalink
Version checking with importlib and versioneer config update (#1048)
Browse files Browse the repository at this point in the history
  • Loading branch information
Raalsky committed Oct 24, 2022
1 parent 9a0e977 commit 29f21df
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
@@ -1 +1 @@
neptune/_version.py export-subst
src/neptune/_version.py export-subst
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -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))
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Expand Up @@ -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"
4 changes: 1 addition & 3 deletions src/neptune/__init__.py
Expand Up @@ -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,
Expand Down Expand Up @@ -46,5 +45,4 @@
set_property,
stop,
)

__version__ = get_versions()["version"]
from neptune.version import __version__
3 changes: 2 additions & 1 deletion src/neptune/_version.py
Expand Up @@ -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

Expand Down
7 changes: 3 additions & 4 deletions src/neptune/new/version.py
Expand Up @@ -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__)
33 changes: 33 additions & 0 deletions 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

0 comments on commit 29f21df

Please sign in to comment.