@@ -641,10 +641,18 @@ def install_python_package(self, arch, name=None, env=None, is_dir=True):
641641 shprint (hostpython , 'setup.py' , 'install' , '-O2' , _env = env ,
642642 * self .setup_extra_args )
643643 else :
644+ hppath = join (dirname (self .hostpython_location ), 'Lib' ,
645+ 'site-packages' )
646+ hpenv = env .copy ()
647+ if 'PYTHONPATH' in hpenv :
648+ hpenv ['PYTHONPATH' ] = ':' .join ([hppath ] +
649+ hpenv ['PYTHONPATH' ].split (':' ))
650+ else :
651+ hpenv ['PYTHONPATH' ] = hppath
644652 shprint (hostpython , 'setup.py' , 'install' , '-O2' ,
645653 '--root={}' .format (self .ctx .get_python_install_dir ()),
646654 '--install-lib=lib/python2.7/site-packages' ,
647- _env = env , * self .setup_extra_args )
655+ _env = hpenv , * self .setup_extra_args )
648656 # AND: Hardcoded python2.7 needs fixing
649657
650658 # If asked, also install in the hostpython build dir
@@ -658,6 +666,8 @@ def install_python_package(self, arch, name=None, env=None, is_dir=True):
658666class CompiledComponentsPythonRecipe (PythonRecipe ):
659667 pre_build_ext = False
660668
669+ build_cmd = 'build_ext'
670+
661671 def build_arch (self , arch ):
662672 '''Build any cython components, then install the Python module by
663673 calling setup.py install with the target Python dir.
@@ -673,13 +683,16 @@ def build_compiled_components(self, arch):
673683 with current_directory (self .get_build_dir (arch .arch )):
674684 hostpython = sh .Command (self .hostpython_location )
675685 if self .call_hostpython_via_targetpython :
676- shprint (hostpython , 'setup.py' , 'build_ext' , '-v' ,
677- * self .setup_extra_args )
686+ shprint (hostpython , 'setup.py' , self . build_cmd , '-v' ,
687+ _env = env , * self .setup_extra_args )
678688 else :
679689 hppath = join (dirname (self .hostpython_location ), 'Lib' ,
680690 'site-packages' )
681- hpenv = {'PYTHONPATH' : hppath }
682- shprint (hostpython , 'setup.py' , 'build_ext' , '-v' , _env = hpenv ,
691+ if 'PYTHONPATH' in env :
692+ env ['PYTHONPATH' ] = hppath + ':' + env ['PYTHONPATH' ]
693+ else :
694+ env ['PYTHONPATH' ] = hppath
695+ shprint (hostpython , 'setup.py' , self .build_cmd , '-v' , _env = env ,
683696 * self .setup_extra_args )
684697 build_dir = glob .glob ('build/lib.*' )[0 ]
685698 shprint (sh .find , build_dir , '-name' , '"*.o"' , '-exec' ,
0 commit comments