-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Better detection of invalid __legacy__ PEP 517 projects #10534
Conversation
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.
I think this test should happen before build-backend
is set. If you invoke pip on something that it not a Python package, it will still say File 'setup.py' not found for legacy project ...
, instead of telling the use that the specified path/url is not a project.
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.
Should we include a test for this?
Of course :) |
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.
I don't think we should take this approach here, as I've just elaborated in the corresponding issue.
I'm also not going to spend any energy on this weekend though -- I'd rather get 21.3 ready, because that's much more relevant and useful. :)
src/pip/_internal/pyproject.py
Outdated
@@ -174,4 +174,9 @@ def load_pyproject_toml( | |||
backend = "setuptools.build_meta:__legacy__" | |||
check = ["setuptools>=40.8.0", "wheel"] | |||
|
|||
if backend == "setuptools.build_meta:__legacy__" and not has_setup: |
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.
setup.py-less projects should be permitted if they specify a pyproject.toml
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.
In which case they don't use the legacy backend, or ?
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.
Or what if a project lists setuptools.build_meta:__legacy__
as their build-backend? setup.py-less builds should definitely work then
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.
And if they don't, why is that a problem? They're explicitly opting into legacy behaviour.
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.
Right but setuptools.build_meta:__legacy__
automatically generates a setup.py
if it's missing
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.
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.
I'm aware of the behaviour of setuptools, and that isn't an answer to the question asked.
Let me rephrase: Why should "setup.py-less" projects work when they're using the setuptools.build_meta:__legacy__
backend (whether implicitly, or through an explicit specification in the pyproject.toml
file)?
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.
Note that there's a very straightforward solution in those cases -- add the right pyproject.toml
content.
a64c732
to
a0e4d16
Compare
Or we could always reject projects that have neither a pyproject.toml nor a setup.py (PR updated to do that). |
I think I'm mildly in favour of keeping this. It's a low-effort way for users to move to completely declarative setups (especially until setuptools adds PEP 621 [project metadata in pyproject.toml] support) -- having editable installs work with that is a nice-to-have. FWIW, this whole thing will involve user-facing behaviour changes, so we'd need a deprecation cycle -- I'm in favour for that being expidited and only keeping it deprecated for a single release though. :) |
@pradyunsg to be clear, projects having a |
I think it's okay to treat |
Fair enough. This still needs a deprecation cycle though, because I do imagine folks showing up with pitchforks, because they can no longer use their cute setup.cfg-only projects. |
This has only existed since 21.2, and the solution is |
1ce9fba
to
29d5172
Compare
I agree with @sbidoul - I'd be comfortable treating this as a bug introduced in 21.2 and therefore this is a bugfix. We didn't document "pip will install projects that have |
From https://pip.pypa.io/en/stable/news/#v21-1:
This was introduced in 21.1.
This was "documented" in the changelog. This is definitely one of the ways we communicate about features, so I certainly consider this to need a deprecation cycle.
Only if your project does not have any other build-time dependencies. If you have build-time dependencies that you just install in your build environment, and/or if you're sensitive to what headers you're compiled against (eg: numpy's headers), then this doesn't work. |
To be clear, I'm not advocating to keeping the setup.cfg-only-works behaviour anymore -- but rather, that we should remove it with a deprecation cycle. I'm on board for only having the deprecation for a single release cycle as well. |
I thought |
Ah, OK. I took "since 21.2" as "introduced in 21.2" and while I skimmed the earlier changelog, I missed it. My bad. As we did state the behaviour (even if only in the changelog) then my suggestion of thinking of it as a bugfix is wrong. A single release cycle of deprecation sounds like a reasonable compromise. |
c9870c5
to
f270a9d
Compare
I'm back after testing 96 combinations with pip 21.4, this PR and the build project 😓 The following table shows the combinations that behave differently between 21.2.4 and this PR, and also
[update]: here is the full table. The table shows that the cases that did succeed before and now fail are all quite exotic. Notably, The only change that could possibly be considered backward-incompatible is that So yeah this is such an exotic case that my motivation to do a deprecation cycle for that is nil. But I'm not going to block anyone else willing to do it of course. |
Also I verified that the same combinations are accepted or rejected by pip and build. |
I tentatively assigned to 21.3. Feel free to drop it if you are not comfortable with it, @pradyunsg |
What do the numbers in the table mean? |
Nothing. They are just row numbers for easier reference. |
I've kicked the can down the road for this, mostly because... I don't feel a 100% comfortable just merging this, especially just a few hours before the release! (which is... well... when I realised that, oh, there's another open PR in the milestone 😅) |
Hm, while investigating a fix for #10573 I noticed that while implementing PEP 660 I accidentally allowed The good news is this PR fixes that. |
Before it sometimes errored out.
214f649
to
1f595b8
Compare
I'm merging this into #10577 |
Fixes #10531
TODO