-
-
Notifications
You must be signed in to change notification settings - Fork 614
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
Fix build deps compilation for setuptools < 70.1.0
#2106
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3431,7 +3431,6 @@ def test_compile_recursive_extras_build_targets(runner, tmp_path, current_resolv | |
""" | ||
) | ||
) | ||
(tmp_path / "constraints.txt").write_text("wheel<0.43") | ||
out = runner.invoke( | ||
cli, | ||
[ | ||
|
@@ -3446,15 +3445,82 @@ def test_compile_recursive_extras_build_targets(runner, tmp_path, current_resolv | |
"--find-links", | ||
os.fspath(MINIMAL_WHEELS_PATH), | ||
os.fspath(tmp_path / "pyproject.toml"), | ||
"--constraint", | ||
os.fspath(tmp_path / "constraints.txt"), | ||
"--output-file", | ||
"-", | ||
], | ||
) | ||
expected = rf"""foo[footest] @ {tmp_path.as_uri()} | ||
small-fake-a==0.2 | ||
small-fake-b==0.3 | ||
|
||
# The following packages are considered to be unsafe in a requirements file: | ||
# setuptools | ||
""" | ||
try: | ||
assert out.exit_code == 0 | ||
assert expected == out.stdout | ||
except Exception: # pragma: no cover | ||
print(out.stdout) | ||
print(out.stderr) | ||
raise | ||
webknjaz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
@backtracking_resolver_only | ||
def test_compile_build_targets_setuptools_no_wheel_dep( | ||
runner, | ||
tmp_path, | ||
current_resolver, | ||
): | ||
"""Check that user requests apply to build dependencies. | ||
|
||
This verifies that build deps compilation would not use the latest version | ||
of an unconstrained build requirements list, when the user requested | ||
restricting them. | ||
|
||
It is implemented against `setuptools < 70.1.0` which is known to inject a | ||
dependency on `wheel` (newer `setuptools` vendor it). The idea is that | ||
`pyproject.toml` does not have an upper bound for `setuptools` but the CLI | ||
arg does. And when this works correctly, the `wheel` entry will be included | ||
into the resolved output. | ||
|
||
This is a regression test for | ||
https://github.com/jazzband/pip-tools/pull/1681#issuecomment-2212541289. | ||
""" | ||
(tmp_path / "pyproject.toml").write_text( | ||
dedent( | ||
""" | ||
[project] | ||
name = "foo" | ||
version = "0.0.1" | ||
dependencies = ["small-fake-a"] | ||
""" | ||
) | ||
) | ||
(tmp_path / "constraints.txt").write_text("wheel<0.43") | ||
out = runner.invoke( | ||
cli, | ||
[ | ||
"--build-isolation", | ||
"--no-header", | ||
"--no-annotate", | ||
"--no-emit-options", | ||
"--extra", | ||
"dev", | ||
"--build-deps-for", | ||
"wheel", | ||
"--find-links", | ||
os.fspath(MINIMAL_WHEELS_PATH), | ||
os.fspath(tmp_path / "pyproject.toml"), | ||
"--constraint", | ||
os.fspath(tmp_path / "constraints.txt"), | ||
"--upgrade-package", | ||
"setuptools < 70.1.0", # setuptools>=70.1.0 doesn't require wheel any more | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FWIW, it'd be better to make it not need internet access. But that's not a blocker, just something to think about for the future. |
||
"--output-file", | ||
"-", | ||
], | ||
catch_exceptions=True, | ||
) | ||
expected = r"""small-fake-a==0.2 | ||
wheel==0.42.0 | ||
|
||
# The following packages are considered to be unsafe in a requirements file: | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, while debugging via tmate, I discovered that on Windows, this raises a
SubprocessError
from somewhere withinpypa/build
. I'm not yet sure what's happening. The command waspip install --pep517
something.. I didn't get to save it since the SSH session expires in about 40 minutes and I just lost it. I think, it's https://github.com/pypa/build/blob/88ae833/src/build/env.py#L257-L265.This then causes the visible error we saw in the logs —
[RuntimeError("generator didn't yield")]
(https://github.com/python/cpython/blob/6bc3e83/Lib/contextlib.py#L143). I'm not entirely sure why, though — might be a CPython bug.Now that I'm thinking about it, I'm curious if the order of the CMs in the
with
statement matters. Perhaps,build.env.DefaultIsolatedEnv()
gets interrupted and processes the__exit__()
first, suppressing the error. Then, the control flow of_create_project_builder()
is interrupted, never reaching theyield
, tripping the validation in the outer@contextlib.contextmanager()
decorator.Though, I don't understand why
SubprocessError
doesn't escape thewith
block… can it be https://github.com/python/cpython/blob/6bc3e83/Lib/contextlib.py#L163-L167?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calling
_create_project_builder()
orbuild_project_metadata()
doesn't seem to be enough to reproduce this. I suspect, Click might be the cause.