Skip to content
Snippets Groups Projects
Commit a215c8cf authored by Joseph Weston's avatar Joseph Weston
Browse files

simplified version file format

Now we exec _kwant_version.py into a namespace and get
the version from that.
parent b6fcbd03
No related branches found
No related tags found
No related merge requests found
...@@ -68,14 +68,11 @@ def get_version_from_git(): ...@@ -68,14 +68,11 @@ def get_version_from_git():
# version file contains comments (lines starting with '#') # populate the version_info dictionary with values stored in the version file
# followed by the version string on its own on a single line version_info = {}
with open(os.path.join(package_root, version_file), 'r') as f: with open(os.path.join(package_root, version_file), 'r') as f:
cruft="\"'\n\t\r " # strip whitespace and quotes exec(f.read(), {}, version_info)
line = next(f).strip(cruft) version = version_info['version']
while line.startswith('#'):
line = next(f).strip(cruft)
version = line
version_is_from_git = (version == "__use_git__") version_is_from_git = (version == "__use_git__")
if version_is_from_git: if version_is_from_git:
version = get_version_from_git() version = get_version_from_git()
......
# This file will be overwritten by setup.py when a source or binary # This file will be overwritten by setup.py when a source or binary
# distribution is made. The magic value "__use_git__" is interpreted by # distribution is made. The magic value "__use_git__" is interpreted by
# _common.py in this directory. # _common.py in this directory.
"__use_git__" version = "__use_git__"
...@@ -173,7 +173,7 @@ def git_lsfiles(): ...@@ -173,7 +173,7 @@ def git_lsfiles():
if p.wait() != 0: if p.wait() != 0:
return return
return p.communicate()[0].split('\n')[:-1] return p.communicate()[0].decode().split('\n')[:-1]
# Make the command "sdist" depend on "build". This verifies that the # Make the command "sdist" depend on "build". This verifies that the
...@@ -235,7 +235,7 @@ def write_version(fname): ...@@ -235,7 +235,7 @@ def write_version(fname):
pass pass
with open(fname, 'w') as f: with open(fname, 'w') as f:
f.write("# This file has been created by setup.py.\n") f.write("# This file has been created by setup.py.\n")
f.write(version) f.write("version = '{}'".format(version))
def long_description(): def long_description():
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment