mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2026-01-04 19:10:09 +01:00
Enable runcmd to use a list for the command, and have it quote elements as needed.
This commit is contained in:
19
build.py
19
build.py
@@ -231,16 +231,17 @@ def setPythonVersion(args):
|
|||||||
else:
|
else:
|
||||||
PYTHON = args[idx+1]
|
PYTHON = args[idx+1]
|
||||||
del args[idx:idx+2]
|
del args[idx:idx+2]
|
||||||
PYVER = runcmd('"%s" -c "import sys; print(sys.version[:3])"' % PYTHON,
|
PYVER = runcmd([PYTHON, '-c', 'import sys; print(sys.version[:3])'],
|
||||||
getOutput=True, echoCmd=False)
|
getOutput=True, echoCmd=True)
|
||||||
|
msg("PYVER: {!r}".format(PYVER))
|
||||||
PYSHORTVER = PYVER[0] + PYVER[2]
|
PYSHORTVER = PYVER[0] + PYVER[2]
|
||||||
break
|
break
|
||||||
|
|
||||||
if havePyVer:
|
if havePyVer:
|
||||||
if isWindows and os.environ.get('TOOLS'):
|
if isWindows and os.environ.get('TOOLS'):
|
||||||
# Use $TOOLS to find the correct Python. It should be the install
|
# Use $TOOLS to find the correct Python. If set then it should be
|
||||||
# root of all Python's on the system, with the 64-bit ones in an
|
# the install root of all Python's on the system, with the 64-bit
|
||||||
# amd64 subfolder, like this:
|
# ones in an amd64 subfolder, like this:
|
||||||
#
|
#
|
||||||
# $TOOLS\Python27\python.exe
|
# $TOOLS\Python27\python.exe
|
||||||
# $TOOLS\Python33\python.exe
|
# $TOOLS\Python33\python.exe
|
||||||
@@ -284,9 +285,11 @@ def setPythonVersion(args):
|
|||||||
PYTHON = os.path.abspath(PYTHON)
|
PYTHON = os.path.abspath(PYTHON)
|
||||||
msg('Build using: "%s"' % PYTHON)
|
msg('Build using: "%s"' % PYTHON)
|
||||||
|
|
||||||
msg(runcmd('"%s" -c "import sys; print(sys.version)"' % PYTHON, True, False))
|
msg(runcmd([PYTHON, '-c', 'import sys; print(sys.version)'], True, False))
|
||||||
PYTHON_ARCH = runcmd('"%s" -c "import platform; print(platform.architecture()[0])"'
|
PYTHON_ARCH = runcmd(
|
||||||
% PYTHON, True, False)
|
[PYTHON, '-c', 'import platform; print(platform.architecture()[0])'],
|
||||||
|
True, False)
|
||||||
|
|
||||||
msg('Python\'s architecture is %s' % PYTHON_ARCH)
|
msg('Python\'s architecture is %s' % PYTHON_ARCH)
|
||||||
os.environ['PYTHON'] = PYTHON
|
os.environ['PYTHON'] = PYTHON
|
||||||
|
|
||||||
|
|||||||
@@ -781,6 +781,24 @@ def getVcsRev():
|
|||||||
|
|
||||||
|
|
||||||
def runcmd(cmd, getOutput=False, echoCmd=True, fatal=True):
|
def runcmd(cmd, getOutput=False, echoCmd=True, fatal=True):
|
||||||
|
"""
|
||||||
|
Runs a give command-line command, optionally returning the output.
|
||||||
|
"""
|
||||||
|
if isinstance(cmd, list):
|
||||||
|
# add quotes to elements of the command that need it
|
||||||
|
cmd = cmd[:]
|
||||||
|
for idx, item in enumerate(cmd):
|
||||||
|
if ' ' in item or ';' in item:
|
||||||
|
if item[0] not in ['"', "'"]:
|
||||||
|
if '"' in item:
|
||||||
|
item = item.replace('"', '\\"')
|
||||||
|
item = '"{}"'.format(item)
|
||||||
|
cmd[idx] = item
|
||||||
|
|
||||||
|
cmd = ' '.join(cmd)
|
||||||
|
#if echoCmd:
|
||||||
|
# msg(' '.join(cmd))
|
||||||
|
|
||||||
if echoCmd:
|
if echoCmd:
|
||||||
msg(cmd)
|
msg(cmd)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user