Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions pythonforandroid/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 '
Expand All @@ -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()))


Expand Down
2 changes: 1 addition & 1 deletion pythonforandroid/recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down