-
-
Notifications
You must be signed in to change notification settings - Fork 689
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
25 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Move ``_package_version`` to travertino |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,25 @@ | ||
try: | ||
# Read version from SCM metadata | ||
# This will only exist in a development environment | ||
from setuptools_scm import get_version | ||
def _package_version(file, name): | ||
try: | ||
# Read version from SCM metadata | ||
# This will only exist in a development environment | ||
from setuptools_scm import get_version | ||
|
||
# Excluded from coverage because a pure test environment (such as the one | ||
# used by tox in CI) won't have setuptools_scm | ||
__version__ = get_version("../../..", relative_to=__file__) # pragma: no cover | ||
except (ModuleNotFoundError, LookupError): | ||
# If setuptools_scm isn't in the environment, the call to import will fail. | ||
# If it *is* in the environment, but the code isn't a git checkout (e.g., | ||
# it's been pip installed non-editable) the call to get_version() will fail. | ||
# If either of these occurs, read version from the installer metadata. | ||
# Excluded from coverage because a pure test environment (such as the one | ||
# used by tox in CI) won't have setuptools_scm | ||
return get_version(root="../../..", relative_to=file) # pragma: no cover | ||
except ( | ||
ModuleNotFoundError, | ||
LookupError, | ||
): # pragma: no-cover-if-missing-setuptools_scm | ||
# If setuptools_scm isn't in the environment, the call to import will fail. | ||
# If it *is* in the environment, but the code isn't a git checkout (e.g., | ||
# it's been pip installed non-editable) the call to get_version() will fail. | ||
# If either of these occurs, read version from the installer metadata. | ||
import importlib.metadata | ||
|
||
from importlib.metadata import version | ||
# The Toga package names as defined in pyproject.toml all use dashes. | ||
package = "toga-core" if name == "toga" else name.replace("_", "-") | ||
return importlib.metadata.version(package) | ||
|
||
__version__ = version("travertino") | ||
|
||
__version__ = _package_version(__file__, __name__) |