1
1
import os
2
+ import shlex
2
3
import shutil
3
4
import subprocess
4
5
import sys
19
20
IS_RUNNING_ON_TRAVIS = os .environ .get ('TRAVIS_OS_NAME' ) == 'windows'
20
21
21
22
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 )
26
31
27
32
def get_nuget_args (version , arch ):
28
33
python_name = 'python' if version [0 ] == '3' else 'python2'
@@ -102,6 +107,7 @@ def setup_python(python_configuration, dependency_constraint_flags, environment)
102
107
raise ValueError ("Unknown Python implementation" )
103
108
104
109
assert os .path .exists (os .path .join (installation_path , 'python.exe' ))
110
+ print ("# python path" , installation_path )
105
111
106
112
# set up PATH and environment variables for run_with_env
107
113
env = os .environ .copy ()
@@ -117,7 +123,7 @@ def setup_python(python_configuration, dependency_constraint_flags, environment)
117
123
118
124
# for the logs - check we're running the right version of python
119
125
call (['where' , 'python' ], env = env )
120
- call (['python' , '--version' ], env = env )
126
+ call (['python' , '--version' ], env = env , shell = True )
121
127
call (['python' , '-c' , '"import struct; print(struct.calcsize(\' P\' ) * 8)"' ], env = env )
122
128
where_python = subprocess .check_output (['where' , 'python' ], env = env , universal_newlines = True ).splitlines ()[0 ].strip ()
123
129
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
165
171
# run the before_build command
166
172
if before_build :
167
173
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 )
169
175
170
176
# build the wheel
171
177
if os .path .exists (built_wheel_dir ):
@@ -183,7 +189,7 @@ def build(project_dir, output_dir, test_command, before_test, test_requires, tes
183
189
shutil .move (built_wheel , repaired_wheel_dir )
184
190
else :
185
191
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 )
187
193
repaired_wheel = glob (os .path .join (repaired_wheel_dir , '*.whl' ))[0 ]
188
194
189
195
if test_command :
@@ -213,7 +219,7 @@ def build(project_dir, output_dir, test_command, before_test, test_requires, tes
213
219
214
220
if before_test :
215
221
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 )
217
223
218
224
# install the wheel
219
225
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
226
232
# (this ensures that Python runs the tests against the installed wheel
227
233
# and not the repo code)
228
234
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 )
230
236
231
237
# clean up
232
238
shutil .rmtree (venv_dir )
0 commit comments