Skip to content

Commit

Permalink
Don't use setuptools_scm if .git does not exists
Browse files Browse the repository at this point in the history
  • Loading branch information
hoxbro committed Nov 7, 2023
1 parent 38ed7aa commit 528fa90
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions holonote/__init__.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
from __future__ import annotations

import os

from . import annotate, editor # noqa: F401

# Define '__version__'
try:
# 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
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__)
except (ImportError, LookupError):
# 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:
from ._version import __version__
Expand Down

0 comments on commit 528fa90

Please sign in to comment.