Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions Lib/ensurepip/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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",
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions Makefile.pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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@ \
Expand Down