@@ -641,10 +641,18 @@ def install_python_package(self, arch, name=None, env=None, is_dir=True):
641
641
shprint (hostpython , 'setup.py' , 'install' , '-O2' , _env = env ,
642
642
* self .setup_extra_args )
643
643
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
644
652
shprint (hostpython , 'setup.py' , 'install' , '-O2' ,
645
653
'--root={}' .format (self .ctx .get_python_install_dir ()),
646
654
'--install-lib=lib/python2.7/site-packages' ,
647
- _env = env , * self .setup_extra_args )
655
+ _env = hpenv , * self .setup_extra_args )
648
656
# AND: Hardcoded python2.7 needs fixing
649
657
650
658
# 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):
658
666
class CompiledComponentsPythonRecipe (PythonRecipe ):
659
667
pre_build_ext = False
660
668
669
+ build_cmd = 'build_ext'
670
+
661
671
def build_arch (self , arch ):
662
672
'''Build any cython components, then install the Python module by
663
673
calling setup.py install with the target Python dir.
@@ -673,13 +683,16 @@ def build_compiled_components(self, arch):
673
683
with current_directory (self .get_build_dir (arch .arch )):
674
684
hostpython = sh .Command (self .hostpython_location )
675
685
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 )
678
688
else :
679
689
hppath = join (dirname (self .hostpython_location ), 'Lib' ,
680
690
'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 ,
683
696
* self .setup_extra_args )
684
697
build_dir = glob .glob ('build/lib.*' )[0 ]
685
698
shprint (sh .find , build_dir , '-name' , '"*.o"' , '-exec' ,
0 commit comments