general: update for python 3 (#41852)
This commit is contained in:
parent
d649f30ea8
commit
db357708da
14
eobuildall
14
eobuildall
|
@ -77,15 +77,15 @@ if __name__ == '__main__':
|
||||||
if blacklisted:
|
if blacklisted:
|
||||||
continue
|
continue
|
||||||
t0 = time.time()
|
t0 = time.time()
|
||||||
print '='*60
|
print('='*60)
|
||||||
print module
|
print(module)
|
||||||
print '='*60
|
print('='*60)
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
results[module] = build_module(config, module)
|
results[module] = build_module(config, module)
|
||||||
print '\n'
|
print('\n')
|
||||||
print '(%1.2f seconds)' % (time.time()-t0)
|
print('(%1.2f seconds)' % (time.time()-t0))
|
||||||
print '\n'
|
print('\n')
|
||||||
|
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
for module in sorted(results.keys()):
|
for module in sorted(results.keys()):
|
||||||
print '%-40s %s' % (module, results[module])
|
print('%-40s %s' % (module, results[module]))
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import atexit
|
import atexit
|
||||||
import re
|
import re
|
||||||
|
@ -23,7 +23,7 @@ def smart_cleaning(files_path):
|
||||||
project_files = {}
|
project_files = {}
|
||||||
for file_path in files_path:
|
for file_path in files_path:
|
||||||
project_name = os.path.basename(file_path).split('_')[0]
|
project_name = os.path.basename(file_path).split('_')[0]
|
||||||
if not project_files.has_key(project_name):
|
if projet_name not in project_files:
|
||||||
project_files[project_name] = []
|
project_files[project_name] = []
|
||||||
project_files[project_name].append(file_path)
|
project_files[project_name].append(file_path)
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ def smart_cleaning(files_path):
|
||||||
|
|
||||||
|
|
||||||
def clean(method):
|
def clean(method):
|
||||||
print "+ Cleanning %s" % method
|
print("+ Cleanning %s" % method)
|
||||||
if method == "all":
|
if method == "all":
|
||||||
shutil.rmtree(settings.ORIGIN_PATH)
|
shutil.rmtree(settings.ORIGIN_PATH)
|
||||||
shutil.rmtree(settings.PBUILDER_RESULT)
|
shutil.rmtree(settings.PBUILDER_RESULT)
|
||||||
|
@ -157,14 +157,14 @@ def prepare_build(dist, project, cmd_options, new):
|
||||||
if debian_branch == "debian" and "debian-%s" % dist in branches:
|
if debian_branch == "debian" and "debian-%s" % dist in branches:
|
||||||
debian_branch = "debian-" + dist
|
debian_branch = "debian-" + dist
|
||||||
if not 'origin/%s' % debian_branch in output("git branch -r -l"):
|
if not 'origin/%s' % debian_branch in output("git branch -r -l"):
|
||||||
print '!!! WARNING: cannot build for dist %s, no debian directory found' % dist
|
print('!!! WARNING: cannot build for dist %s, no debian directory found' % dist)
|
||||||
return
|
return
|
||||||
print "!!! WARNING obsolete: using a branch for debian/ packaging"
|
print("!!! WARNING obsolete: using a branch for debian/ packaging")
|
||||||
print "+ Updating Debian branch for %s" % dist
|
print("+ Updating Debian branch for %s" % dist)
|
||||||
call("git checkout --quiet %s" % debian_branch)
|
call("git checkout --quiet %s" % debian_branch)
|
||||||
call("git pull")
|
call("git pull")
|
||||||
else:
|
else:
|
||||||
print "+ Building from %s debian folder" % debian_folder
|
print("+ Building from %s debian folder" % debian_folder)
|
||||||
for r in cmd_options.repositories:
|
for r in cmd_options.repositories:
|
||||||
repo = r.split(':')
|
repo = r.split(':')
|
||||||
if repo[0] == dist:
|
if repo[0] == dist:
|
||||||
|
@ -183,7 +183,7 @@ def prepare_build(dist, project, cmd_options, new):
|
||||||
origin_archive = os.path.join(settings.ORIGIN_PATH,
|
origin_archive = os.path.join(settings.ORIGIN_PATH,
|
||||||
"%s_%s.orig.tar.bz2" % (package['source_name'], project['version']))
|
"%s_%s.orig.tar.bz2" % (package['source_name'], project['version']))
|
||||||
if not os.path.exists(origin_archive):
|
if not os.path.exists(origin_archive):
|
||||||
print "+ Generating origin tarball ..."
|
print("+ Generating origin tarball ...")
|
||||||
os.chdir(project['git_path'])
|
os.chdir(project['git_path'])
|
||||||
call("git checkout --quiet %s" % build_branch)
|
call("git checkout --quiet %s" % build_branch)
|
||||||
if os.path.exists('setup.py'):
|
if os.path.exists('setup.py'):
|
||||||
|
@ -251,7 +251,7 @@ def prepare_build(dist, project, cmd_options, new):
|
||||||
|
|
||||||
if os.path.exists(project['build_dir']):
|
if os.path.exists(project['build_dir']):
|
||||||
shutil.rmtree(project['build_dir'])
|
shutil.rmtree(project['build_dir'])
|
||||||
os.makedirs(project['build_dir'], 0755)
|
os.makedirs(project['build_dir'], 0o755)
|
||||||
|
|
||||||
if package['version'].split('-')[0].split(':')[-1] == project['version']:
|
if package['version'].split('-')[0].split(':')[-1] == project['version']:
|
||||||
# the generated changelog has the right version number, use it.
|
# the generated changelog has the right version number, use it.
|
||||||
|
@ -274,10 +274,10 @@ def prepare_build(dist, project, cmd_options, new):
|
||||||
build_branch.replace('/', '_'))
|
build_branch.replace('/', '_'))
|
||||||
)
|
)
|
||||||
if os.path.exists(build_file):
|
if os.path.exists(build_file):
|
||||||
print "+ Already built for %s !" % dist
|
print("+ Already built for %s !" % dist)
|
||||||
return package
|
return package
|
||||||
|
|
||||||
print "+ Preparing Debian build (%s %s) ..." % (package['source_name'], package['version'])
|
print("+ Preparing Debian build (%s %s) ..." % (package['source_name'], package['version']))
|
||||||
if debian_branch:
|
if debian_branch:
|
||||||
call("git checkout --quiet %s" % debian_branch)
|
call("git checkout --quiet %s" % debian_branch)
|
||||||
os.chdir(project['build_dir'])
|
os.chdir(project['build_dir'])
|
||||||
|
@ -304,7 +304,7 @@ def build_project(dist, arch, project, package, new):
|
||||||
project_build_path = os.path.join(project['build_dir'],
|
project_build_path = os.path.join(project['build_dir'],
|
||||||
"%s-%s" % (project['name'], project['version']))
|
"%s-%s" % (project['name'], project['version']))
|
||||||
if not os.path.exists(pbuilder_project_result):
|
if not os.path.exists(pbuilder_project_result):
|
||||||
os.makedirs(pbuilder_project_result, 0755)
|
os.makedirs(pbuilder_project_result, 0o755)
|
||||||
os.chdir(project['lock_path'])
|
os.chdir(project['lock_path'])
|
||||||
source_build = os.path.join(project['lock_path'],
|
source_build = os.path.join(project['lock_path'],
|
||||||
"%s_%s_%s_%s_source.build" % (project['name'],
|
"%s_%s_%s_%s_source.build" % (project['name'],
|
||||||
|
@ -319,21 +319,21 @@ def build_project(dist, arch, project, package, new):
|
||||||
project['build_branch'].replace('/', '_'),
|
project['build_branch'].replace('/', '_'),
|
||||||
arch)
|
arch)
|
||||||
)
|
)
|
||||||
print 'SOURCE_BUILD:', source_build
|
print('SOURCE_BUILD:', source_build)
|
||||||
if os.path.exists(source_build):
|
if os.path.exists(source_build):
|
||||||
source_opt = '-b'
|
source_opt = '-b'
|
||||||
else:
|
else:
|
||||||
source_opt = '-sa'
|
source_opt = '-sa'
|
||||||
if new == 0 and os.path.exists(bin_build):
|
if new == 0 and os.path.exists(bin_build):
|
||||||
print "+ Already build !"
|
print("+ Already build !")
|
||||||
return
|
return
|
||||||
os.chdir(project_build_path)
|
os.chdir(project_build_path)
|
||||||
print "+ Building %s %s %s %s" % \
|
print("+ Building %s %s %s %s" % \
|
||||||
(project['name'], project['version'], dist, arch)
|
(project['name'], project['version'], dist, arch))
|
||||||
call('DIST=%s ARCH=%s pdebuild --use-pdebuild-internal --architecture %s --debbuildopts "%s"' % \
|
call('DIST=%s ARCH=%s pdebuild --use-pdebuild-internal --architecture %s --debbuildopts "%s"' % \
|
||||||
(dist, arch, arch, source_opt))
|
(dist, arch, arch, source_opt))
|
||||||
|
|
||||||
print "+ Lock build"
|
print("+ Lock build")
|
||||||
touch(bin_build)
|
touch(bin_build)
|
||||||
if not os.path.exists(source_build):
|
if not os.path.exists(source_build):
|
||||||
touch(source_build)
|
touch(source_build)
|
||||||
|
@ -343,10 +343,10 @@ def send_packages(dist, arch, project, package, last_tag):
|
||||||
project['name'], package['version'],
|
project['name'], package['version'],
|
||||||
package['repository'], arch, project['build_branch'].replace('/', '_')))
|
package['repository'], arch, project['build_branch'].replace('/', '_')))
|
||||||
if os.path.exists(stamp_file):
|
if os.path.exists(stamp_file):
|
||||||
print '+ Already uploaded'
|
print('+ Already uploaded')
|
||||||
return
|
return
|
||||||
|
|
||||||
print "+ Sending package..."
|
print("+ Sending package...")
|
||||||
pbuilder_project_result = os.path.join(settings.PBUILDER_RESULT,
|
pbuilder_project_result = os.path.join(settings.PBUILDER_RESULT,
|
||||||
'%s-%s' % (dist, arch))
|
'%s-%s' % (dist, arch))
|
||||||
os.chdir(pbuilder_project_result)
|
os.chdir(pbuilder_project_result)
|
||||||
|
@ -357,23 +357,23 @@ def send_packages(dist, arch, project, package, last_tag):
|
||||||
arch)
|
arch)
|
||||||
)
|
)
|
||||||
|
|
||||||
print "+ Updating repository ..."
|
print("+ Updating repository ...")
|
||||||
call('ssh root@%s "/etc/cron.hourly/process-incoming"' % \
|
call('ssh root@%s "/etc/cron.hourly/process-incoming"' % \
|
||||||
settings.REPOSITORY_URL)
|
settings.REPOSITORY_URL)
|
||||||
old_version = tuple(int(d) for d in last_tag.split('.'))
|
old_version = tuple(int(d) for d in last_tag.split('.'))
|
||||||
new_version = tuple(int(d) for d in project['current_tag'].split('.'))
|
new_version = tuple(int(d) for d in project['current_tag'].split('.'))
|
||||||
if new_version > old_version and \
|
if new_version > old_version and \
|
||||||
project['current_tag'] == project['version']:
|
project['current_tag'] == project['version']:
|
||||||
print "New tag detected : %s" % project['current_tag']
|
print("New tag detected : %s" % project['current_tag'])
|
||||||
if settings.MANUAL_TESTING_REPOSITORIES.has_key(package['source_name']):
|
if package['source_name'] in settings.MANUAL_TESTING_REPOSITORIES:
|
||||||
package_repos = settings.MANUAL_TESTING_REPOSITORIES[package['source_name']]
|
package_repos = settings.MANUAL_TESTING_REPOSITORIES[package['source_name']]
|
||||||
else:
|
else:
|
||||||
package_repos = settings.DEFAULT_TESTING_REPOSITORIES
|
package_repos = settings.DEFAULT_TESTING_REPOSITORIES
|
||||||
packages = package['names'] + [package['source_name']]
|
packages = package['names'] + [package['source_name']]
|
||||||
packages = " ".join(packages)
|
packages = " ".join(packages)
|
||||||
if package_repos.has_key(dist) and package['copy_in_testing']:
|
if dist in package_repos and package['copy_in_testing']:
|
||||||
for repo in package_repos[dist]:
|
for repo in package_repos[dist]:
|
||||||
print "+ Copy %s packages to %s repository (%s)" % (package['source_name'], repo, dist)
|
print("+ Copy %s packages to %s repository (%s)" % (package['source_name'], repo, dist))
|
||||||
call('ssh root@%s "/usr/bin/reprepro -b /var/vhosts/deb.entrouvert.org copy %s %s %s"'\
|
call('ssh root@%s "/usr/bin/reprepro -b /var/vhosts/deb.entrouvert.org copy %s %s %s"'\
|
||||||
% (settings.REPOSITORY_URL, repo,
|
% (settings.REPOSITORY_URL, repo,
|
||||||
package['repository'], packages))
|
package['repository'], packages))
|
||||||
|
@ -406,7 +406,7 @@ def setup_git_tree(project_name, options):
|
||||||
subprocess.check_call(['git', 'checkout', '--quiet', options.branch])
|
subprocess.check_call(['git', 'checkout', '--quiet', options.branch])
|
||||||
subprocess.check_call(['git', 'reset', '--hard', 'origin/%s' % options.branch])
|
subprocess.check_call(['git', 'reset', '--hard', 'origin/%s' % options.branch])
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
print >> sys.stderr, e
|
print(e, file=sys.stderr)
|
||||||
shutil.rmtree(git_project_path)
|
shutil.rmtree(git_project_path)
|
||||||
return setup_git_tree(project_name, options)
|
return setup_git_tree(project_name, options)
|
||||||
else:
|
else:
|
||||||
|
@ -426,7 +426,7 @@ def setup_git_tree(project_name, options):
|
||||||
subprocess.check_call(['git', 'submodule', 'update'])
|
subprocess.check_call(['git', 'submodule', 'update'])
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
if existing_tree:
|
if existing_tree:
|
||||||
print >> sys.stderr, e
|
print(e, file=sys.stderr)
|
||||||
shutil.rmtree(git_project_path)
|
shutil.rmtree(git_project_path)
|
||||||
return setup_git_tree(project_name, options)
|
return setup_git_tree(project_name, options)
|
||||||
raise
|
raise
|
||||||
|
@ -462,7 +462,7 @@ def main():
|
||||||
project = get_project_infos(git_project_path, options)
|
project = get_project_infos(git_project_path, options)
|
||||||
|
|
||||||
if not os.path.exists(project['lock_path']):
|
if not os.path.exists(project['lock_path']):
|
||||||
os.mkdir(project['lock_path'], 0755)
|
os.mkdir(project['lock_path'], 0o755)
|
||||||
|
|
||||||
# compare revision between last build and now to determine if something is really new
|
# compare revision between last build and now to determine if something is really new
|
||||||
new = 1
|
new = 1
|
||||||
|
@ -482,7 +482,7 @@ def main():
|
||||||
new = 0
|
new = 0
|
||||||
|
|
||||||
if options.force and not new:
|
if options.force and not new:
|
||||||
print "+ Warning force a new build"
|
print("+ Warning force a new build")
|
||||||
new = 1
|
new = 1
|
||||||
|
|
||||||
for dist in options.distrib:
|
for dist in options.distrib:
|
||||||
|
@ -493,7 +493,7 @@ def main():
|
||||||
for arch in options.architectures:
|
for arch in options.architectures:
|
||||||
build_project(dist, arch, project, package, new)
|
build_project(dist, arch, project, package, new)
|
||||||
send_packages(dist, arch, project, package, last_tag)
|
send_packages(dist, arch, project, package, last_tag)
|
||||||
print "+ Add a build file to lock new build for %s" % dist
|
print("+ Add a build file to lock new build for %s" % dist)
|
||||||
touch(os.path.join(project['lock_path'],
|
touch(os.path.join(project['lock_path'],
|
||||||
"%s_%s_%s_%s.build" % (project['name'],
|
"%s_%s_%s_%s.build" % (project['name'],
|
||||||
package['version'],
|
package['version'],
|
||||||
|
|
|
@ -3,12 +3,12 @@ import os
|
||||||
VERSION = '7'
|
VERSION = '7'
|
||||||
|
|
||||||
def init():
|
def init():
|
||||||
print "+ Init EO Builder"
|
print("+ Init EO Builder")
|
||||||
if not os.path.exists(settings.GIT_PATH):
|
if not os.path.exists(settings.GIT_PATH):
|
||||||
os.makedirs(settings.GIT_PATH, 0755)
|
os.makedirs(settings.GIT_PATH, 0o755)
|
||||||
if not os.path.exists(settings.ORIGIN_PATH):
|
if not os.path.exists(settings.ORIGIN_PATH):
|
||||||
os.makedirs(settings.ORIGIN_PATH, 0755)
|
os.makedirs(settings.ORIGIN_PATH, 0o755)
|
||||||
if not os.path.exists(settings.PBUILDER_RESULT):
|
if not os.path.exists(settings.PBUILDER_RESULT):
|
||||||
os.makedirs(settings.PBUILDER_RESULT, 0755)
|
os.makedirs(settings.PBUILDER_RESULT, 0o755)
|
||||||
if not os.path.exists(settings.LOCK_PATH):
|
if not os.path.exists(settings.LOCK_PATH):
|
||||||
os.makedirs(settings.LOCK_PATH, 0755)
|
os.makedirs(settings.LOCK_PATH, 0o755)
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import codecs
|
||||||
import datetime
|
import datetime
|
||||||
import textwrap
|
import textwrap
|
||||||
import os
|
import os
|
||||||
|
@ -66,7 +67,9 @@ def changelog_from_git(project, version_suffix, path,
|
||||||
if i == n-1:
|
if i == n-1:
|
||||||
logs = [commit] + list(commit.iter_parents())
|
logs = [commit] + list(commit.iter_parents())
|
||||||
else:
|
else:
|
||||||
reflog = '%s..%s' % (versions[i+1][1].binsha.encode('hex'), commit.binsha.encode('hex'))
|
def encode_hex(value):
|
||||||
|
return codecs.encode(value, 'hex').decode('ascii')
|
||||||
|
reflog = '%s..%s' % (encode_hex(versions[i+1][1].binsha), encode_hex(commit.binsha))
|
||||||
logs = list(Commit.iter_items(repo, reflog))
|
logs = list(Commit.iter_items(repo, reflog))
|
||||||
if not logs:
|
if not logs:
|
||||||
continue
|
continue
|
||||||
|
@ -87,7 +90,7 @@ def changelog_from_git(project, version_suffix, path,
|
||||||
t = '(%s) %s' % (l.hexsha[:6], e)
|
t = '(%s) %s' % (l.hexsha[:6], e)
|
||||||
lines = textwrap.wrap(t, 80)
|
lines = textwrap.wrap(t, 80)
|
||||||
for prefix, suffix in zip([' * '] + [' ']*(len(lines)-1), lines):
|
for prefix, suffix in zip([' * '] + [' ']*(len(lines)-1), lines):
|
||||||
yield (prefix + suffix).encode('utf-8')
|
yield (prefix + suffix)
|
||||||
paris = pytz.timezone('Europe/Paris')
|
paris = pytz.timezone('Europe/Paris')
|
||||||
date = datetime.datetime.fromtimestamp(logs[0].committed_date + logs[0].committer_tz_offset).replace(
|
date = datetime.datetime.fromtimestamp(logs[0].committed_date + logs[0].committer_tz_offset).replace(
|
||||||
tzinfo=pytz.UTC).astimezone(paris).strftime('%a, %d %b %Y %H:%M:%S %z')
|
tzinfo=pytz.UTC).astimezone(paris).strftime('%a, %d %b %Y %H:%M:%S %z')
|
||||||
|
@ -102,4 +105,4 @@ if __name__ == '__main__':
|
||||||
path = sys.argv[3]
|
path = sys.argv[3]
|
||||||
else:
|
else:
|
||||||
path = os.getcwd()
|
path = os.getcwd()
|
||||||
print '\n'.join(changelog_from_git(project, version_suffix, path))
|
print('\n'.join(changelog_from_git(project, version_suffix, path)))
|
||||||
|
|
|
@ -99,7 +99,7 @@ def cat(file_path):
|
||||||
return content
|
return content
|
||||||
|
|
||||||
def touch(fname):
|
def touch(fname):
|
||||||
print 'TOUCH:', fname
|
print('TOUCH:', fname)
|
||||||
with open(fname, 'a'):
|
with open(fname, 'a'):
|
||||||
os.utime(fname, None)
|
os.utime(fname, None)
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ def call(cmd):
|
||||||
shebang = open('setup.py').readline()
|
shebang = open('setup.py').readline()
|
||||||
if shebang.startswith('#!'):
|
if shebang.startswith('#!'):
|
||||||
cmd = shebang[2:].strip() + ' ' + cmd.split(' ', 1)[1]
|
cmd = shebang[2:].strip() + ' ' + cmd.split(' ', 1)[1]
|
||||||
print 'CALL:', cmd
|
print('CALL:', cmd)
|
||||||
rcode = subprocess.call(cmd, shell=True)
|
rcode = subprocess.call(cmd, shell=True)
|
||||||
if rcode != 0:
|
if rcode != 0:
|
||||||
error(cmd)
|
error(cmd)
|
||||||
|
@ -135,11 +135,11 @@ def output(cmd, print_output=False, exit_on_error=True):
|
||||||
output = subprocess.check_output(cmd,
|
output = subprocess.check_output(cmd,
|
||||||
stderr=subprocess.STDOUT,
|
stderr=subprocess.STDOUT,
|
||||||
shell=True)
|
shell=True)
|
||||||
except subprocess.CalledProcessError, e:
|
except subprocess.CalledProcessError as e:
|
||||||
sys.stderr.write(e.output)
|
sys.stderr.write(e.output)
|
||||||
if exit_on_error:
|
if exit_on_error:
|
||||||
error(cmd)
|
error(cmd)
|
||||||
if print_output:
|
if print_output:
|
||||||
print output
|
print(output)
|
||||||
return output
|
return output.decode('utf-8')
|
||||||
|
|
||||||
|
|
|
@ -56,4 +56,4 @@ MIN_AGE = 60
|
||||||
local_settings_file = os.environ.get('EOBUILDER_SETTINGS_FILE',
|
local_settings_file = os.environ.get('EOBUILDER_SETTINGS_FILE',
|
||||||
os.path.join(os.path.dirname(__file__), 'local_settings.py'))
|
os.path.join(os.path.dirname(__file__), 'local_settings.py'))
|
||||||
if os.path.exists(local_settings_file):
|
if os.path.exists(local_settings_file):
|
||||||
execfile(local_settings_file)
|
exec(open(local_settings_file).read())
|
||||||
|
|
26
setup.py
26
setup.py
|
@ -8,9 +8,7 @@ from setuptools.command.sdist import sdist
|
||||||
|
|
||||||
|
|
||||||
class eo_sdist(sdist):
|
class eo_sdist(sdist):
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
print "creating VERSION file"
|
|
||||||
if os.path.exists('VERSION'):
|
if os.path.exists('VERSION'):
|
||||||
os.remove('VERSION')
|
os.remove('VERSION')
|
||||||
version = get_version()
|
version = get_version()
|
||||||
|
@ -18,29 +16,35 @@ class eo_sdist(sdist):
|
||||||
version_file.write(version)
|
version_file.write(version)
|
||||||
version_file.close()
|
version_file.close()
|
||||||
sdist.run(self)
|
sdist.run(self)
|
||||||
print "removing VERSION file"
|
|
||||||
if os.path.exists('VERSION'):
|
if os.path.exists('VERSION'):
|
||||||
os.remove('VERSION')
|
os.remove('VERSION')
|
||||||
|
|
||||||
|
|
||||||
def get_version():
|
def get_version():
|
||||||
'''Use the VERSION, if absent generates a version with git describe, if not
|
'''Use the VERSION, if absent generates a version with git describe, if not
|
||||||
tag exists, take 0.0.0- and add the length of the commit log.
|
tag exists, take 0.0- and add the length of the commit log.
|
||||||
'''
|
'''
|
||||||
if os.path.exists('VERSION'):
|
if os.path.exists('VERSION'):
|
||||||
with open('VERSION', 'r') as v:
|
with open('VERSION', 'r') as v:
|
||||||
return v.read()
|
return v.read()
|
||||||
if os.path.exists('.git'):
|
if os.path.exists('.git'):
|
||||||
p = subprocess.Popen(['git', 'describe', '--dirty', '--match=v*'], stdout=subprocess.PIPE,
|
p = subprocess.Popen(
|
||||||
stderr=subprocess.PIPE)
|
['git', 'describe', '--dirty=.dirty', '--match=v*'],
|
||||||
|
stdout=subprocess.PIPE,
|
||||||
|
stderr=subprocess.PIPE,
|
||||||
|
)
|
||||||
result = p.communicate()[0]
|
result = p.communicate()[0]
|
||||||
if p.returncode == 0:
|
if p.returncode == 0:
|
||||||
result = result.split()[0][1:]
|
result = result.decode('ascii').strip()[1:] # strip spaces/newlines and initial v
|
||||||
|
if '-' in result: # not a tagged version
|
||||||
|
real_number, commit_count, commit_hash = result.split('-', 2)
|
||||||
|
version = '%s.post%s+%s' % (real_number, commit_count, commit_hash)
|
||||||
|
else:
|
||||||
|
version = result
|
||||||
|
return version
|
||||||
else:
|
else:
|
||||||
result = '0.0.0-%s' % len(subprocess.check_output(
|
return '0.0.post%s' % len(subprocess.check_output(['git', 'rev-list', 'HEAD']).splitlines())
|
||||||
['git', 'rev-list', 'HEAD']).splitlines())
|
return '0.0'
|
||||||
return result.replace('-', '.').replace('.g', '+g')
|
|
||||||
return '0.0.0'
|
|
||||||
|
|
||||||
|
|
||||||
setup(name="eobuilder",
|
setup(name="eobuilder",
|
||||||
|
|
Loading…
Reference in New Issue