@@ -2167,6 +2167,9 @@ class PythonRecipe(Recipe):
21672167 call_hostpython_via_targetpython is False.
21682168 '''
21692169
2170+ setup_extra_args = []
2171+ '''List of extra arguments to pass to setup.py.'''
2172+
21702173 @property
21712174 def hostpython_location (self ):
21722175 if not self .call_hostpython_via_targetpython :
@@ -2208,12 +2211,20 @@ def install_python_package(self, arch, name=None, env=None, is_dir=True):
22082211 hostpython = sh .Command (self .hostpython_location )
22092212
22102213 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 )
22122215 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
22132224 shprint (hostpython , 'setup.py' , 'install' , '-O2' ,
22142225 '--root={}' .format (self .ctx .get_python_install_dir ()),
22152226 '--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
22172228
22182229 # If asked, also install in the hostpython build dir
22192230 if self .install_in_hostpython :
@@ -2239,8 +2250,15 @@ def build_compiled_components(self, arch):
22392250
22402251 env = self .get_recipe_env (arch )
22412252 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+
22442262 build_dir = glob .glob ('build/lib.*' )[0 ]
22452263 shprint (sh .find , build_dir , '-name' , '"*.o"' , '-exec' ,
22462264 env ['STRIP' ], '{}' , ';' , _env = env )
0 commit comments