diff --git a/Lib/ensurepip/__init__.py b/Lib/ensurepip/__init__.py index 9f5d15109a..eb0644a1c6 100644 --- a/Lib/ensurepip/__init__.py +++ b/Lib/ensurepip/__init__.py @@ -46,12 +46,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. """ @@ -92,6 +92,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: @@ -164,6 +166,11 @@ def _main(argv=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", default=False, @@ -182,6 +189,7 @@ def _main(argv=None): 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 ee1cd4a028..5466504819 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -1054,7 +1054,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 @@ -1064,7 +1064,7 @@ altinstall: commoninstall install|*) ensurepip="--altinstall" ;; \ esac; \ $(RUNSHARED) $(PYTHON_FOR_BUILD) -m ensurepip \ - $$ensurepip --root=$(DESTDIR)/ ; \ + $$ensurepip --root=$(DESTDIR)/ --prefix=$(prefix) ; \ fi commoninstall: @FRAMEWORKALTINSTALLFIRST@ \