@@ -470,6 +470,17 @@ def get_libs_dir(self, arch):
470
470
ensure_dir (join (self .libs_dir , arch ))
471
471
return join (self .libs_dir , arch )
472
472
473
+ def has_package (self , name , arch = None ):
474
+ site_packages_dir = self .get_site_packages_dir (arch )
475
+ return (exists (join (site_packages_dir , name )) or
476
+ exists (join (site_packages_dir , name + '.py' )) or
477
+ exists (join (site_packages_dir , name + '.pyc' )) or
478
+ exists (join (site_packages_dir , name + '.pyo' )) or
479
+ exists (join (site_packages_dir , name + '.so' )))
480
+
481
+ def not_has_package (self , name , arch = None ):
482
+ return not self .has_package (name , arch )
483
+
473
484
474
485
def build_recipes (build_order , python_modules , ctx ):
475
486
# Put recipes in correct build order
@@ -531,9 +542,12 @@ def build_recipes(build_order, python_modules, ctx):
531
542
532
543
533
544
def run_pymodules_install (ctx , modules ):
545
+ modules = filter (ctx .not_has_package , modules )
546
+
534
547
if not modules :
535
548
info ('There are no Python modules to install, skipping' )
536
549
return
550
+
537
551
info ('The requirements ({}) don\' t have recipes, attempting to install '
538
552
'them with pip' .format (', ' .join (modules )))
539
553
info ('If this fails, it may mean that the module has compiled '
@@ -556,8 +570,8 @@ def run_pymodules_install(ctx, modules):
556
570
# This bash method is what old-p4a used
557
571
# It works but should be replaced with something better
558
572
shprint (sh .bash , '-c' , (
559
- "source venv/bin/activate && env CC=/bin/false CXX=/bin/false"
560
- "PYTHONPATH= pip install --target '{}' -r requirements.txt"
573
+ "source venv/bin/activate && env CC=/bin/false CXX=/bin/false "
574
+ "PYTHONPATH={0} pip install --target '{0 }' -r requirements.txt"
561
575
).format (ctx .get_site_packages_dir ()))
562
576
563
577
0 commit comments