File size: 624 Bytes
44facea 4f9da36 44facea 4f9da36 44facea | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | def _get_version():
"""Get version from package metadata (generated from pyproject.toml during installation)"""
try:
from importlib.metadata import version, PackageNotFoundError
return version('pyment')
except PackageNotFoundError:
import os
import tomli
pyproject_path = os.path.join(
os.path.dirname(__file__), os.pardir, 'pyproject.toml'
)
if os.path.exists(pyproject_path):
with open(pyproject_path, 'rb') as f:
data = tomli.load(f)
return data['project']['version']
__version__ = _get_version()
|