Don't preinstall setuptools and wheel, remove from constraints

Reasons to do this:

- setuptools is no longer the only game in town. When cibuildwheel was created, setuptools was the only way to make wheels. these days, there are many build backends so special casing setuptools doesn't make so much sense
- we don't need to preinstall `wheel` any more, setuptools will do that itself when it needs it.
- projects with pyproject.toml (i.e. the vast majority of projects going forward) don't benefit from the pin anyway, because both `pip` and `build` create an isolated environment to install `build-system.requires` into.
- this makes it easier for end users (such as @webknjaz) to control build-system versions using `PIP_CONSTRAINT`, because there's less potential for a user-specified version to conflict with one of our pins.
  - (long-term, I'd love `build` to [support this directly](https://github.com/pypa/build/issues/292), and then we could have a proper way to keep pyproject.toml dependencies loose and forward-compatible while retaining build determinism. But PIP_CONSTRAINT is the best we have for now. PIP_CONSTRAINT isn't ideal because it affects other things, like the test virtualenv).

This PR also adds a pin for pypa/build. It appears that was missing before, but we should pin it.
This commit is contained in:
Joe Rickerby
2024-01-20 18:44:03 +00:00
parent 93542c397c
commit 9879937c63
13 changed files with 109 additions and 74 deletions
-2
View File
@@ -287,8 +287,6 @@ def setup_python(
"pip",
"install",
"--upgrade",
"setuptools",
"wheel",
"delocate",
*dependency_constraint_flags,
env=env,
@@ -4,6 +4,8 @@
#
# nox -s update_constraints-3.10
#
build==1.0.3
# via -r cibuildwheel/resources/constraints.in
delocate==0.10.7
# via -r cibuildwheel/resources/constraints.in
distlib==0.3.8
@@ -11,18 +13,22 @@ distlib==0.3.8
filelock==3.13.1
# via virtualenv
packaging==23.2
# via delocate
# via
# build
# delocate
platformdirs==4.1.0
# via virtualenv
pyproject-hooks==1.0.0
# via build
tomli==2.0.1
# via
# build
# pyproject-hooks
typing-extensions==4.9.0
# via delocate
virtualenv==20.25.0
# via -r cibuildwheel/resources/constraints.in
wheel==0.42.0
# via -r cibuildwheel/resources/constraints.in
# The following packages are considered to be unsafe in a requirements file:
pip==23.3.2
# via -r cibuildwheel/resources/constraints.in
setuptools==69.0.3
# via -r cibuildwheel/resources/constraints.in
@@ -4,6 +4,8 @@
#
# nox -s update_constraints-3.11
#
build==1.0.3
# via -r cibuildwheel/resources/constraints.in
delocate==0.10.7
# via -r cibuildwheel/resources/constraints.in
distlib==0.3.8
@@ -11,18 +13,18 @@ distlib==0.3.8
filelock==3.13.1
# via virtualenv
packaging==23.2
# via delocate
# via
# build
# delocate
platformdirs==4.1.0
# via virtualenv
pyproject-hooks==1.0.0
# via build
typing-extensions==4.9.0
# via delocate
virtualenv==20.25.0
# via -r cibuildwheel/resources/constraints.in
wheel==0.42.0
# via -r cibuildwheel/resources/constraints.in
# The following packages are considered to be unsafe in a requirements file:
pip==23.3.2
# via -r cibuildwheel/resources/constraints.in
setuptools==69.0.3
# via -r cibuildwheel/resources/constraints.in
@@ -4,6 +4,8 @@
#
# nox -s update_constraints-3.12
#
build==1.0.3
# via -r cibuildwheel/resources/constraints.in
delocate==0.10.7
# via -r cibuildwheel/resources/constraints.in
distlib==0.3.8
@@ -11,18 +13,18 @@ distlib==0.3.8
filelock==3.13.1
# via virtualenv
packaging==23.2
# via delocate
# via
# build
# delocate
platformdirs==4.1.0
# via virtualenv
pyproject-hooks==1.0.0
# via build
typing-extensions==4.9.0
# via delocate
virtualenv==20.25.0
# via -r cibuildwheel/resources/constraints.in
wheel==0.42.0
# via -r cibuildwheel/resources/constraints.in
# The following packages are considered to be unsafe in a requirements file:
pip==23.3.2
# via -r cibuildwheel/resources/constraints.in
setuptools==69.0.3
# via -r cibuildwheel/resources/constraints.in
@@ -4,18 +4,33 @@
#
# nox -s update_constraints-3.6
#
build==0.9.0
# via -r cibuildwheel/resources/constraints.in
delocate==0.10.2
# via -r cibuildwheel/resources/constraints.in
distlib==0.3.6
distlib==0.3.8
# via virtualenv
filelock==3.4.1
# via virtualenv
importlib-metadata==4.8.3
# via virtualenv
# via
# build
# pep517
# virtualenv
importlib-resources==5.4.0
# via virtualenv
packaging==21.3
# via build
pep517==0.13.1
# via build
platformdirs==2.4.0
# via virtualenv
pyparsing==3.1.1
# via packaging
tomli==1.2.3
# via
# build
# pep517
typing-extensions==4.1.1
# via
# delocate
@@ -23,16 +38,13 @@ typing-extensions==4.1.1
virtualenv==20.17.1
# via -r cibuildwheel/resources/constraints.in
wheel==0.37.1
# via
# -r cibuildwheel/resources/constraints.in
# delocate
# via delocate
zipp==3.6.0
# via
# importlib-metadata
# importlib-resources
# pep517
# The following packages are considered to be unsafe in a requirements file:
pip==21.3.1
# via -r cibuildwheel/resources/constraints.in
setuptools==59.6.0
# via -r cibuildwheel/resources/constraints.in
@@ -4,6 +4,8 @@
#
# nox -s update_constraints-3.7
#
build==1.0.3
# via -r cibuildwheel/resources/constraints.in
delocate==0.10.7
# via -r cibuildwheel/resources/constraints.in
distlib==0.3.8
@@ -11,11 +13,21 @@ distlib==0.3.8
filelock==3.12.2
# via virtualenv
importlib-metadata==6.7.0
# via virtualenv
# via
# build
# virtualenv
packaging==23.2
# via delocate
# via
# build
# delocate
platformdirs==4.0.0
# via virtualenv
pyproject-hooks==1.0.0
# via build
tomli==2.0.1
# via
# build
# pyproject-hooks
typing-extensions==4.7.1
# via
# delocate
@@ -23,13 +35,9 @@ typing-extensions==4.7.1
# platformdirs
virtualenv==20.25.0
# via -r cibuildwheel/resources/constraints.in
wheel==0.42.0
# via -r cibuildwheel/resources/constraints.in
zipp==3.15.0
# via importlib-metadata
# The following packages are considered to be unsafe in a requirements file:
pip==23.3.2
# via -r cibuildwheel/resources/constraints.in
setuptools==68.0.0
# via -r cibuildwheel/resources/constraints.in
@@ -4,25 +4,35 @@
#
# nox -s update_constraints-3.8
#
build==1.0.3
# via -r cibuildwheel/resources/constraints.in
delocate==0.10.7
# via -r cibuildwheel/resources/constraints.in
distlib==0.3.8
# via virtualenv
filelock==3.13.1
# via virtualenv
importlib-metadata==7.0.1
# via build
packaging==23.2
# via delocate
# via
# build
# delocate
platformdirs==4.1.0
# via virtualenv
pyproject-hooks==1.0.0
# via build
tomli==2.0.1
# via
# build
# pyproject-hooks
typing-extensions==4.9.0
# via delocate
virtualenv==20.25.0
# via -r cibuildwheel/resources/constraints.in
wheel==0.42.0
# via -r cibuildwheel/resources/constraints.in
zipp==3.17.0
# via importlib-metadata
# The following packages are considered to be unsafe in a requirements file:
pip==23.3.2
# via -r cibuildwheel/resources/constraints.in
setuptools==69.0.3
# via -r cibuildwheel/resources/constraints.in
@@ -4,25 +4,35 @@
#
# nox -s update_constraints-3.9
#
build==1.0.3
# via -r cibuildwheel/resources/constraints.in
delocate==0.10.7
# via -r cibuildwheel/resources/constraints.in
distlib==0.3.8
# via virtualenv
filelock==3.13.1
# via virtualenv
importlib-metadata==7.0.1
# via build
packaging==23.2
# via delocate
# via
# build
# delocate
platformdirs==4.1.0
# via virtualenv
pyproject-hooks==1.0.0
# via build
tomli==2.0.1
# via
# build
# pyproject-hooks
typing-extensions==4.9.0
# via delocate
virtualenv==20.25.0
# via -r cibuildwheel/resources/constraints.in
wheel==0.42.0
# via -r cibuildwheel/resources/constraints.in
zipp==3.17.0
# via importlib-metadata
# The following packages are considered to be unsafe in a requirements file:
pip==23.3.2
# via -r cibuildwheel/resources/constraints.in
setuptools==69.0.3
# via -r cibuildwheel/resources/constraints.in
+1 -2
View File
@@ -1,5 +1,4 @@
pip
setuptools
wheel
build
delocate
virtualenv
+7 -5
View File
@@ -4,6 +4,8 @@
#
# nox -s update_constraints-3.12
#
build==1.0.3
# via -r cibuildwheel/resources/constraints.in
delocate==0.10.7
# via -r cibuildwheel/resources/constraints.in
distlib==0.3.8
@@ -11,18 +13,18 @@ distlib==0.3.8
filelock==3.13.1
# via virtualenv
packaging==23.2
# via delocate
# via
# build
# delocate
platformdirs==4.1.0
# via virtualenv
pyproject-hooks==1.0.0
# via build
typing-extensions==4.9.0
# via delocate
virtualenv==20.25.0
# via -r cibuildwheel/resources/constraints.in
wheel==0.42.0
# via -r cibuildwheel/resources/constraints.in
# The following packages are considered to be unsafe in a requirements file:
pip==23.3.2
# via -r cibuildwheel/resources/constraints.in
setuptools==69.0.3
# via -r cibuildwheel/resources/constraints.in
+1 -13
View File
@@ -315,17 +315,7 @@ def setup_python(
call("pip", "--version", env=env)
log.step("Installing build tools...")
if build_frontend == "pip":
call(
"pip",
"install",
"--upgrade",
"setuptools",
"wheel",
*dependency_constraint_flags,
env=env,
)
elif build_frontend == "build":
if build_frontend == "build":
call(
"pip",
"install",
@@ -334,8 +324,6 @@ def setup_python(
*dependency_constraint_flags,
env=env,
)
else:
assert_never(build_frontend)
if python_libs_base:
# Set up the environment for various backends to enable cross-compilation
+1 -1
View File
@@ -9,7 +9,7 @@ import nox
nox.options.sessions = ["lint", "pylint", "check_manifest", "tests"]
PYTHON_ALL_VERSIONS = ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
PYTHON_ALL_VERSIONS = ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
DIR = Path(__file__).parent.resolve()
+11 -13
View File
@@ -27,7 +27,9 @@ project_with_expected_version_checks = test_projects.new_c_project(
print('Gathered versions', versions)
for package_name in ['pip', 'setuptools', 'wheel']:
packages_to_test = ['pip']
for package_name in packages_to_test:
env_name = 'EXPECTED_{}_VERSION'.format(package_name.upper())
expected_version = os.environ[env_name]
@@ -48,7 +50,7 @@ def get_versions_from_constraint_file(constraint_file):
return dict(re.findall(VERSION_REGEX, constraint_file_text))
@pytest.mark.parametrize("python_version", ["3.6", "3.8", "3.9"])
@pytest.mark.parametrize("python_version", ["3.6", "3.8", "3.10"])
def test_pinned_versions(tmp_path, python_version, build_frontend_env):
if utils.platform == "linux":
pytest.skip("linux doesn't pin individual tool versions, it pins manylinux images instead")
@@ -70,13 +72,13 @@ def test_pinned_versions(tmp_path, python_version, build_frontend_env):
constraint_filename = "constraints-python38.txt"
build_pattern = "[cp]p38-*"
else:
constraint_filename = "constraints.txt"
build_pattern = "[cp]p39-*"
constraint_filename = "constraints-python310.txt"
build_pattern = "[cp]p310-*"
constraint_file = cibuildwheel.util.resources_dir / constraint_filename
constraint_versions = get_versions_from_constraint_file(constraint_file)
for package in ["pip", "setuptools", "wheel", "virtualenv"]:
for package in ["pip"]:
env_name = f"EXPECTED_{package.upper()}_VERSION"
build_environment[env_name] = constraint_versions[package]
@@ -101,9 +103,9 @@ def test_pinned_versions(tmp_path, python_version, build_frontend_env):
expected_wheels = [
w for w in utils.expected_wheels("spam", "0.1.0") if "-cp38" in w or "-pp38" in w
]
elif python_version == "3.9":
elif python_version == "3.10":
expected_wheels = [
w for w in utils.expected_wheels("spam", "0.1.0") if "-cp39" in w or "-pp39" in w
w for w in utils.expected_wheels("spam", "0.1.0") if "-cp310" in w or "-pp310" in w
]
else:
msg = "unhandled python version"
@@ -121,9 +123,7 @@ def test_dependency_constraints_file(tmp_path, build_frontend_env):
tool_versions = {
"pip": "23.1.2",
"setuptools": "67.7.2",
"wheel": "0.38.3",
"virtualenv": "20.23.0",
"delocate": "0.10.3",
}
constraints_file = tmp_path / "constraints file.txt"
@@ -131,9 +131,7 @@ def test_dependency_constraints_file(tmp_path, build_frontend_env):
textwrap.dedent(
"""
pip=={pip}
setuptools=={setuptools}
wheel=={wheel}
virtualenv=={virtualenv}
delocate=={delocate}
importlib-metadata<3,>=0.12; python_version < "3.8"
""".format(**tool_versions)
)