Skip to content

Commit 5a1e9e8

Browse files
committed
Make versioningit write version to file; make setup.py read version as fallback
1 parent afe9a91 commit 5a1e9e8

File tree

5 files changed

+17
-10
lines changed

5 files changed

+17
-10
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ _build/
88
build/
99
dist/
1010
.vscode/
11+
_version.py

heudiconv/__init__.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,7 @@
22
import logging
33
import os
44
from .info import __packagename__
5-
6-
try:
7-
from importlib.metadata import version
8-
except ImportError:
9-
from importlib_metadata import version
10-
11-
__version__ = version(__name__)
5+
from ._version import __version__
126

137
# Rudimentary logging support.
148
lgr = logging.getLogger(__name__)

heudiconv/info.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
'dcmstack>=0.8',
2929
'etelemetry',
3030
'filelock>=3.0.12',
31-
'importlib-metadata; python_version < "3.8"',
3231
]
3332

3433
TESTS_REQUIRES = [

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ requires = [
66
]
77
build-backend = "setuptools.build_meta"
88

9-
[tool.versioningit]
9+
[tool.versioningit.write]
10+
file = "heudiconv/_version.py"

setup.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,17 @@ def main():
2121
with open(info_file) as infofile:
2222
exec(infofile.read(), globals(), ldict)
2323

24+
try:
25+
import versioningit
26+
except ImportError:
27+
# versioningit isn't installed; assume we're building a Debian package
28+
# from an sdist on an older Debian that doesn't support pybuild
29+
vglobals = {}
30+
with open(op.join(op.dirname(__file__), "heudiconv", "_version.py")) as fp:
31+
exec(fp.read(), vglobals)
32+
kwargs = {"version": vglobals["__version__"]}
33+
else:
34+
kwargs = {}
2435

2536
def findsome(subdir, extensions):
2637
"""Find files under subdir having specified extensions
@@ -58,7 +69,8 @@ def findsome(subdir, extensions):
5869
op.join('data', '*.dcm'),
5970
op.join('data', '*', '*.dcm')
6071
],
61-
}
72+
},
73+
**kwargs,
6274
)
6375

6476

0 commit comments

Comments
 (0)