MCPcopy Create free account
hub / github.com/kivy/python-for-android / process_python_modules

Function process_python_modules

pythonforandroid/build.py:693–819  ·  view source on GitHub ↗

Use pip --dry-run to resolve dependencies and filter for pure-Python packages

(ctx, modules, arch)

Source from the content-addressed store, hash-verified

691
692
693def process_python_modules(ctx, modules, arch):
694 """Use pip --dry-run to resolve dependencies and filter for pure-Python packages
695 """
696 modules = list(modules)
697 build_order = list(ctx.recipe_build_order)
698
699 _requirement_names = []
700 processed_modules = []
701
702 for module in modules+build_order:
703 try:
704 # we need to normalize names
705 # eg Requests>=2.0 becomes requests
706 _requirement_names.append(Requirement(module).name)
707 except Exception:
708 # name parsing failed; skip processing this module via pip
709 processed_modules.append(module)
710 if module in modules:
711 modules.remove(module)
712
713 if len(processed_modules) > 0:
714 warning(f'Ignored by module resolver : {processed_modules}')
715
716 # preserve the original module list
717 processed_modules.extend(modules)
718
719 if len(modules) == 0:
720 return processed_modules
721
722 # temp file for pip report
723 fd, path = tempfile.mkstemp()
724 os.close(fd)
725
726 # setup hostpython recipe
727 env = environ.copy()
728 host_recipe = None
729 try:
730 host_recipe = Recipe.get_recipe("hostpython3", ctx)
731 pip = host_recipe.pip
732 except Exception:
733 # hostpython3 is unavailable, so fall back to system pip
734 pip = sh.Command("pip")
735
736 # add platform tags
737 platforms = []
738 tags = PyProjectRecipe.get_wheel_platform_tags(arch.arch, ctx)
739 for tag in tags:
740 platforms.append(f"--platform={tag}")
741
742 if host_recipe is not None:
743 platforms.extend(["--python-version", host_recipe.version])
744 else:
745 # use the version of the currently running Python interpreter
746 current_version = f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}"
747 platforms.extend(["--python-version", current_version])
748
749 indices = []
750 # add extra index urls

Callers 2

run_pymodules_installFunction · 0.85

Calls 5

shprintFunction · 0.90
is_wheel_compatibleFunction · 0.85
get_recipeMethod · 0.80
loadMethod · 0.80

Tested by 1