Skip to content

Commit 9e55ac3

Browse files
committed
Drop run-time version constraints for modern Pip
Modern Pip (v9.0.0+) supports `Requires-Python` and so automatically takes the current Python version into account, when determining the latest version of packages that can be installed. As such, for modern Pip we don't need to specify version range constraints for the pip/setuptools/wheel versions passed to the `pip install` at `get-pip.py` run-time. This is the first step towards being able to remove `SCRIPT_CONSTRAINTS` and rely purely on `Requires-Python` metadata, per: #88 (comment) I've intentionally left the "figure out what Pip version to embed in the template" part of template generation alone for now to keep the PR smaller, and have only changed the run-time `pip install` parts. I had to add a new `pre-9.py` template file (created as a copy of `pre-10.py`), since it's only pip<9 that needs the various version constraint references in the template (and otherwise anything else that used `pre-10.py`, such as Python 2.6, would have had redundant version constraints). The new `pre-9.py` template is only used for Python 3.2.
1 parent d03a9e8 commit 9e55ac3

File tree

14 files changed

+246
-52
lines changed

14 files changed

+246
-52
lines changed

public/2.6/get-pip.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,11 @@ def parse_args(self, args):
147147

148148
# Add any implicit installations to the end of our args
149149
if implicit_pip:
150-
args += ["pip<10"]
150+
args += ["pip"]
151151
if implicit_setuptools:
152-
args += ["setuptools<37"]
152+
args += ["setuptools"]
153153
if implicit_wheel:
154-
args += ["wheel<0.30"]
154+
args += ["wheel"]
155155

156156
delete_tmpdir = False
157157
try:

public/2.7/get-pip.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,9 @@ def cert_parse_args(self, args):
149149

150150
# Add any implicit installations to the end of our args
151151
if implicit_pip:
152-
args += ["pip<21.0"]
152+
args += ["pip"]
153153
if implicit_setuptools:
154-
args += ["setuptools<45"]
154+
args += ["setuptools"]
155155
if implicit_wheel:
156156
args += ["wheel"]
157157

public/3.3/get-pip.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,11 @@ def parse_args(self, args):
147147

148148
# Add any implicit installations to the end of our args
149149
if implicit_pip:
150-
args += ["pip<18"]
150+
args += ["pip"]
151151
if implicit_setuptools:
152152
args += ["setuptools"]
153153
if implicit_wheel:
154-
args += ["wheel<0.30"]
154+
args += ["wheel"]
155155

156156
# Add our default arguments
157157
args = ["install", "--upgrade", "--force-reinstall"] + args

public/3.4/get-pip.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def parse_args(self, args):
147147

148148
# Add any implicit installations to the end of our args
149149
if implicit_pip:
150-
args += ["pip<19.2"]
150+
args += ["pip"]
151151
if implicit_setuptools:
152152
args += ["setuptools"]
153153
if implicit_wheel:

public/3.5/get-pip.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def cert_parse_args(self, args):
149149

150150
# Add any implicit installations to the end of our args
151151
if implicit_pip:
152-
args += ["pip<21.0"]
152+
args += ["pip"]
153153
if implicit_setuptools:
154154
args += ["setuptools"]
155155
if implicit_wheel:

public/3.6/get-pip.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def determine_pip_install_arguments():
6969
pre_parser.add_argument("--no-wheel", action="store_true")
7070
pre, args = pre_parser.parse_known_args()
7171

72-
args.append("pip<22.0")
72+
args.append("pip")
7373

7474
if include_setuptools(pre):
7575
args.append("setuptools")

public/3.7/get-pip.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def determine_pip_install_arguments():
6969
pre_parser.add_argument("--no-wheel", action="store_true")
7070
pre, args = pre_parser.parse_known_args()
7171

72-
args.append("pip<24.1")
72+
args.append("pip")
7373

7474
if include_setuptools(pre):
7575
args.append("setuptools")

scripts/generate.py

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,48 +23,34 @@
2323
SCRIPT_CONSTRAINTS = {
2424
"default": {
2525
"pip": "",
26-
"setuptools": "",
27-
"wheel": "",
2826
},
2927
"2.6": {
3028
"pip": "<10",
31-
"setuptools": "<37",
32-
"wheel": "<0.30",
3329
},
3430
"2.7": {
3531
"pip": "<21.0",
36-
"setuptools": "<45",
37-
"wheel": "",
3832
},
3933
"3.2": {
34+
# Pip older than v9.0.0 does not support Requires-Python so we have to manually
35+
# constrain the pip, setuptools and wheel versions that are installed at runtime.
4036
"pip": "<8",
4137
"setuptools": "<30",
4238
"wheel": "<0.30",
4339
},
4440
"3.3": {
4541
"pip": "<18",
46-
"setuptools": "",
47-
"wheel": "<0.30",
4842
},
4943
"3.4": {
5044
"pip": "<19.2",
51-
"setuptools": "",
52-
"wheel": "",
5345
},
5446
"3.5": {
5547
"pip": "<21.0",
56-
"setuptools": "",
57-
"wheel": "",
5848
},
5949
"3.6": {
6050
"pip": "<22.0",
61-
"setuptools": "",
62-
"wheel": "",
6351
},
6452
"3.7": {
6553
"pip": "<24.1",
66-
"setuptools": "",
67-
"wheel": "",
6854
},
6955
}
7056

@@ -248,7 +234,7 @@ def detect_newline(f: TextIO) -> str:
248234

249235

250236
def generate_one(variant, mapping, *, console, pip_versions):
251-
# Determing the correct wheel to download
237+
# Determine the correct wheel to download
252238
pip_version = determine_latest(pip_versions.keys(), constraint=mapping["pip"])
253239
wheel_url, wheel_hash = pip_versions[pip_version]
254240

@@ -264,10 +250,11 @@ def generate_one(variant, mapping, *, console, pip_versions):
264250
newline = detect_newline(f)
265251
rendered_template = f.read().format(
266252
zipfile=encoded_wheel,
267-
installed_version=pip_version,
268-
pip_version=mapping["pip"],
269-
setuptools_version=mapping["setuptools"],
270-
wheel_version=mapping["wheel"],
253+
bundled_pip_version=pip_version,
254+
# These constraints are only used for pip versions that don't support Requires-Python.
255+
pip_version_constraint=mapping.get("pip"),
256+
setuptools_version_constraint=mapping.get("setuptools"),
257+
wheel_version_constraint=mapping.get("wheel"),
271258
minimum_supported_version=mapping["minimum_supported_version"],
272259
)
273260
# Write the script to the correct location

templates/default.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# You may be wondering what this giant blob of binary data here is, you might
66
# even be worried that we're up to something nefarious (good for you for being
77
# paranoid!). This is a base85 encoding of a zip file, this zip file contains
8-
# an entire copy of pip (version {installed_version}).
8+
# an entire copy of pip (version {bundled_pip_version}).
99
#
1010
# Pip is a thing that installs packages, pip itself is a package that someone
1111
# might want to install, especially if they're looking to run this get-pip.py
@@ -69,13 +69,13 @@ def determine_pip_install_arguments():
6969
pre_parser.add_argument("--no-wheel", action="store_true")
7070
pre, args = pre_parser.parse_known_args()
7171

72-
args.append("pip{pip_version}")
72+
args.append("pip")
7373

7474
if include_setuptools(pre):
75-
args.append("setuptools{setuptools_version}")
75+
args.append("setuptools")
7676

7777
if include_wheel(pre):
78-
args.append("wheel{wheel_version}")
78+
args.append("wheel")
7979

8080
return ["install", "--upgrade", "--force-reinstall"] + args
8181

templates/pre-10.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# You may be wondering what this giant blob of binary data here is, you might
66
# even be worried that we're up to something nefarious (good for you for being
77
# paranoid!). This is a base85 encoding of a zip file, this zip file contains
8-
# an entire copy of pip (version {installed_version}).
8+
# an entire copy of pip (version {bundled_pip_version}).
99
#
1010
# Pip is a thing that installs packages, pip itself is a package that someone
1111
# might want to install, especially if they're looking to run this get-pip.py
@@ -147,11 +147,11 @@ def parse_args(self, args):
147147

148148
# Add any implicit installations to the end of our args
149149
if implicit_pip:
150-
args += ["pip{pip_version}"]
150+
args += ["pip"]
151151
if implicit_setuptools:
152-
args += ["setuptools{setuptools_version}"]
152+
args += ["setuptools"]
153153
if implicit_wheel:
154-
args += ["wheel{wheel_version}"]
154+
args += ["wheel"]
155155

156156
delete_tmpdir = False
157157
try:

templates/pre-18.1.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# You may be wondering what this giant blob of binary data here is, you might
66
# even be worried that we're up to something nefarious (good for you for being
77
# paranoid!). This is a base85 encoding of a zip file, this zip file contains
8-
# an entire copy of pip (version {installed_version}).
8+
# an entire copy of pip (version {bundled_pip_version}).
99
#
1010
# Pip is a thing that installs packages, pip itself is a package that someone
1111
# might want to install, especially if they're looking to run this get-pip.py
@@ -147,11 +147,11 @@ def parse_args(self, args):
147147

148148
# Add any implicit installations to the end of our args
149149
if implicit_pip:
150-
args += ["pip{pip_version}"]
150+
args += ["pip"]
151151
if implicit_setuptools:
152-
args += ["setuptools{setuptools_version}"]
152+
args += ["setuptools"]
153153
if implicit_wheel:
154-
args += ["wheel{wheel_version}"]
154+
args += ["wheel"]
155155

156156
# Add our default arguments
157157
args = ["install", "--upgrade", "--force-reinstall"] + args

templates/pre-19.3.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# You may be wondering what this giant blob of binary data here is, you might
66
# even be worried that we're up to something nefarious (good for you for being
77
# paranoid!). This is a base85 encoding of a zip file, this zip file contains
8-
# an entire copy of pip (version {installed_version}).
8+
# an entire copy of pip (version {bundled_pip_version}).
99
#
1010
# Pip is a thing that installs packages, pip itself is a package that someone
1111
# might want to install, especially if they're looking to run this get-pip.py
@@ -147,11 +147,11 @@ def parse_args(self, args):
147147

148148
# Add any implicit installations to the end of our args
149149
if implicit_pip:
150-
args += ["pip{pip_version}"]
150+
args += ["pip"]
151151
if implicit_setuptools:
152-
args += ["setuptools{setuptools_version}"]
152+
args += ["setuptools"]
153153
if implicit_wheel:
154-
args += ["wheel{wheel_version}"]
154+
args += ["wheel"]
155155

156156
# Add our default arguments
157157
args = ["install", "--upgrade", "--force-reinstall"] + args

templates/pre-21.0.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# You may be wondering what this giant blob of binary data here is, you might
66
# even be worried that we're up to something nefarious (good for you for being
77
# paranoid!). This is a base85 encoding of a zip file, this zip file contains
8-
# an entire copy of pip (version {installed_version}).
8+
# an entire copy of pip (version {bundled_pip_version}).
99
#
1010
# Pip is a thing that installs packages, pip itself is a package that someone
1111
# might want to install, especially if they're looking to run this get-pip.py
@@ -149,11 +149,11 @@ def cert_parse_args(self, args):
149149

150150
# Add any implicit installations to the end of our args
151151
if implicit_pip:
152-
args += ["pip{pip_version}"]
152+
args += ["pip"]
153153
if implicit_setuptools:
154-
args += ["setuptools{setuptools_version}"]
154+
args += ["setuptools"]
155155
if implicit_wheel:
156-
args += ["wheel{wheel_version}"]
156+
args += ["wheel"]
157157

158158
# Add our default arguments
159159
args = ["install", "--upgrade", "--force-reinstall"] + args

0 commit comments

Comments
 (0)