From e5d121c58f626d28c06aaf4111353fd324ac69bd Mon Sep 17 00:00:00 2001 From: Xavier de Gaye Date: Wed, 26 Jul 2017 18:39:00 +0200 Subject: [PATCH] ensurepip should honour the value of $(prefix) When cross-compiling, the local Python interpreter that is used to run ensurepip may not have the same value of sys.prefix as the value of the 'prefix' variable that is set in the Makefile. With the following values used to install Python locally for a later copy to the files hierarchy owned by the 'termux' application on an Android device: DESTDIR=/tmp/android prefix=/data/data/com.termux/files/usr/local 'make install' causes ensurepip to install pip in $(DESTDIR)/usr/local instead of the expected $(DESTDIR)/$(prefix) where is installed the standard library. The attached patch fixes the problem. The patch was implemented assuming that pip uses distutils for the installation (note that setup.py also uses the --prefix option in the Makefile), but I know nothing about pip so forgive me if the patch is wrong and please just assume it is just a way to demonstrate the problem. bpo-31046 --- Lib/ensurepip/__init__.py | 12 ++++++++++-- Makefile.pre.in | 4 ++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Lib/ensurepip/__init__.py b/Lib/ensurepip/__init__.py index 545fce656fd6f5..e07fa388ce9036 100644 --- a/Lib/ensurepip/__init__.py +++ b/Lib/ensurepip/__init__.py @@ -59,12 +59,12 @@ def _disable_pip_configuration_settings(): os.environ['PIP_CONFIG_FILE'] = os.devnull -def bootstrap(*, root=None, upgrade=False, user=False, +def bootstrap(*, root=None, prefix=None, upgrade=False, user=False, altinstall=False, default_pip=False, verbosity=0): """ Bootstrap pip into the current Python installation (or the given root - directory). + and prefix directory). Note that calling this function will alter both sys.path and os.environ. """ @@ -122,6 +122,8 @@ def _bootstrap(*, root=None, upgrade=False, user=False, args = ["install", "--no-index", "--find-links", tmpdir] if root: args += ["--root", root] + if prefix: + args += ["--prefix", prefix] if upgrade: args += ["--upgrade"] if user: @@ -193,6 +195,11 @@ def _main(argv=None): default=None, help="Install everything relative to this alternate root directory.", ) + parser.add_argument( + "--prefix", + default=None, + help="Install everything using this prefix.", + ) parser.add_argument( "--altinstall", action="store_true", @@ -212,6 +219,7 @@ def _main(argv=None): return _bootstrap( root=args.root, + prefix=args.prefix, upgrade=args.upgrade, user=args.user, verbosity=args.verbosity, diff --git a/Makefile.pre.in b/Makefile.pre.in index caa1d376485343..a5634e8b3dee68 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -1188,7 +1188,7 @@ install: @FRAMEWORKINSTALLFIRST@ commoninstall bininstall maninstall @FRAMEWORKI install|*) ensurepip="" ;; \ esac; \ $(RUNSHARED) $(PYTHON_FOR_BUILD) -m ensurepip \ - $$ensurepip --root=$(DESTDIR)/ ; \ + $$ensurepip --root=$(DESTDIR)/ --prefix=$(prefix) ; \ fi altinstall: commoninstall @@ -1198,7 +1198,7 @@ altinstall: commoninstall install|*) ensurepip="--altinstall" ;; \ esac; \ $(RUNSHARED) $(PYTHON_FOR_BUILD) -m ensurepip \ - $$ensurepip --root=$(DESTDIR)/ ; \ + $$ensurepip --root=$(DESTDIR)/ --prefix=$(prefix) ; \ fi commoninstall: check-clean-src @FRAMEWORKALTINSTALLFIRST@ \ pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy