Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: modernize #5

Merged
merged 10 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
ENH: dynamic versioning
  • Loading branch information
jotelha committed Jul 4, 2024
commit 6db6144797716794f2d5a0ebfde1586bbe97f506
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@
env
build
dist

dtool/version.py
25 changes: 24 additions & 1 deletion dtool/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
"""dtool package."""

__version__ = "3.26.2"
import logging

logger = logging.getLogger(__name__)

# workaround for diverging python versions:
try:
from importlib.metadata import version, PackageNotFoundError
logger.debug("imported version, PackageNotFoundError from importlib.metadata")
except ModuleNotFoundError:
from importlib_metadata import version, PackageNotFoundError
logger.debug("imported version, PackageNotFoundError from importlib_metadata")

# first, try to determine dynamic version at runtime
try:
__version__ = version(__name__)
logger.debug("Determined version %s via importlib_metadata.version", __version__)
except PackageNotFoundError:
# if that fails, check for static version file written by setuptools_scm
try:
from .version import version as __version__
logger.debug("Determined version %s from autogenerated dtool/version.py", __version__)
except Exception as e:
logger.debug("All efforts to determine version failed: %s", e)
__version__ = None