Skip to content

Commit

Permalink
Support Python executables with spaces in path (PR #318)...
Browse files Browse the repository at this point in the history
Python 3.5/3.6 installs to  C:\Program Files (x86)\ when "install
into PATH for all users" is checked.
  • Loading branch information
cztomczak committed Mar 10, 2017
1 parent e0ef669 commit 36c0560
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 17 deletions.
15 changes: 7 additions & 8 deletions tools/automate.py
Original file line number Diff line number Diff line change
Expand Up @@ -851,19 +851,13 @@ def run_command(command, working_dir, env=None):
shell=(platform.system() == "Windows"))


def run_python(command_line, working_dir):
"""Run python script using depot_tools."""
python = "python"
return run_command("%s %s" % (python, command_line), working_dir)


def run_git(command_line, working_dir):
"""Run git command using depot_tools."""
return run_command("git %s" % command_line, working_dir)


def run_automate_git():
"""Run CEF automate-git.py."""
"""Run CEF automate-git.py using Python 2.7."""
script = os.path.join(Options.cefpython_dir, "tools", "automate-git.py")
"""
Example automate-git.py command:
Expand Down Expand Up @@ -898,8 +892,13 @@ def run_automate_git():
# later in cef_binary/ with cmake/ninja do works fine.
args.append("--build-target=cefsimple")

# On Windows automate-git.py must be run using Python 2.7
# from depot_tools. depot_tools should already be added to PATH.
python = "python" # *do not* replace with sys.executable!
args = " ".join(args)
return run_python(script+" "+args, Options.cef_build_dir)
command = script + " " + args
working_dir = Options.cef_build_dir
return run_command("%s %s" % (python, command), working_dir)


def rmdir(path):
Expand Down
14 changes: 7 additions & 7 deletions tools/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -690,13 +690,13 @@ def build_cefpython_module():
os.chdir(BUILD_CEFPYTHON)

if FAST_FLAG:
ret = subprocess.call("{python} {tools_dir}/cython_setup.py"
ret = subprocess.call("\"{python}\" {tools_dir}/cython_setup.py"
" build_ext --fast"
.format(python=sys.executable,
tools_dir=TOOLS_DIR),
shell=True)
else:
ret = subprocess.call("{python} {tools_dir}/cython_setup.py"
ret = subprocess.call("\"{python}\" {tools_dir}/cython_setup.py"
" build_ext"
.format(python=sys.executable,
tools_dir=TOOLS_DIR),
Expand Down Expand Up @@ -725,7 +725,7 @@ def build_cefpython_module():
" being generated yet. Will re-run the build.py script"
" programmatically now.")
args = list()
args.append(sys.executable)
args.append("\"{python}\"".format(python=sys.executable))
args.append(os.path.join(TOOLS_DIR, os.path.basename(__file__)))
assert __file__ in sys.argv[0]
args.extend(sys.argv[1:])
Expand Down Expand Up @@ -794,7 +794,7 @@ def install_and_run():
# Make setup installer
print("[build.py] Make setup installer")
make_tool = os.path.join(TOOLS_DIR, "make_installer.py")
ret = os.system("{python} {make_tool} --version {version}"
ret = os.system("\"{python}\" {make_tool} --version {version}"
.format(python=sys.executable,
make_tool=make_tool,
version=VERSION))
Expand All @@ -805,7 +805,7 @@ def install_and_run():
# Install
print("[build.py] Install the cefpython package")
os.chdir(setup_installer_dir)
ret = os.system("{sudo} {python} setup.py install"
ret = os.system("{sudo} \"{python}\" setup.py install"
.format(sudo=get_sudo(), python=sys.executable))
if ret != 0:
print("[build.py] ERROR while installing package")
Expand All @@ -818,7 +818,7 @@ def install_and_run():
# Run unittests
print("[build.py] Run unittests")
test_runner = os.path.join(UNITTESTS_DIR, "_test_runner.py")
ret = os.system("{python} {test_runner}"
ret = os.system("\"{python}\" {test_runner}"
.format(python=sys.executable, test_runner=test_runner))
if ret != 0:
print("[build.py] ERROR while running unit tests")
Expand All @@ -829,7 +829,7 @@ def install_and_run():
os.chdir(EXAMPLES_DIR)
kivy_flag = "--kivy" if KIVY_FLAG else ""
run_examples = os.path.join(TOOLS_DIR, "run_examples.py")
ret = os.system("{python} {run_examples} {kivy_flag}"
ret = os.system("\"{python}\" {run_examples} {kivy_flag}"
.format(python=sys.executable,
run_examples=run_examples,
kivy_flag=kivy_flag))
Expand Down
2 changes: 1 addition & 1 deletion tools/make_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def main():
print("[make_installer.py] ERROR: you must specify flags"
" eg. --python-tag cp27 or --universal")
sys.exit(1)
command = ("{python} setup.py bdist_wheel {wheel_args}"
command = ("\"{python}\" setup.py bdist_wheel {wheel_args}"
.format(python=sys.executable,
wheel_args=" ".join(WHEEL_ARGS)))
print("[make_installer.py] Run command: '{0}' in setup directory"
Expand Down
2 changes: 1 addition & 1 deletion tools/run_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def main():
for example in examples:
print("[run_examples.py] Running '{example}'..."
.format(example=example))
ret = os.system("{python} {example}"
ret = os.system("\"{python}\" {example}"
.format(python=sys.executable, example=example))
if ret == 0:
succeeded.append(example)
Expand Down

0 comments on commit 36c0560

Please sign in to comment.