Skip to content

Commit 2ba6c42

Browse files
committed
PY27: Ensure setup.py runs on older build tools
1 parent 13bab97 commit 2ba6c42

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

wrapper/setup.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,31 @@
1313
# This enables setuptools to install wheel on-the-fly
1414
SETUP_REQUIRES += ['wheel'] if 'bdist_wheel' in sys.argv else []
1515

16-
17-
VERSION = get_version(root='..', relative_to=__file__)
16+
try:
17+
VERSION = get_version(root='..', relative_to=__file__)
18+
except LookupError: # PY27 will not be able to build with a correct version, probably
19+
# Note that `python setup.py *` will work, but `pip install` generally won't
20+
VERSION = '99.99.99'
1821

1922

2023
def update_version(target_file, version):
2124
with open(target_file) as fp:
2225
contents = fp.read()
23-
updated = contents.replace('__version__ = "99.99.99"', '__version__ = "{%s}"' % version)
26+
updated = contents.replace('__version__ = "99.99.99"', '__version__ = "%s"' % version)
2427
with open(target_file, 'w') as fp:
2528
fp.write(updated)
2629

2730

2831
class PatchVersionSdist(sdist):
2932
def make_release_tree(self, base_dir, files):
30-
super().make_release_tree(base_dir, files)
33+
sdist.make_release_tree(self, base_dir, files)
3134
target_file = base_dir + '/smriprep_docker.py'
3235
update_version(target_file, VERSION)
3336

3437

3538
class PatchVersionBuild(build_py):
3639
def run(self):
37-
super().run()
40+
build_py.run(self)
3841
target_file = self.build_lib + '/smriprep_docker.py'
3942
update_version(target_file, VERSION)
4043

0 commit comments

Comments
 (0)