Skip to content

Commit 23a3edd

Browse files
authored
Include __version__ at runtime (#176)
This PR adds a `__version__` attribute to the top level module
1 parent df846c7 commit 23a3edd

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

python/acquire/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,17 @@
99
Tuple,
1010
Union,
1111
)
12-
12+
from importlib.metadata import version, PackageNotFoundError
1313
import numpy.typing as npt
1414

1515
from . import acquire
1616
from .acquire import *
1717

18+
try:
19+
__version__ = version("acquire-imaging")
20+
except PackageNotFoundError:
21+
__version__ = "uninstalled"
22+
1823
__doc__ = acquire.__doc__
1924

2025
import logging

python/acquire/__init__.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import napari # type: ignore
44

55
from .acquire import Runtime, Properties
66

7+
__version__: str
8+
79
def setup(
810
runtime: Runtime,
911
camera: Union[str, List[str]] = ...,

tests/test_basic.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ def runtime():
1818
yield acquire.Runtime()
1919

2020

21+
def test_version():
22+
assert isinstance(acquire.__version__, str)
23+
# this will fail if pip install -e . has not been run
24+
# so feel free to remove this line if it's not what you want to test
25+
assert acquire.__version__ != "uninstalled"
26+
27+
2128
def test_set():
2229
t = Trigger()
2330
assert not t.enable

0 commit comments

Comments
 (0)