benchmark/bindings/python/google_benchmark/version.py
Nicholas Junge 3623765dd3
Add setuptools_scm for dynamic zero-config Python versioning (#1690)
* Add `setuptools_scm` for dynamic zero-config Python versioning

This removes the need for manually bumping versions in the Python
bindings.

For the wheel uploads, the correct semver version is inferred in the case
of tagged commits, which is exactly the case in GitHub CI.

The docs were updated to reflect the changes in the release workflow.

* Add separate version variable and module, use PEP484-compliant exports

This is the best practice mentioned in the `setuptools_scm` docs, see
https://setuptools-scm.readthedocs.io/en/latest/usage/#version-at-runtime.
2023-11-01 09:48:01 +00:00

8 lines
182 B
Python

from importlib.metadata import PackageNotFoundError, version
try:
__version__ = version("google-benchmark")
except PackageNotFoundError:
# package is not installed
pass