allow packaging python projects using +g as separator with the git commit number

.g is forbidden when following PEP0440 versionning standard.
This commit is contained in:
Benjamin Dauvergne 2016-02-16 22:11:07 +01:00
parent 8a84c89610
commit 90cec19eeb
1 changed files with 20 additions and 0 deletions

View File

@ -2,6 +2,7 @@ import datetime
import textwrap
import os
import sys
import subprocess
import pytz
@ -16,11 +17,27 @@ def get_commit_from_tag(repo, tag_ref):
assert ref.object.type == 'commit'
return ref.object
def is_pep0440_project(path):
if not os.path.exists(os.path.join(path, 'setup.py')):
return False
curdir = os.getcwd()
try:
os.chdir(path)
output = subprocess.check_output('python setup.py --version', shell=True)
if '+' in output:
return True
finally:
os.chdir(curdir)
return False
def changelog_from_git(project, version_suffix, path,
repository='eobuilder',
maintainer_name='eobuilder',
maintainer_email='eobuilder@entrouvert.com'):
repo = git.repo.Repo(path)
is_pep0440 = is_pep0440_project(path)
versions = []
@ -51,6 +68,9 @@ def changelog_from_git(project, version_suffix, path,
if not logs:
continue
version = name.lstrip('v').replace('-', '.')
if is_pep0440_project:
# pep440 limit free-style version number after a +
version = version.replace('.g', '+g')
if i == 0:
version += version_suffix
yield '%s (%s) %s; urgency=low' % (project, str(version), repository)