@@ -470,6 +470,17 @@ def get_libs_dir(self, arch):
470470 ensure_dir (join (self .libs_dir , arch ))
471471 return join (self .libs_dir , arch )
472472
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+
473484
474485def build_recipes (build_order , python_modules , ctx ):
475486 # Put recipes in correct build order
@@ -531,9 +542,12 @@ def build_recipes(build_order, python_modules, ctx):
531542
532543
533544def run_pymodules_install (ctx , modules ):
545+ modules = filter (ctx .not_has_package , modules )
546+
534547 if not modules :
535548 info ('There are no Python modules to install, skipping' )
536549 return
550+
537551 info ('The requirements ({}) don\' t have recipes, attempting to install '
538552 'them with pip' .format (', ' .join (modules )))
539553 info ('If this fails, it may mean that the module has compiled '
@@ -556,8 +570,8 @@ def run_pymodules_install(ctx, modules):
556570 # This bash method is what old-p4a used
557571 # It works but should be replaced with something better
558572 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"
561575 ).format (ctx .get_site_packages_dir ()))
562576
563577
0 commit comments