Skip to content

Commit 1ac76bc

Browse files
authored
Bundle newer version of pip (#1703)
1 parent 0d4b0d8 commit 1ac76bc

File tree

7 files changed

+31
-34
lines changed

7 files changed

+31
-34
lines changed

Src/StdLib/Lib/ensurepip/__init__.py

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,9 @@
88
__all__ = ["version", "bootstrap"]
99

1010

11-
_SETUPTOOLS_VERSION = "28.8.0"
12-
13-
_PIP_VERSION = "9.0.1"
14-
15-
# pip currently requires ssl support, so we try to provide a nicer
16-
# error message when that is missing (http://bugs.python.org/issue19744)
17-
_MISSING_SSL_MESSAGE = ("pip {} requires SSL/TLS".format(_PIP_VERSION))
18-
try:
19-
import ssl
20-
except ImportError:
21-
ssl = None
22-
def _require_ssl_for_pip():
23-
raise RuntimeError(_MISSING_SSL_MESSAGE)
24-
else:
25-
def _require_ssl_for_pip():
26-
pass
11+
_SETUPTOOLS_VERSION = "40.6.2"
12+
13+
_PIP_VERSION = "18.1"
2714

2815
_PROJECTS = [
2916
("setuptools", _SETUPTOOLS_VERSION),
@@ -37,8 +24,8 @@ def _run_pip(args, additional_paths=None):
3724
sys.path = additional_paths + sys.path
3825

3926
# Install the bundled software
40-
import pip
41-
pip.main(args)
27+
import pip._internal
28+
return pip._internal.main(args)
4229

4330

4431
def version():
@@ -66,12 +53,26 @@ def bootstrap(*, root=None, upgrade=False, user=False,
6653
Bootstrap pip into the current Python installation (or the given root
6754
directory).
6855
56+
Note that calling this function will alter both sys.path and os.environ.
57+
"""
58+
# Discard the return value
59+
_bootstrap(root=root, upgrade=upgrade, user=user,
60+
altinstall=altinstall, default_pip=default_pip,
61+
verbosity=verbosity)
62+
63+
64+
def _bootstrap(*, root=None, upgrade=False, user=False,
65+
altinstall=False, default_pip=False,
66+
verbosity=0):
67+
"""
68+
Bootstrap pip into the current Python installation (or the given root
69+
directory). Returns pip command status code.
70+
6971
Note that calling this function will alter both sys.path and os.environ.
7072
"""
7173
if altinstall and default_pip:
7274
raise ValueError("Cannot use altinstall and default_pip together")
7375

74-
_require_ssl_for_pip()
7576
_disable_pip_configuration_settings()
7677

7778
# By default, installing pip and setuptools installs all of the
@@ -115,7 +116,7 @@ def bootstrap(*, root=None, upgrade=False, user=False,
115116
if verbosity:
116117
args += ["-" + "v" * verbosity]
117118

118-
_run_pip(args + [p[0] for p in _PROJECTS], additional_paths)
119+
return _run_pip(args + [p[0] for p in _PROJECTS], additional_paths)
119120

120121
def _uninstall_helper(*, verbosity=0):
121122
"""Helper to support a clean default uninstall process on Windows
@@ -135,23 +136,17 @@ def _uninstall_helper(*, verbosity=0):
135136
print(msg.format(pip.__version__, _PIP_VERSION), file=sys.stderr)
136137
return
137138

138-
_require_ssl_for_pip()
139139
_disable_pip_configuration_settings()
140140

141141
# Construct the arguments to be passed to the pip command
142142
args = ["uninstall", "-y", "--disable-pip-version-check"]
143143
if verbosity:
144144
args += ["-" + "v" * verbosity]
145145

146-
_run_pip(args + [p[0] for p in reversed(_PROJECTS)])
146+
return _run_pip(args + [p[0] for p in reversed(_PROJECTS)])
147147

148148

149149
def _main(argv=None):
150-
if ssl is None:
151-
print("Ignoring ensurepip failure: {}".format(_MISSING_SSL_MESSAGE),
152-
file=sys.stderr)
153-
return
154-
155150
import argparse
156151
parser = argparse.ArgumentParser(prog="python -m ensurepip")
157152
parser.add_argument(
@@ -189,20 +184,20 @@ def _main(argv=None):
189184
"--altinstall",
190185
action="store_true",
191186
default=False,
192-
help=("Make an alternate install, installing only the X.Y versioned"
193-
"scripts (Default: pipX, pipX.Y, easy_install-X.Y)"),
187+
help=("Make an alternate install, installing only the X.Y versioned "
188+
"scripts (Default: pipX, pipX.Y, easy_install-X.Y)."),
194189
)
195190
parser.add_argument(
196191
"--default-pip",
197192
action="store_true",
198193
default=False,
199194
help=("Make a default pip install, installing the unqualified pip "
200-
"and easy_install in addition to the versioned scripts"),
195+
"and easy_install in addition to the versioned scripts."),
201196
)
202197

203198
args = parser.parse_args(argv)
204199

205-
bootstrap(
200+
return _bootstrap(
206201
root=args.root,
207202
upgrade=args.upgrade,
208203
user=args.user,
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import ensurepip
2+
import sys
23

34
if __name__ == "__main__":
4-
ensurepip._main()
5+
sys.exit(ensurepip._main())
1.26 MB
Binary file not shown.
-1.2 MB
Binary file not shown.
Binary file not shown.
Binary file not shown.

Src/StdLib/Lib/ensurepip/_uninstall.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import argparse
44
import ensurepip
5+
import sys
56

67

78
def _main(argv=None):
@@ -23,8 +24,8 @@ def _main(argv=None):
2324

2425
args = parser.parse_args(argv)
2526

26-
ensurepip._uninstall_helper(verbosity=args.verbosity)
27+
return ensurepip._uninstall_helper(verbosity=args.verbosity)
2728

2829

2930
if __name__ == "__main__":
30-
_main()
31+
sys.exit(_main())

0 commit comments

Comments
 (0)