Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure to not use setuptools>=71. #159

Merged
merged 2 commits into from
Aug 17, 2024
Merged
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
30 changes: 27 additions & 3 deletions src/pip_deepfreeze/sanity.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,15 @@
or (
# pip not installed in target python env and local pip is not compatible
# with target python, so we'll need pkg_resources to inspect with
# env-info-json.py
# pip-list-json.py
not pip_version and not local_pip_compatible(python)
)
):
setuptools_install_cmd = shlex.join(
[python, "-m", "pip", "install", "setuptools"]
[python, "-m", "pip", "install", "setuptools<71"]
)
pip_upgrade_cmd = shlex.join(
[python, "-m", "pip", "install", "--upgrade", "pip"]
[python, "-m", "pip", "install", "--upgrade", "pip>=22.2"]
)
log_error(
f"pkg_resources is not available to {python}. It is currently "
Expand All @@ -119,6 +119,30 @@
f"installs pkg_resources with '{setuptools_install_cmd}'."
)
return False
setuptools_version = env_info.get("setuptools_version")
if (
setuptools_version
and Version(setuptools_version) >= Version("71")
and pip_version
and Version(pip_version) < Version("22.2")
):
# In setuptools>=71, pkg_resources.working_set reports setuptools'
# vendored dependencies, so we can't rely on it to inspect the
# environment.
# https://github.com/pypa/setuptools/issues/4516
setuptools_downgrade_cmd = shlex.join(

Check warning on line 133 in src/pip_deepfreeze/sanity.py

View check run for this annotation

Codecov / codecov/patch

src/pip_deepfreeze/sanity.py#L133

Added line #L133 was not covered by tests
[python, "-m", "pip", "install", "setuptools<71"]
)
pip_upgrade_cmd = shlex.join(

Check warning on line 136 in src/pip_deepfreeze/sanity.py

View check run for this annotation

Codecov / codecov/patch

src/pip_deepfreeze/sanity.py#L136

Added line #L136 was not covered by tests
[python, "-m", "pip", "install", "--upgrade", "pip>=22.2"]
)
log_error(

Check warning on line 139 in src/pip_deepfreeze/sanity.py

View check run for this annotation

Codecov / codecov/patch

src/pip_deepfreeze/sanity.py#L139

Added line #L139 was not covered by tests
f"setuptools>=71 has a version of pkg_resources that cannot be "
f"used to reliably inspect the environment. You need to downgrade "
f"setuptools with '{setuptools_downgrade_cmd}' or upgrade pip with "
f"'{pip_upgrade_cmd}'."
)
return False

Check warning on line 145 in src/pip_deepfreeze/sanity.py

View check run for this annotation

Codecov / codecov/patch

src/pip_deepfreeze/sanity.py#L145

Added line #L145 was not covered by tests
# Testing for pip must be done after testing for pkg_resources, because
# pkg_resources is needed to obtain the pip version for python < 3.8.
if not pip_version and not local_pip_compatible(python):
Expand Down
4 changes: 2 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def virtualenv_python(tmp_path, testpkgs):
testpkgs,
"-U",
"pip",
"setuptools",
"setuptools<71", # https://github.com/pypa/setuptools/issues/4516
"wheel",
]
)
Expand Down Expand Up @@ -91,7 +91,7 @@ def testpkgs(tmp_path_factory):
"-m",
"pip",
"wheel",
"setuptools",
"setuptools<71", # https://github.com/pypa/setuptools/issues/4516
"wheel",
"--wheel-dir",
str(testpkgs_dir),
Expand Down
14 changes: 13 additions & 1 deletion tests/test_pip.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import subprocess
import sys
import textwrap
from typing import Iterable, Iterator

Expand Down Expand Up @@ -378,7 +379,18 @@ def test_pip_upgrade_vcs_url(


@pytest.mark.parametrize(
"pip_list_function", (_pip_list__env_info_json, _pip_list__pip_inspect, pip_list)
"pip_list_function",
(
pytest.param(
_pip_list__env_info_json,
marks=pytest.mark.skipif(
sys.version_info >= (3, 12),
reason="All pip versions that support Python 3.12 have pip inspect",
),
),
_pip_list__pip_inspect,
pip_list,
),
)
def test_pip_list(virtualenv_python, testpkgs, pip_list_function):
subprocess.check_call(
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ python =
extras = test
usedevelop = true
commands =
pytest -n auto --cov --cov-branch --cov-report=xml --cov-report=html --cov-report=term {posargs}
pytest -vv -n auto --cov --cov-branch --cov-report=xml --cov-report=html --cov-report=term {posargs}

[testenv:py27]
# run only helper scripts tests on python 2
Expand Down
Loading