Skip to content

Commit 5f96ca8

Browse files
committed
Modify basesetup some more
1 parent 7ce2160 commit 5f96ca8

File tree

1 file changed

+25
-26
lines changed

1 file changed

+25
-26
lines changed

basesetup.py

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -233,37 +233,36 @@ def _minimal_ext_cmd(cmd):
233233
return GIT_REVISION
234234

235235

236-
def write_version_py(VERSION, ISRELEASED, filename):
236+
def write_version_py(version, isreleased, filename):
237237
cnt = """
238-
# THIS FILE IS GENERATED FROM SETUP.PY
239-
short_version = '%(version)s'
240-
version = '%(version)s'
241-
full_version = '%(full_version)s'
242-
git_revision = '%(git_revision)s'
243-
release = %(isrelease)s
244-
245-
if not release:
246-
version = full_version
238+
# This file is generated in setup.py at build time.
239+
version = '{version}'
240+
short_version = '{short_version}'
241+
full_version = '{full_version}'
242+
git_revision = '{git_revision}'
243+
release = {release}
247244
"""
248-
# Adding the git rev number needs to be done inside write_version_py(),
249-
# otherwise the import of numpy.version messes up the build under Python 3.
250-
FULLVERSION = VERSION
245+
# git_revision
251246
if os.path.exists('.git'):
252-
GIT_REVISION = git_version()
247+
git_revision = git_version()
253248
else:
254-
GIT_REVISION = 'Unknown'
255-
256-
if not ISRELEASED:
257-
FULLVERSION += '.dev-' + GIT_REVISION[:7]
249+
git_revision = 'Unknown'
258250

259-
a = open(filename, 'w')
260-
try:
261-
a.write(cnt % {'version': VERSION,
262-
'full_version': FULLVERSION,
263-
'git_revision': GIT_REVISION,
264-
'isrelease': str(ISRELEASED)})
265-
finally:
266-
a.close()
251+
# short_version, full_version
252+
if isreleased:
253+
full_version = version
254+
short_version = version
255+
else:
256+
full_version = ("{version}+{git_revision}"
257+
.format(version=version, git_revision=git_revision))
258+
short_version = version
259+
260+
with open(filename, 'w') as f:
261+
f.write(cnt.format(version=version,
262+
short_version=short_version,
263+
full_version=full_version,
264+
git_revision=git_revision,
265+
release=isreleased))
267266

268267

269268
class StaticLibrary(Extension):

0 commit comments

Comments
 (0)