Skip to content

Commit

Permalink
Automatically read version number from git (#97)
Browse files Browse the repository at this point in the history
* Automatically read version number from git
  • Loading branch information
Jegp authored Apr 23, 2024
1 parent 62f07e2 commit 5815874
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
11 changes: 9 additions & 2 deletions nir/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,18 @@
Documentation: https://nnir.readthedocs.io
"""

from importlib.metadata import version as metadata_version, PackageNotFoundError

try:
__version__ = version = metadata_version("nir")
del metadata_version
except PackageNotFoundError:
# package is not installed
pass

from . import ir
from .ir import * # noqa: F403
from .ir import typing # noqa: F401
from .serialization import read, write

__all__ = ir.__all__ + ["read", "write"]

version = __version__ = "1.0.1"
4 changes: 3 additions & 1 deletion nir/serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ def read_node(node: Any) -> nir.NIRNode:
r=node["r"][()], v_threshold=node["v_threshold"][()], **_read_metadata(node)
)
elif node["type"][()] == b"Input":
return nir.Input(input_type={"input": node["shape"][()]}, **_read_metadata(node))
return nir.Input(
input_type={"input": node["shape"][()]}, **_read_metadata(node)
)
elif node["type"][()] == b"LI":
return nir.LI(
tau=node["tau"][()],
Expand Down
10 changes: 6 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
[build-system]
requires = ["setuptools"]
requires = [
"setuptools>=60",
"setuptools-scm>=8.0"
]

[project]
name = "nir"
Expand Down Expand Up @@ -37,13 +40,12 @@ homepage = "https://github.com/neuromorphs/nir"
[tool.pytest.ini_options]
testpaths = ["tests"]

[tool.setuptools.dynamic]
version = {attr = "nir.__version__"}
[tool.setuptools_scm]

[tool.setuptools.packages]
find = {}

[tool.ruff]
line-length = 100
per-file-ignores = {"docs/conf.py" = ["E402"]}
exclude = ["paper/"]
exclude = ["paper/"]

0 comments on commit 5815874

Please sign in to comment.