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@ \
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: