diff options
author | Monty Taylor <mordred@inaugust.com> | 2012-06-26 13:58:07 -0500 |
---|---|---|
committer | Monty Taylor <mordred@inaugust.com> | 2012-06-26 14:05:36 -0500 |
commit | 089d509f350b01c8345cfb7b9b33510a60043861 (patch) | |
tree | e82f59e13be03a1faf3a64632757cc9e4dcd4bb6 | |
parent | 993a7b7dd670f9ea9ade230bd48519b83af85dbf (diff) | |
download | python-glanceclient-0.1.1.tar.gz |
Split reading of versioninfo out into a method0.1.1
Make the read_versioninfo to match write_versioninfo.
Additionally, there is an edge case where if the code is installed from a
github zipball, versioning info is missing. Now that we're using this,
there should be virtual no instances where a zipball will be easier or
less cost than an sdist created tarball, all of which should be public and
accessible, but during the transition, we need to account for the codepath.
Change-Id: Icd3fe97c6341bb04da27adc55a85f1ab6b525c46
-rw-r--r-- | glanceclient/openstack/common/setup.py | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/glanceclient/openstack/common/setup.py b/glanceclient/openstack/common/setup.py index e9cd340..caf06fa 100644 --- a/glanceclient/openstack/common/setup.py +++ b/glanceclient/openstack/common/setup.py @@ -205,6 +205,20 @@ _rst_template = """%(heading)s """ +def read_versioninfo(project): + """Read the versioninfo file. If it doesn't exist, we're in a github + zipball, and there's really know way to know what version we really + are, but that should be ok, because the utility of that should be + just about nil if this code path is in use in the first place.""" + versioninfo_path = os.path.join(project, 'versioninfo') + if os.path.exists(versioninfo_path): + with open(versioninfo_path, 'r') as vinfo: + version = vinfo.read().strip() + else: + version = "0.0.0" + return version + + def write_versioninfo(project, version): """Write a simple file containing the version of the package.""" open(os.path.join(project, 'versioninfo'), 'w').write("%s\n" % version) @@ -312,9 +326,8 @@ def get_pre_version(projectname, base_version): write_versioninfo(projectname, version) return version.split('~')[0] else: - with open(os.path.join(projectname, 'versioninfo'), 'r') as vinfo: - full_version = vinfo.read().strip() - return full_version.split('~')[0] + version = read_versioninfo(projectname) + return version.split('~')[0] def get_post_version(projectname): @@ -326,4 +339,4 @@ def get_post_version(projectname): version = _get_git_post_version() write_versioninfo(projectname, version) return version - return open(os.path.join(projectname, 'versioninfo'), 'r').read().strip() + return read_versioninfo(projectname) |