Skip to content

Commit e7b3c4f

Browse files
authored
Add __version__ property. (#543)
1 parent a014540 commit e7b3c4f

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

larq_compute_engine/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
from larq_compute_engine.mlir.python.converter import convert_keras_model
22
from larq_compute_engine.tflite.python import interpreter as testing
33

4+
try:
5+
from importlib import metadata # type: ignore
6+
except ImportError:
7+
# Running on pre-3.8 Python; use importlib-metadata package
8+
import importlib_metadata as metadata # type: ignore
9+
10+
__version__ = metadata.version("larq_compute_engine")
11+
412
__all__ = ["convert_keras_model", "testing"]

larq_compute_engine/mlir/python/converter_test.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import larq_zoo as lqz
66
from tensorflow.python.eager import context
77

8+
sys.modules["importlib.metadata"] = mock.MagicMock()
9+
sys.modules["importlib_metadata"] = mock.MagicMock()
810
sys.modules["larq_compute_engine.mlir._graphdef_tfl_flatbuffer"] = mock.MagicMock()
911
sys.modules[
1012
"larq_compute_engine.tflite.python.interpreter_wrapper_lite"

setup.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,12 @@ def has_ext_modules(self):
3030
packages=find_packages(),
3131
ext_modules=ext_modules,
3232
url="https://larq.dev/",
33-
install_requires=["flatbuffers>=1.12", "packaging>=19", "tqdm>=4"],
33+
install_requires=[
34+
"flatbuffers>=1.12",
35+
"packaging>=19",
36+
"tqdm>=4",
37+
"importlib-metadata ~= 2.0 ; python_version<'3.8'",
38+
],
3439
extras_require={
3540
"tensorflow": ["tensorflow>=1.14"],
3641
"tensorflow_gpu": ["tensorflow-gpu>=1.14"],

0 commit comments

Comments
 (0)