Skip to content

Commit

Permalink
change windows call to not always call shell
Browse files Browse the repository at this point in the history
  • Loading branch information
Czaki committed Apr 6, 2020
1 parent 2da983d commit 5fbb703
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions cibuildwheel/windows.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import shlex
import shutil
import subprocess
import sys
Expand All @@ -19,10 +20,14 @@
IS_RUNNING_ON_TRAVIS = os.environ.get('TRAVIS_OS_NAME') == 'windows'


def call(args, env=None, cwd=None):
print('+ ' + ' '.join(args))
return subprocess.check_call(' '.join(args), env=env, cwd=cwd, shell=True)
def call(args, env=None, cwd=None, shell=False):
# print the command executing for the logs
if shell:
print('+ %s' % args)
else:
print('+ ' + ' '.join(shlex.quote(a) for a in args))

return subprocess.check_call(args, env=env, cwd=cwd, shell=shell)

def get_nuget_args(version, arch):
python_name = 'python' if version[0] == '3' else 'python2'
Expand Down Expand Up @@ -165,7 +170,7 @@ def build(project_dir, output_dir, test_command, before_test, test_requires, tes
# run the before_build command
if before_build:
before_build_prepared = prepare_command(before_build, project=abs_project_dir)
call([before_build_prepared], env=env)
call([before_build_prepared], env=env, shell=True)

# build the wheel
if os.path.exists(built_wheel_dir):
Expand All @@ -183,7 +188,7 @@ def build(project_dir, output_dir, test_command, before_test, test_requires, tes
shutil.move(built_wheel, repaired_wheel_dir)
else:
repair_command_prepared = prepare_command(repair_command, wheel=built_wheel, dest_dir=repaired_wheel_dir)
call([repair_command_prepared], env=env)
call([repair_command_prepared], env=env, shell=True)
repaired_wheel = glob(os.path.join(repaired_wheel_dir, '*.whl'))[0]

if test_command:
Expand Down Expand Up @@ -213,7 +218,7 @@ def build(project_dir, output_dir, test_command, before_test, test_requires, tes

if before_test:
before_test_prepared = prepare_command(before_test, project=abs_project_dir)
call([before_test_prepared], env=virtualenv_env)
call([before_test_prepared], env=virtualenv_env, shell=True)

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

# clean up
shutil.rmtree(venv_dir)
Expand Down

0 comments on commit 5fbb703

Please sign in to comment.