This function will take care of all non-recipe things, by: 1. Processing them from --requirements (the modules argument) and installing them 2. Installing the user project/app itself via setup.py if ignore_setup_py=True
(ctx, arch, modules, project_dir=None,
ignore_setup_py=False)
| 820 | |
| 821 | |
| 822 | def run_pymodules_install(ctx, arch, modules, project_dir=None, |
| 823 | ignore_setup_py=False): |
| 824 | """ This function will take care of all non-recipe things, by: |
| 825 | |
| 826 | 1. Processing them from --requirements (the modules argument) |
| 827 | and installing them |
| 828 | |
| 829 | 2. Installing the user project/app itself via setup.py if |
| 830 | ignore_setup_py=True |
| 831 | |
| 832 | """ |
| 833 | |
| 834 | info('*** PYTHON PACKAGE / PROJECT INSTALL STAGE FOR ARCH: {} ***'.format(arch)) |
| 835 | |
| 836 | modules = process_python_modules(ctx, modules, arch) |
| 837 | |
| 838 | modules = [m for m in modules if ctx.not_has_package(m, arch)] |
| 839 | |
| 840 | # We change current working directory later, so this has to be an absolute |
| 841 | # path or `None` in case that we didn't supply the `project_dir` via kwargs |
| 842 | project_dir = abspath(project_dir) if project_dir else None |
| 843 | |
| 844 | # Bail out if no python deps and no setup.py to process: |
| 845 | if not modules and ( |
| 846 | ignore_setup_py or |
| 847 | not project_has_setup_py(project_dir) |
| 848 | ): |
| 849 | info('No Python modules and no setup.py to process, skipping') |
| 850 | return |
| 851 | |
| 852 | # Output messages about what we're going to do: |
| 853 | if modules: |
| 854 | info( |
| 855 | "The requirements ({}) don\'t have recipes, attempting to " |
| 856 | "install them with pip".format(', '.join(modules)) |
| 857 | ) |
| 858 | info( |
| 859 | "If this fails, it may mean that the module has compiled " |
| 860 | "components and needs a recipe." |
| 861 | ) |
| 862 | if project_has_setup_py(project_dir) and not ignore_setup_py: |
| 863 | info( |
| 864 | "Will process project install, if it fails then the " |
| 865 | "project may not be compatible for Android install." |
| 866 | ) |
| 867 | |
| 868 | # Use our hostpython to create the virtualenv |
| 869 | host_python = sh.Command(ctx.hostpython) |
| 870 | with current_directory(join(ctx.build_dir)): |
| 871 | shprint(host_python, '-m', 'venv', 'venv') |
| 872 | |
| 873 | # Prepare base environment and upgrade pip: |
| 874 | base_env = dict(copy.copy(os.environ)) |
| 875 | base_env["PYTHONPATH"] = ctx.get_site_packages_dir(arch) |
| 876 | info('Upgrade pip to latest version') |
| 877 | shprint(sh.bash, '-c', ( |
| 878 | "source venv/bin/activate && pip install -U pip" |
| 879 | ), _env=copy.copy(base_env)) |