Skip to content

Commit

Permalink
add __version.py
Browse files Browse the repository at this point in the history
  • Loading branch information
hoxbro committed Jun 21, 2024
1 parent f2727b2 commit d593b21
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 13 deletions.
15 changes: 2 additions & 13 deletions geoviews/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from functools import partial

import param
from holoviews import (
Cycle,
Dimension,
Expand All @@ -23,12 +22,8 @@
save,
)

from . import (
data,
feature,
plotting,
tile_sources,
)
from . import data, feature, plotting, tile_sources
from .__version import __version__
from ._warnings import GeoviewsDeprecationWarning, GeoviewsUserWarning
from .element import (
RGB,
Expand Down Expand Up @@ -60,12 +55,6 @@
)
from .util import from_xarray

__version__ = str(
param.version.Version(
fpath=__file__, archive_commit="$Format:%h$", reponame="geoviews"
)
)

__all__ = (
"Contours",
"Cycle",
Expand Down
44 changes: 44 additions & 0 deletions geoviews/__version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
"""Define the package version.
Called __version.py as setuptools_scm will create a _version.py
"""

import os.path

PACKAGE = "geoviews"

try:
# For performance reasons on imports, avoid importing setuptools_scm
# if not in a .git folder
if os.path.exists(os.path.join(os.path.dirname(__file__), "..", ".git")):
# If setuptools_scm is installed (e.g. in a development environment with
# an editable install), then use it to determine the version dynamically.
from setuptools_scm import get_version

# This will fail with LookupError if the package is not installed in
# editable mode or if Git is not installed.
__version__ = get_version(root="..", relative_to=__file__)
else:
raise FileNotFoundError
except (ImportError, LookupError, FileNotFoundError):
# As a fallback, use the version that is hard-coded in the file.
try:
# __version__ was added in _version in setuptools-scm 7.0.0, we rely on
# the hopefully stable version variable.
from ._version import version as __version__
except (ModuleNotFoundError, ImportError):
# Either _version doesn't exist (ModuleNotFoundError) or version isn't
# in _version (ImportError). ModuleNotFoundError is a subclass of
# ImportError, let's be explicit anyway.

# Try something else:
from importlib.metadata import PackageNotFoundError, version

try:
__version__ = version(PACKAGE)
except PackageNotFoundError:
# The user is probably trying to run this without having installed
# the package.
__version__ = "0.0.0+unknown"

__all__ = ("__version__",)

0 comments on commit d593b21

Please sign in to comment.