@@ -424,6 +424,7 @@ class Recipe:
424
424
"archs" : [],
425
425
"depends" : [],
426
426
"optional_depends" : [],
427
+ "python_depends" : [],
427
428
"library" : None ,
428
429
"libraries" : [],
429
430
"include_dir" : None ,
@@ -814,6 +815,8 @@ def build_all(self):
814
815
self .install_frameworks ()
815
816
logger .info ("Install sources for {}" .format (self .name ))
816
817
self .install_sources ()
818
+ logger .info ("Install python deps for {}" .format (self .name ))
819
+ self .install_python_deps ()
817
820
logger .info ("Install {}" .format (self .name ))
818
821
self .install ()
819
822
@@ -929,6 +932,11 @@ def install_include(self):
929
932
ensure_dir (dirname (dest ))
930
933
shutil .copy (src_dir , dest )
931
934
935
+ @cache_execution
936
+ def install_python_deps (self ):
937
+ for dep in self .python_depends :
938
+ _pip (["install" , dep ])
939
+
932
940
@cache_execution
933
941
def install (self ):
934
942
pass
@@ -1126,6 +1134,37 @@ def ensure_recipes_loaded(ctx):
1126
1134
recipe .init_with_ctx (ctx )
1127
1135
1128
1136
1137
+ def _pip (args ):
1138
+ ctx = Context ()
1139
+ for recipe in Recipe .list_recipes ():
1140
+ key = "{}.build_all" .format (recipe )
1141
+ if key not in ctx .state :
1142
+ continue
1143
+ recipe = Recipe .get_recipe (recipe , ctx )
1144
+ recipe .init_with_ctx (ctx )
1145
+ if not hasattr (ctx , "site_packages_dir" ):
1146
+ logger .error ("python must be compiled before using pip" )
1147
+ sys .exit (1 )
1148
+
1149
+ pip_env = {
1150
+ "CC" : "/bin/false" ,
1151
+ "CXX" : "/bin/false" ,
1152
+ "PYTHONPATH" : ctx .site_packages_dir ,
1153
+ "PYTHONOPTIMIZE" : "2" ,
1154
+ # "PIP_INSTALL_TARGET": ctx.site_packages_dir
1155
+ }
1156
+
1157
+ pip_path = join (ctx .dist_dir , 'hostpython3' , 'bin' , 'pip3' )
1158
+
1159
+ if len (args ) > 1 and args [0 ] == "install" :
1160
+ pip_args = ["--isolated" , "--ignore-installed" , "--prefix" , ctx .python_prefix ]
1161
+ args = ["install" ] + pip_args + args [1 :]
1162
+
1163
+ logger .error ("Executing pip with: {}" .format (args ))
1164
+ pip_cmd = sh .Command (pip_path )
1165
+ shprint (pip_cmd , * args , _env = pip_env )
1166
+
1167
+
1129
1168
def update_pbxproj (filename , pbx_frameworks = None ):
1130
1169
# list all the compiled recipes
1131
1170
ctx = Context ()
@@ -1415,35 +1454,7 @@ def pip3(self):
1415
1454
self .pip ()
1416
1455
1417
1456
def pip (self ):
1418
- ctx = Context ()
1419
- for recipe in Recipe .list_recipes ():
1420
- key = "{}.build_all" .format (recipe )
1421
- if key not in ctx .state :
1422
- continue
1423
- recipe = Recipe .get_recipe (recipe , ctx )
1424
- recipe .init_with_ctx (ctx )
1425
- if not hasattr (ctx , "site_packages_dir" ):
1426
- logger .error ("python must be compiled before using pip" )
1427
- sys .exit (1 )
1428
-
1429
- pip_env = {
1430
- "CC" : "/bin/false" ,
1431
- "CXX" : "/bin/false" ,
1432
- "PYTHONPATH" : ctx .site_packages_dir ,
1433
- "PYTHONOPTIMIZE" : "2" ,
1434
- # "PIP_INSTALL_TARGET": ctx.site_packages_dir
1435
- }
1436
- pip_path = join (ctx .dist_dir , 'hostpython3' , 'bin' , 'pip3' )
1437
- pip_args = []
1438
- if len (sys .argv ) > 2 and sys .argv [2 ] == "install" :
1439
- pip_args = ["--isolated" , "--ignore-installed" , "--prefix" , ctx .python_prefix ]
1440
- args = [pip_path ] + [sys .argv [2 ]] + pip_args + sys .argv [3 :]
1441
- else :
1442
- args = [pip_path ] + pip_args + sys .argv [2 :]
1443
-
1444
- import os
1445
- logger .error ("Executing pip with: {}" .format (args ))
1446
- os .execve (pip_path , args , pip_env )
1457
+ _pip (sys .argv [2 :])
1447
1458
1448
1459
def launchimage (self ):
1449
1460
import xcassets
0 commit comments