X Tutup
Skip to content

Commit 36c0560

Browse files
committed
Support Python executables with spaces in path (PR cztomczak#318)...
Python 3.5/3.6 installs to C:\Program Files (x86)\ when "install into PATH for all users" is checked.
1 parent e0ef669 commit 36c0560

File tree

4 files changed

+16
-17
lines changed

4 files changed

+16
-17
lines changed

tools/automate.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -851,19 +851,13 @@ def run_command(command, working_dir, env=None):
851851
shell=(platform.system() == "Windows"))
852852

853853

854-
def run_python(command_line, working_dir):
855-
"""Run python script using depot_tools."""
856-
python = "python"
857-
return run_command("%s %s" % (python, command_line), working_dir)
858-
859-
860854
def run_git(command_line, working_dir):
861855
"""Run git command using depot_tools."""
862856
return run_command("git %s" % command_line, working_dir)
863857

864858

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

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

904903

905904
def rmdir(path):

tools/build.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -690,13 +690,13 @@ def build_cefpython_module():
690690
os.chdir(BUILD_CEFPYTHON)
691691

692692
if FAST_FLAG:
693-
ret = subprocess.call("{python} {tools_dir}/cython_setup.py"
693+
ret = subprocess.call("\"{python}\" {tools_dir}/cython_setup.py"
694694
" build_ext --fast"
695695
.format(python=sys.executable,
696696
tools_dir=TOOLS_DIR),
697697
shell=True)
698698
else:
699-
ret = subprocess.call("{python} {tools_dir}/cython_setup.py"
699+
ret = subprocess.call("\"{python}\" {tools_dir}/cython_setup.py"
700700
" build_ext"
701701
.format(python=sys.executable,
702702
tools_dir=TOOLS_DIR),
@@ -725,7 +725,7 @@ def build_cefpython_module():
725725
" being generated yet. Will re-run the build.py script"
726726
" programmatically now.")
727727
args = list()
728-
args.append(sys.executable)
728+
args.append("\"{python}\"".format(python=sys.executable))
729729
args.append(os.path.join(TOOLS_DIR, os.path.basename(__file__)))
730730
assert __file__ in sys.argv[0]
731731
args.extend(sys.argv[1:])
@@ -794,7 +794,7 @@ def install_and_run():
794794
# Make setup installer
795795
print("[build.py] Make setup installer")
796796
make_tool = os.path.join(TOOLS_DIR, "make_installer.py")
797-
ret = os.system("{python} {make_tool} --version {version}"
797+
ret = os.system("\"{python}\" {make_tool} --version {version}"
798798
.format(python=sys.executable,
799799
make_tool=make_tool,
800800
version=VERSION))
@@ -805,7 +805,7 @@ def install_and_run():
805805
# Install
806806
print("[build.py] Install the cefpython package")
807807
os.chdir(setup_installer_dir)
808-
ret = os.system("{sudo} {python} setup.py install"
808+
ret = os.system("{sudo} \"{python}\" setup.py install"
809809
.format(sudo=get_sudo(), python=sys.executable))
810810
if ret != 0:
811811
print("[build.py] ERROR while installing package")
@@ -818,7 +818,7 @@ def install_and_run():
818818
# Run unittests
819819
print("[build.py] Run unittests")
820820
test_runner = os.path.join(UNITTESTS_DIR, "_test_runner.py")
821-
ret = os.system("{python} {test_runner}"
821+
ret = os.system("\"{python}\" {test_runner}"
822822
.format(python=sys.executable, test_runner=test_runner))
823823
if ret != 0:
824824
print("[build.py] ERROR while running unit tests")
@@ -829,7 +829,7 @@ def install_and_run():
829829
os.chdir(EXAMPLES_DIR)
830830
kivy_flag = "--kivy" if KIVY_FLAG else ""
831831
run_examples = os.path.join(TOOLS_DIR, "run_examples.py")
832-
ret = os.system("{python} {run_examples} {kivy_flag}"
832+
ret = os.system("\"{python}\" {run_examples} {kivy_flag}"
833833
.format(python=sys.executable,
834834
run_examples=run_examples,
835835
kivy_flag=kivy_flag))

tools/make_installer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def main():
103103
print("[make_installer.py] ERROR: you must specify flags"
104104
" eg. --python-tag cp27 or --universal")
105105
sys.exit(1)
106-
command = ("{python} setup.py bdist_wheel {wheel_args}"
106+
command = ("\"{python}\" setup.py bdist_wheel {wheel_args}"
107107
.format(python=sys.executable,
108108
wheel_args=" ".join(WHEEL_ARGS)))
109109
print("[make_installer.py] Run command: '{0}' in setup directory"

tools/run_examples.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def main():
9696
for example in examples:
9797
print("[run_examples.py] Running '{example}'..."
9898
.format(example=example))
99-
ret = os.system("{python} {example}"
99+
ret = os.system("\"{python}\" {example}"
100100
.format(python=sys.executable, example=example))
101101
if ret == 0:
102102
succeeded.append(example)

0 commit comments

Comments
 (0)
X Tutup