1- from os .path import join , dirname , isdir , exists , isfile , split , realpath , basename
1+ from os .path import (join , dirname , normpath , isfile ,
2+ isdir , exists , realpath , basename )
23import importlib
3- import zipfile
44import glob
55from shutil import rmtree
66from six import PY2 , with_metaclass
@@ -788,7 +788,6 @@ def install_python_package(self, arch, name=None, env=None, is_dir=True):
788788 with current_directory (self .get_build_dir (arch .arch )):
789789 hostpython = sh .Command (self .hostpython_location )
790790
791-
792791 if self .ctx .python_recipe .from_crystax :
793792 hpenv = env .copy ()
794793 shprint (hostpython , 'setup.py' , 'install' , '-O2' ,
@@ -819,7 +818,8 @@ def install_python_package(self, arch, name=None, env=None, is_dir=True):
819818 def get_hostrecipe_env (self , arch ):
820819 env = {}
821820 env ['PATH' ] = '/usr/local/bin:/usr/bin:/bin'
822- env ['PYTHONPATH' ] = join (dirname (self .real_hostpython_location ), 'Lib' , 'site-packages' )
821+ env ['PYTHONPATH' ] = join (dirname (self .real_hostpython_location ),
822+ 'Lib' , 'site-packages' )
823823 return env
824824
825825 def install_hostpython_package (self , arch ):
@@ -830,6 +830,22 @@ def install_hostpython_package(self, arch):
830830 '--install-lib=Lib/site-packages' ,
831831 _env = env , * self .setup_extra_args )
832832
833+ def pip_install_hostpython_package (self , arch ):
834+ """ calling recipe build_arch() must hast 'host_pip' in depends[] """
835+ package = (self .name + '==' + self .version if hasattr (self , 'version' )
836+ else self .name )
837+ env = self .get_hostrecipe_env (arch )
838+ real_hostpython = sh .Command (self .real_hostpython_location )
839+ build_dir = normpath (join (dirname (self .real_hostpython_location ),
840+ '..' , self .name ))
841+ target_dir = env ['PYTHONPATH' ]
842+ ensure_dir (build_dir )
843+ with current_directory (build_dir ):
844+ shprint (real_hostpython , '-mpip' , 'install' , '--upgrade' , package ,
845+ "--build={}" .format (build_dir ),
846+ "--target={}" .format (target_dir ),
847+ _env = env , * self .setup_extra_args )
848+
833849
834850class CompiledComponentsPythonRecipe (PythonRecipe ):
835851 pre_build_ext = False
0 commit comments