Skip to content

Commit 13bab97

Browse files
committed
FIX: Patch version for smriprep-docker
1 parent c72116a commit 13bab97

File tree

3 files changed

+44
-6
lines changed

3 files changed

+44
-6
lines changed

wrapper/pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
requires = ["setuptools", "setuptools_scm"]
3+
build-backend = "setuptools.build_meta"

wrapper/setup.cfg

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
[metadata]
2-
version = attr: smriprep_docker.__version__
32
url = https://github.com/nipreps/smriprep
43
author = The NiPreps developers
54
author_email = [email protected]

wrapper/setup.py

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,51 @@
1-
#!/usr/bin/env python
21
import sys
2+
33
from setuptools import setup
4+
from setuptools.command.build_py import build_py
5+
from setuptools.command.sdist import sdist
6+
from setuptools_scm import get_version
47

58
# Give setuptools a hint to complain if it's too old a version
69
# 30.3.0 allows us to put most metadata in setup.cfg
710
# Should match pyproject.toml
811
# Not going to help us much without numpy or new pip, but gives us a shot
9-
SETUP_REQUIRES = ["setuptools >= 30.3.0"]
12+
SETUP_REQUIRES = ['setuptools >= 30.3.0']
1013
# This enables setuptools to install wheel on-the-fly
11-
SETUP_REQUIRES += ["wheel"] if "bdist_wheel" in sys.argv else []
14+
SETUP_REQUIRES += ['wheel'] if 'bdist_wheel' in sys.argv else []
15+
16+
17+
VERSION = get_version(root='..', relative_to=__file__)
18+
19+
20+
def update_version(target_file, version):
21+
with open(target_file) as fp:
22+
contents = fp.read()
23+
updated = contents.replace('__version__ = "99.99.99"', '__version__ = "{%s}"' % version)
24+
with open(target_file, 'w') as fp:
25+
fp.write(updated)
26+
27+
28+
class PatchVersionSdist(sdist):
29+
def make_release_tree(self, base_dir, files):
30+
super().make_release_tree(base_dir, files)
31+
target_file = base_dir + '/smriprep_docker.py'
32+
update_version(target_file, VERSION)
33+
34+
35+
class PatchVersionBuild(build_py):
36+
def run(self):
37+
super().run()
38+
target_file = self.build_lib + '/smriprep_docker.py'
39+
update_version(target_file, VERSION)
1240

1341

14-
if __name__ == "__main__":
15-
setup(name="smriprep-docker", setup_requires=SETUP_REQUIRES)
42+
if __name__ == '__main__':
43+
setup(
44+
name='smriprep-docker',
45+
version=VERSION,
46+
setup_requires=SETUP_REQUIRES,
47+
cmdclass={
48+
'build_py': PatchVersionBuild,
49+
'sdist': PatchVersionSdist,
50+
},
51+
)

0 commit comments

Comments
 (0)