Skip to content
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
1 change: 1 addition & 0 deletions news/10222.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix ``pip install --pre`` for packages with pre-release build dependencies defined both in ``pyproject.toml``'s ``build-system.requires`` and ``setup.py``'s ``setup_requires``.
2 changes: 1 addition & 1 deletion src/pip/_internal/build_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def check_requirements(
installed_req_str = f"{req.name}=={dist.version}"
else:
installed_req_str = f"{req.name}==={dist.version}"
if dist.version not in req.specifier:
if not req.specifier.contains(dist.version, prereleases=True):
conflicting.add((installed_req_str, req_str))
# FIXME: Consider direct URL?
return conflicting, missing
Expand Down
39 changes: 39 additions & 0 deletions tests/functional/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,45 @@ def test_editable_install__local_dir_setup_requires_with_pyproject(
script.pip("install", "--find-links", shared_data.find_links, "-e", local_dir)


def test_install_pre__setup_requires_with_pyproject(
script: PipTestEnvironment, shared_data: TestData, common_wheels: Path
) -> None:
"""
Test installing with a pre-release build dependency declared in both
setup.py and pyproject.toml.

https://github.com/pypa/pip/issues/10573
"""
depends_package = "prerelease_dependency"
depends_path = create_basic_wheel_for_package(script, depends_package, "1.0.0a1")

local_dir = script.scratch_path.joinpath("temp")
local_dir.mkdir()
pyproject_path = local_dir.joinpath("pyproject.toml")
pyproject_path.write_text(
"[build-system]\n"
f'requires = ["setuptools", "wheel", "{depends_package}"]\n'
'build-backend = "setuptools.build_meta"\n'
)
setup_py_path = local_dir.joinpath("setup.py")
setup_py_path.write_text(
"from setuptools import setup\n"
f"setup(name='dummy', setup_requires=['{depends_package}'])\n"
)

Comment on lines +806 to +816
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, these should likely be two separate test cases, one for each config.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue arises when build dependencies are both declared in setup.py and pyproject.toml, else it is fine.
Maybe that's a case that's not supported, but it worked until v21.2.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh huh interesting. I guess there’s some conflict with pip and setuptools’s build dependency population logic.

script.pip(
"install",
"--pre",
"--no-cache-dir",
"--no-index",
"--find-links",
common_wheels,
"--find-links",
depends_path.parent,
local_dir,
)


@pytest.mark.network
def test_upgrade_argparse_shadowed(script: PipTestEnvironment) -> None:
# If argparse is installed - even if shadowed for imported - we support
Expand Down