Skip to content

Commit

Permalink
Add separate version variable and module, use PEP484-compliant exports
Browse files Browse the repository at this point in the history
This is the best practice mentioned in the `setuptools_scm` docs, see
https://setuptools-scm.readthedocs.io/en/latest/usage/#version-at-runtime.
  • Loading branch information
nicholasjng committed Oct 31, 2023
1 parent 33fcee2 commit ab7ecc0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 37 deletions.
53 changes: 16 additions & 37 deletions bindings/python/google_benchmark/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,44 +32,23 @@ def my_benchmark(state):

from google_benchmark import _benchmark
from google_benchmark._benchmark import (
Counter,
State,
kMicrosecond,
kMillisecond,
kNanosecond,
kSecond,
o1,
oAuto,
oLambda,
oLogN,
oN,
oNCubed,
oNLogN,
oNone,
oNSquared,
Counter as Counter,
State as State,
kMicrosecond as kMicrosecond,
kMillisecond as kMillisecond,
kNanosecond as kNanosecond,
kSecond as kSecond,
o1 as o1,
oAuto as oAuto,
oLambda as oLambda,
oLogN as oLogN,
oN as oN,
oNCubed as oNCubed,
oNLogN as oNLogN,
oNone as oNone,
oNSquared as oNSquared,
)

__all__ = [
"register",
"main",
"Counter",
"kNanosecond",
"kMicrosecond",
"kMillisecond",
"kSecond",
"oNone",
"o1",
"oN",
"oNSquared",
"oNCubed",
"oLogN",
"oNLogN",
"oAuto",
"oLambda",
"State",
]

__version__ = "1.8.3"
from google_benchmark.version import __version__ as __version__


class __OptionMaker:
Expand Down
7 changes: 7 additions & 0 deletions bindings/python/google_benchmark/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from importlib.metadata import version, PackageNotFoundError

try:
__version__ = version("google-benchmark")
except PackageNotFoundError:
# package is not installed
pass

0 comments on commit ab7ecc0

Please sign in to comment.