From d2ee8c54d9d42375a95f18159e950a119671cf63 Mon Sep 17 00:00:00 2001 From: Fabian Date: Thu, 30 Jul 2026 10:39:26 +0100 Subject: [PATCH] build: avoid pip self-upgrade corrupting the build venv Running 'pip install -U pip' during the build occasionally leaves mixed files from two pip versions if the process is interrupted, causing 'ImportError: cannot import name BuildDependencyInstallError' on subsequent runs. Fix by: - Adding '--clear' to venv creation so contaminated state is wiped - Removing the unnecessary pip self-upgrade step entirely --- pythonforandroid/build.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/pythonforandroid/build.py b/pythonforandroid/build.py index d88fdb1fe..c7b32d975 100644 --- a/pythonforandroid/build.py +++ b/pythonforandroid/build.py @@ -868,15 +868,11 @@ def run_pymodules_install(ctx, arch, modules, project_dir=None, # Use our hostpython to create the virtualenv host_python = sh.Command(ctx.hostpython) with current_directory(join(ctx.build_dir)): - shprint(host_python, '-m', 'venv', 'venv') + shprint(host_python, '-m', 'venv', '--clear', 'venv') - # Prepare base environment and upgrade pip: + # Prepare base environment: base_env = dict(copy.copy(os.environ)) base_env["PYTHONPATH"] = ctx.get_site_packages_dir(arch) - info('Upgrade pip to latest version') - shprint(sh.bash, '-c', ( - "source venv/bin/activate && pip install -U pip" - ), _env=copy.copy(base_env)) # Install Cython in case modules need it to build: info('Install Cython in case one of the modules needs it to build')