From 6256fcbc97e0b1a1e0df1972221232b3a78dff18 Mon Sep 17 00:00:00 2001 From: Nick Coghlan Date: Mon, 23 Dec 2013 16:16:07 +1000 Subject: Close #19734: ignore pip env vars in ensurepip --- Lib/ensurepip/__init__.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'Lib/ensurepip') diff --git a/Lib/ensurepip/__init__.py b/Lib/ensurepip/__init__.py index b6bc4b606e..5ceda516a2 100644 --- a/Lib/ensurepip/__init__.py +++ b/Lib/ensurepip/__init__.py @@ -43,10 +43,18 @@ def bootstrap(*, root=None, upgrade=False, user=False, """ Bootstrap pip into the current Python installation (or the given root directory). + + Note that calling this function will alter both sys.path and os.environ. """ if altinstall and default_pip: raise ValueError("Cannot use altinstall and default_pip together") + # We deliberately ignore all pip environment variables + # See http://bugs.python.org/issue19734 for details + keys_to_remove = [k for k in os.environ if k.startswith("PIP_")] + for k in keys_to_remove: + del os.environ[k] + # By default, installing pip and setuptools installs all of the # following scripts (X.Y == running Python version): # -- cgit v1.2.1