summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2019-12-26 10:21:36 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2019-12-26 15:35:02 (GMT)
commit06602cd25e313692427f580da5765492377dd02f (patch)
treed7041f7007e58d25fcfb4a16cf3354e1af581e3d
parent5ca950a6a2e1821305e365f426e109a9ac6b9bb7 (diff)
downloadeobuilder-master.zip
eobuilder-master.tar.gz
eobuilder-master.tar.bz2
cmdline: intercept setup.py calls and use shebang to get proper version (#38710)HEADv15master
-rw-r--r--eobuilder/changelog.py5
-rw-r--r--eobuilder/cmdline.py8
2 files changed, 11 insertions, 2 deletions
diff --git a/eobuilder/changelog.py b/eobuilder/changelog.py
index 2b1eb0f..8a33fb9 100644
--- a/eobuilder/changelog.py
+++ b/eobuilder/changelog.py
@@ -2,7 +2,6 @@ import datetime
import textwrap
import os
import sys
-import subprocess
import pytz
@@ -10,6 +9,8 @@ import git
from git.exc import GitCommandError
from git.objects.commit import Commit
+from . import cmdline
+
def get_commit_from_tag(repo, tag_ref):
ref = repo.tags[tag_ref]
while ref.object.type == 'tag':
@@ -24,7 +25,7 @@ def is_pep0440_project(path):
curdir = os.getcwd()
try:
os.chdir(path)
- output = subprocess.check_output('python setup.py --version', shell=True)
+ output = cmdline.output('python setup.py --version')
if '+' in output:
return True
finally:
diff --git a/eobuilder/cmdline.py b/eobuilder/cmdline.py
index 4e6ea75..8935336 100644
--- a/eobuilder/cmdline.py
+++ b/eobuilder/cmdline.py
@@ -112,6 +112,10 @@ def error(msg, build_dir=None, exit_code=1):
def call(cmd):
""" cmd: command line
"""
+ if cmd.startswith('python setup.py'):
+ shebang = open('setup.py').readline()
+ if shebang.startswith('#!'):
+ cmd = shebang[2:].strip() + ' ' + cmd.split(' ', 1)[1]
print 'CALL:', cmd
rcode = subprocess.call(cmd, shell=True)
if rcode != 0:
@@ -122,6 +126,10 @@ def output(cmd, print_output=False, exit_on_error=True):
print_output: print stdout and stderr
return outputs (stderr + stdout) as byte string
"""
+ if cmd.startswith('python setup.py'):
+ shebang = open('setup.py').readline()
+ if shebang.startswith('#!'):
+ cmd = shebang[2:].strip() + ' ' + cmd.split(' ', 1)[1]
output = None
try:
output = subprocess.check_output(cmd,