@@ -2174,6 +2174,9 @@ class PythonRecipe(Recipe):
2174
2174
call_hostpython_via_targetpython is False.
2175
2175
'''
2176
2176
2177
+ setup_extra_args = []
2178
+ '''List of extra arguments to pass to setup.py.'''
2179
+
2177
2180
@property
2178
2181
def hostpython_location (self ):
2179
2182
if not self .call_hostpython_via_targetpython :
@@ -2215,12 +2218,20 @@ def install_python_package(self, arch, name=None, env=None, is_dir=True):
2215
2218
hostpython = sh .Command (self .hostpython_location )
2216
2219
2217
2220
if self .call_hostpython_via_targetpython :
2218
- shprint (hostpython , 'setup.py' , 'install' , '-O2' , _env = env )
2221
+ shprint (hostpython , 'setup.py' , 'install' , '-O2' , _env = env , * self . setup_extra_args )
2219
2222
else :
2223
+ hppath = join (dirname (self .hostpython_location ), 'Lib' ,
2224
+ 'site-packages' )
2225
+ hpenv = env .copy ()
2226
+ if 'PYTHONPATH' in hpenv :
2227
+ hpenv ['PYTHONPATH' ] = ':' .join (
2228
+ [hppath ] + hpenv ['PYTHONPATH' ].split (':' ))
2229
+ else :
2230
+ hpenv ['PYTHONPATH' ] = hppath
2220
2231
shprint (hostpython , 'setup.py' , 'install' , '-O2' ,
2221
2232
'--root={}' .format (self .ctx .get_python_install_dir ()),
2222
2233
'--install-lib=lib/python2.7/site-packages' ,
2223
- _env = env ) # AND: Hardcoded python2.7 needs fixing
2234
+ _env = hpenv , * self . setup_extra_args ) # AND: Hardcoded python2.7 needs fixing
2224
2235
2225
2236
# If asked, also install in the hostpython build dir
2226
2237
if self .install_in_hostpython :
@@ -2246,8 +2257,15 @@ def build_compiled_components(self, arch):
2246
2257
2247
2258
env = self .get_recipe_env (arch )
2248
2259
with current_directory (self .get_build_dir (arch .arch )):
2249
- hostpython = sh .Command (self .ctx .hostpython )
2250
- shprint (hostpython , 'setup.py' , 'build_ext' , '-v' )
2260
+ hostpython = sh .Command (self .hostpython_location )
2261
+ if self .call_hostpython_via_targetpython :
2262
+ shprint (hostpython , 'setup.py' , 'build_ext' , '-v' , * self .setup_extra_args )
2263
+ else :
2264
+ hppath = join (dirname (self .hostpython_location ), 'Lib' ,
2265
+ 'site-packages' )
2266
+ hpenv = {'PYTHONPATH' : hppath }
2267
+ shprint (hostpython , 'setup.py' , 'build_ext' , '-v' , _env = hpenv , * self .setup_extra_args )
2268
+
2251
2269
build_dir = glob .glob ('build/lib.*' )[0 ]
2252
2270
shprint (sh .find , build_dir , '-name' , '"*.o"' , '-exec' ,
2253
2271
env ['STRIP' ], '{}' , ';' , _env = env )
0 commit comments