From a42cf6264871932db373e6ac7aaa3cbaf3455bf8 Mon Sep 17 00:00:00 2001 From: Ryan Pessa Date: Mon, 14 Dec 2015 12:34:45 -0600 Subject: [PATCH] fix pymodules install --- pythonforandroid/build.py | 18 ++++++++++++++++-- pythonforandroid/recipe.py | 2 +- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/pythonforandroid/build.py b/pythonforandroid/build.py index a3c4489a9a..a25b8ddcb0 100644 --- a/pythonforandroid/build.py +++ b/pythonforandroid/build.py @@ -470,6 +470,17 @@ def get_libs_dir(self, arch): ensure_dir(join(self.libs_dir, arch)) return join(self.libs_dir, arch) + def has_package(self, name, arch=None): + site_packages_dir = self.get_site_packages_dir(arch) + return (exists(join(site_packages_dir, name)) or + exists(join(site_packages_dir, name + '.py')) or + exists(join(site_packages_dir, name + '.pyc')) or + exists(join(site_packages_dir, name + '.pyo')) or + exists(join(site_packages_dir, name + '.so'))) + + def not_has_package(self, name, arch=None): + return not self.has_package(name, arch) + def build_recipes(build_order, python_modules, ctx): # Put recipes in correct build order @@ -531,9 +542,12 @@ def build_recipes(build_order, python_modules, ctx): def run_pymodules_install(ctx, modules): + modules = filter(ctx.not_has_package, modules) + if not modules: info('There are no Python modules to install, skipping') return + info('The requirements ({}) don\'t have recipes, attempting to install ' 'them with pip'.format(', '.join(modules))) info('If this fails, it may mean that the module has compiled ' @@ -556,8 +570,8 @@ def run_pymodules_install(ctx, modules): # This bash method is what old-p4a used # It works but should be replaced with something better shprint(sh.bash, '-c', ( - "source venv/bin/activate && env CC=/bin/false CXX=/bin/false" - "PYTHONPATH= pip install --target '{}' -r requirements.txt" + "source venv/bin/activate && env CC=/bin/false CXX=/bin/false " + "PYTHONPATH={0} pip install --target '{0}' -r requirements.txt" ).format(ctx.get_site_packages_dir())) diff --git a/pythonforandroid/recipe.py b/pythonforandroid/recipe.py index 3a8f0c7968..333d3579dc 100644 --- a/pythonforandroid/recipe.py +++ b/pythonforandroid/recipe.py @@ -610,7 +610,7 @@ def should_build(self, arch): name = self.site_packages_name if name is None: name = self.name - if exists(join(self.ctx.get_site_packages_dir(), name)): + if self.ctx.has_package(name): info('Python package already exists in site-packages') return False info('{} apparently isn\'t already in site-packages'.format(name))