@@ -2167,6 +2167,9 @@ class PythonRecipe(Recipe):
2167
2167
call_hostpython_via_targetpython is False.
2168
2168
'''
2169
2169
2170
+ setup_extra_args = []
2171
+ '''List of extra arguments to pass to setup.py.'''
2172
+
2170
2173
@property
2171
2174
def hostpython_location (self ):
2172
2175
if not self .call_hostpython_via_targetpython :
@@ -2208,12 +2211,20 @@ def install_python_package(self, arch, name=None, env=None, is_dir=True):
2208
2211
hostpython = sh .Command (self .hostpython_location )
2209
2212
2210
2213
if self .call_hostpython_via_targetpython :
2211
- shprint (hostpython , 'setup.py' , 'install' , '-O2' , _env = env )
2214
+ shprint (hostpython , 'setup.py' , 'install' , '-O2' , _env = env , * self . setup_extra_args )
2212
2215
else :
2216
+ hppath = join (dirname (self .hostpython_location ), 'Lib' ,
2217
+ 'site-packages' )
2218
+ hpenv = env .copy ()
2219
+ if 'PYTHONPATH' in hpenv :
2220
+ hpenv ['PYTHONPATH' ] = ':' .join (
2221
+ [hppath ] + hpenv ['PYTHONPATH' ].split (':' ))
2222
+ else :
2223
+ hpenv ['PYTHONPATH' ] = hppath
2213
2224
shprint (hostpython , 'setup.py' , 'install' , '-O2' ,
2214
2225
'--root={}' .format (self .ctx .get_python_install_dir ()),
2215
2226
'--install-lib=lib/python2.7/site-packages' ,
2216
- _env = env ) # AND: Hardcoded python2.7 needs fixing
2227
+ _env = hpenv , * self . setup_extra_args ) # AND: Hardcoded python2.7 needs fixing
2217
2228
2218
2229
# If asked, also install in the hostpython build dir
2219
2230
if self .install_in_hostpython :
@@ -2239,8 +2250,15 @@ def build_compiled_components(self, arch):
2239
2250
2240
2251
env = self .get_recipe_env (arch )
2241
2252
with current_directory (self .get_build_dir (arch .arch )):
2242
- hostpython = sh .Command (self .ctx .hostpython )
2243
- shprint (hostpython , 'setup.py' , 'build_ext' , '-v' )
2253
+ hostpython = sh .Command (self .hostpython_location )
2254
+ if self .call_hostpython_via_targetpython :
2255
+ shprint (hostpython , 'setup.py' , 'build_ext' , '-v' , * self .setup_extra_args )
2256
+ else :
2257
+ hppath = join (dirname (self .hostpython_location ), 'Lib' ,
2258
+ 'site-packages' )
2259
+ hpenv = {'PYTHONPATH' : hppath }
2260
+ shprint (hostpython , 'setup.py' , 'build_ext' , '-v' , _env = hpenv , * self .setup_extra_args )
2261
+
2244
2262
build_dir = glob .glob ('build/lib.*' )[0 ]
2245
2263
shprint (sh .find , build_dir , '-name' , '"*.o"' , '-exec' ,
2246
2264
env ['STRIP' ], '{}' , ';' , _env = env )
0 commit comments