comparison setup.py @ 179:acc718ab56da 2.0.0a5

setup: Make version generation compatible with PEP440.
author Ludovic Chabant <ludovic@chabant.com>
date Sat, 03 Jan 2015 23:13:06 -0800
parents f49fcf9448df
children 9fb7c4921d75
comparison
equal deleted inserted replaced
178:ff5b2d3863a8 179:acc718ab56da
60 elif os.path.isdir(os.path.join(os.path.dirname(__file__), '.git')): 60 elif os.path.isdir(os.path.join(os.path.dirname(__file__), '.git')):
61 return generate_version_from_git() 61 return generate_version_from_git()
62 else: 62 else:
63 raise Exception("Can't generate version number: this is not a " 63 raise Exception("Can't generate version number: this is not a "
64 "Mercurial repository.") 64 "Mercurial repository.")
65
65 66
66 def generate_version_from_mercurial(): 67 def generate_version_from_mercurial():
67 try: 68 try:
68 # Get the version we're currently on. Also see if we have local 69 # Get the version we're currently on. Also see if we have local
69 # changes. 70 # changes.
91 if dist == '1': 92 if dist == '1':
92 # We're on the commit that created the tag in the first place. 93 # We're on the commit that created the tag in the first place.
93 # Let's just do as if we were on the tag. 94 # Let's just do as if we were on the tag.
94 version = tag 95 version = tag
95 else: 96 else:
96 version = '%s-%s-%s' % (tag, dist, hgid) 97 version = '%s+%s.%s' % (tag, dist, hgid)
97 98
98 if has_local_changes: 99 if has_local_changes:
99 version += time.strftime('+%Y%m%d') 100 if '+' in version:
101 version += '.'
102 else:
103 version += '+'
104 version += time.strftime('%Y%m%d')
100 105
101 return version 106 return version
102 except OSError: 107 except OSError:
103 raise Exception("Can't generate version number: Mercurial isn't " 108 raise Exception("Can't generate version number: Mercurial isn't "
104 "installed, or in the PATH.") 109 "installed, or in the PATH.")