@@ -205,6 +205,20 @@ def generate_authors():
205205"""
206206
207207
208+ def read_versioninfo (project ):
209+ """Read the versioninfo file. If it doesn't exist, we're in a github
210+ zipball, and there's really know way to know what version we really
211+ are, but that should be ok, because the utility of that should be
212+ just about nil if this code path is in use in the first place."""
213+ versioninfo_path = os .path .join (project , 'versioninfo' )
214+ if os .path .exists (versioninfo_path ):
215+ with open (versioninfo_path , 'r' ) as vinfo :
216+ version = vinfo .read ().strip ()
217+ else :
218+ version = "0.0.0"
219+ return version
220+
221+
208222def write_versioninfo (project , version ):
209223 """Write a simple file containing the version of the package."""
210224 open (os .path .join (project , 'versioninfo' ), 'w' ).write ("%s\n " % version )
@@ -312,9 +326,8 @@ def get_pre_version(projectname, base_version):
312326 write_versioninfo (projectname , version )
313327 return version .split ('~' )[0 ]
314328 else :
315- with open (os .path .join (projectname , 'versioninfo' ), 'r' ) as vinfo :
316- full_version = vinfo .read ().strip ()
317- return full_version .split ('~' )[0 ]
329+ version = read_versioninfo (projectname )
330+ return version .split ('~' )[0 ]
318331
319332
320333def get_post_version (projectname ):
@@ -326,4 +339,4 @@ def get_post_version(projectname):
326339 version = _get_git_post_version ()
327340 write_versioninfo (projectname , version )
328341 return version
329- return open ( os . path . join ( projectname , 'versioninfo' ), 'r' ). read (). strip ( )
342+ return read_versioninfo ( projectname )
0 commit comments