Skip to content

Commit 22f18af

Browse files
committed
change windows call to not always call shell
1 parent a276abb commit 22f18af

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

cibuildwheel/windows.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import shlex
23
import shutil
34
import subprocess
45
import sys
@@ -19,10 +20,14 @@
1920
IS_RUNNING_ON_TRAVIS = os.environ.get('TRAVIS_OS_NAME') == 'windows'
2021

2122

22-
def call(args, env=None, cwd=None):
23-
print('+ ' + ' '.join(args))
24-
return subprocess.check_call(' '.join(args), env=env, cwd=cwd, shell=True)
25-
23+
def call(args, env=None, cwd=None, shell=True):
24+
# print the command executing for the logs
25+
if shell:
26+
print('+ %s' % args)
27+
else:
28+
print('+ ' + ' '.join(shlex.quote(a) for a in args))
29+
args = " ".join(args)
30+
return subprocess.check_call(args, env=env, cwd=cwd, shell=shell)
2631

2732
def get_nuget_args(version, arch):
2833
python_name = 'python' if version[0] == '3' else 'python2'
@@ -102,6 +107,7 @@ def setup_python(python_configuration, dependency_constraint_flags, environment)
102107
raise ValueError("Unknown Python implementation")
103108

104109
assert os.path.exists(os.path.join(installation_path, 'python.exe'))
110+
print("# python path", installation_path)
105111

106112
# set up PATH and environment variables for run_with_env
107113
env = os.environ.copy()
@@ -117,7 +123,7 @@ def setup_python(python_configuration, dependency_constraint_flags, environment)
117123

118124
# for the logs - check we're running the right version of python
119125
call(['where', 'python'], env=env)
120-
call(['python', '--version'], env=env)
126+
call(['python', '--version'], env=env, shell=True)
121127
call(['python', '-c', '"import struct; print(struct.calcsize(\'P\') * 8)"'], env=env)
122128
where_python = subprocess.check_output(['where', 'python'], env=env, universal_newlines=True).splitlines()[0].strip()
123129
if where_python != os.path.join(installation_path, 'python.exe'):
@@ -165,7 +171,7 @@ def build(project_dir, output_dir, test_command, before_test, test_requires, tes
165171
# run the before_build command
166172
if before_build:
167173
before_build_prepared = prepare_command(before_build, project=abs_project_dir)
168-
call([before_build_prepared], env=env)
174+
call([before_build_prepared], env=env, shell=True)
169175

170176
# build the wheel
171177
if os.path.exists(built_wheel_dir):
@@ -183,7 +189,7 @@ def build(project_dir, output_dir, test_command, before_test, test_requires, tes
183189
shutil.move(built_wheel, repaired_wheel_dir)
184190
else:
185191
repair_command_prepared = prepare_command(repair_command, wheel=built_wheel, dest_dir=repaired_wheel_dir)
186-
call([repair_command_prepared], env=env)
192+
call([repair_command_prepared], env=env, shell=True)
187193
repaired_wheel = glob(os.path.join(repaired_wheel_dir, '*.whl'))[0]
188194

189195
if test_command:
@@ -213,7 +219,7 @@ def build(project_dir, output_dir, test_command, before_test, test_requires, tes
213219

214220
if before_test:
215221
before_test_prepared = prepare_command(before_test, project=abs_project_dir)
216-
call([before_test_prepared], env=virtualenv_env)
222+
call([before_test_prepared], env=virtualenv_env, shell=True)
217223

218224
# install the wheel
219225
call(['pip', 'install', repaired_wheel + test_extras], env=virtualenv_env)
@@ -226,7 +232,7 @@ def build(project_dir, output_dir, test_command, before_test, test_requires, tes
226232
# (this ensures that Python runs the tests against the installed wheel
227233
# and not the repo code)
228234
test_command_prepared = prepare_command(test_command, project=abs_project_dir)
229-
call([test_command_prepared], cwd='c:\\', env=virtualenv_env)
235+
call([test_command_prepared], cwd='c:\\', env=virtualenv_env, shell=True)
230236

231237
# clean up
232238
shutil.rmtree(venv_dir)

0 commit comments

Comments
 (0)