-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Directory with an empty pyproject.toml files is built into an sdist+wheel by setuptools 64 #3511
Comments
This is the same underlying problem as #2329, and my position is the same on this topic as #2329 (comment). |
I'll reiterate: Setuptools should not build such projects, and should error out instead in situations with no build configuration (whether there's a setup.py or not) -- requiring both a name and a version to be specified. The current behaviour is confusing, frustrating to explain to users who hit it and setuptools already breaks test configurations for projects (pip's test suite is failing, since we have a test that no setup.py + a pyproject.toml file with no build configuration should fail to build/work with editable installs). Preserving backwards compatibility of borderline non-sensical behaviour that causes user confusion, while not holding other areas of setuptools to the same level of scrutiny is a bad idea IMO. |
One temporary solution we found in the meantime was to set the setuptools version in the pyproject.toml file as 63.0.0 |
Since our last discussion, I've encountered other use-cases where it's been valuable not to have to specify a name or a version for a package. I was troubleshooting a case where I needed to replicate a user's experience with how the package metadata was generated (dist-info vs. egg-info) and I needed a minimal setuptools project against which to test. The name and version of the generated package were irrelevant to the investigation. It was nice to be able to create a package and not have to supply arbitrary and irrelevant concerns, especially when those concerns are dealt with by higher-level abstractions. Maybe you're right that Setuptools should have a "strict" mode or something similar, perhaps even enabled by default, where it doesn't supply default values. Still, like I said in #2329 (and thanks for linking that discussion), I'd like to defer this work until after the distutils merge is complete, because the factors are complicated by backward compatibility that distutils supplies. |
I'll reiterate that, while being able to omit these fields is convenient for you, a Python Packaging expert who is deeply familiar with setuptools and its failure modes, it's absolutely not clear to anyone who is not deeply familiar with setuptools and a clear error message would be vastly more obvious and is a matter of two lines of text.
They aren't, and I want to push back against this rationale, which you also used in the previous issue. You need to either have a setup.py file or a pyproject.toml file. If either exists (or doesn't exist), pip will delegate to setuptools will happily build the project. Heck, if you don't have setuptools installed in an environment which has pip installed, it will delegate to setuptools which will build an empty directory. To that end, setuptools will package up any directory. That's... bad, and not worth the convinience of allowing experts to omit two lines while writing quick-and-dirty tests. |
Is there any chance that setuptools agrees to change this behaviour? I would appreciate if I could get a clear answer to the above. It'll help me decide whether or not it's worth my time to spend energy on this papercut in Python. |
Bumping this again -- is there any chance that setuptools would change this behaviour or is @jaraco's rationale 1 something that all setuptools maintainers agree with? Footnotes
|
Hi @pradyunsg could you please expand a little bit more which kind of user confusion this behaviour is causing? There used to be a big source of confusion when older versions of setuptools (with no support for either My understanding is that the behaviour reported here is only triggered when an user or tool is explicitly trying to install/build an arbitrary directory. (I might be wrong here, and it would be nice to know if there are other situations). With that in mind, my view is that if the user or tool is actively trying to install/build a given path, it is fair to assume the process is intended. Moreover, having an empty When combined with Setuptools' name autodetection feature, this behaviour is quite handy for incrementally adding packaging and tests to pre-existing code (which is a nice flow to teach). |
pypa/pip#12333 is another example of how the failure modes when not doing this look like to users. |
Hi @pradyunsg again this looks like an XY problem to me... It would seem that the build environment in pypa/pip#12333 is missing |
It's the same failure mode -- setuptools is proceeding without configuration for what the version should be. If it had a clean error about a missing version, it would've prompted the user to look into where the version comes from rather than show up on the pip issue tracker confused about why there's a version mismatch. The version mismatch exists because setuptools places an implicit 0.0.0 value into the built package. |
To be honest with you, all the problems reported in #3765 (comment) an in pypa/pip#12333 seem to be primarily related to the fact that the build environment is not set up correctly (or contain leaks). That is why my view is that this discussion has been a XY problem for a while. We can debate that if setuptools had raised an error for the last example it would be easier for users to identify what is the problem1, but it is also equally true that the same effect would be achieved if the frontend had identified that the build environment does not contain the correct build dependencies... Most of the time the users do provide the correct configuration (in pypa/pip#12333, the configuration files are impeccable), the problem is that the build environment does not contain the correct dependencies (or the correct versions of the dependencies) to process it2. Footnotes
|
Yes precisely. That would be a good error message to push the user in the direction of asking why setuptools-scm is not doing its job. Much better than silent apparent success that’s actually a failure. |
Sorry @merwok, my comment was actually in the opposite direction. I disagree that this would be a good error message. I think it is not a practical approach for setuptools to go out of its way implementing defensive programming against improperly configured build environments. I also don't like to blame it on empty Maybe in the future we can implement a different way of using plugins, other than entry-points. That would be more explicit and facilitate raising errors without much need of defensive programming. |
(I did understand, my comment was going in the opposite direction to your conclusion!) |
Urged by pradyunsg at PyCon sprints, I'm revisiting this issue. I've gone back and re-read #2329 and re-reviewed #2817 (which originally implemented stricter validation but which I disabled). I'm tempted to just reverse my prior decision and accept whatever change was proposed. I believe reverting 650ff7f would restore pganssle's original design (except that 18 tests fail due to the name being missing). Incidentally, just before looking at this issue, I was taking another look at another issue and in that issue, I was relying on the default name/version to build a minimal package, where name and version were irrelevant to the concern at hand and a failure would only have distracted from the investigation. After reverting 650ff7f, I tried building a project that relies on auto-discovery and resolves the package name from the Python package name, but it fails the validation:
That means the hook for validation is firing too early (before the name can be inferred from the sources), justifying concerns about the placement of the hook point. Moreover, even if we were able to apply this change in some form, it wouldn't address the failure mode reported in #3511 (comment), because that one was about an unspecified version, which I feel even more strongly 0 is a reasonable degenerate value. I'm once again feeling reluctant to special-case
Going back to #3511 (comment), I don't think it's the same failure mode as originally reported. This bug is about a "directory with an empty pyproject.toml". If we think narrowly about just that case, I think we agreed that installers should reject that case (they should limit fall back to the legacy backend for legacy cases, i.e. when only a I think I'd like to focus our efforts first on limiting where setuptools is inferred as the default backend. If we could remove support for setuptools as a default backend, that would fix the problem of an empty pyproject.toml (or one with no backend declared). That still wouldn't address the broader issue of inferring a broken build based on config values. I have some ideas about how we might make it easier to deprecate the default backend that I'll bring up in a separate discussion (aside: does Here's what I propose (plan):
@pradyunsg What do you think of the plan? |
@jaraco I am not so sure about this proposal... What I would like to understand better before we proceed is: what are the real issues with the approach that setuptools currently implements and how specifically are they problematic? As far as I understand, some problems that have been attributed to the current behaviour are typically unrelated and caused by other reasons. Often the real issue is that an old version of setuptools or other build dependency is being used (either because it is what is currently installed in the environment, or because there are some My thoughts are the following:
It seems to me that together these 2 factors (existence of Can we have some other reproducers? I don't think that simply creating a new folder with an empty In which circumstances that would not be true? Footnotes
|
I also believe that once the following 2 improvements are widely adopted in the ecosystem we are going to start seeing less and less of failures in the style of the ones listed in #3765 (comment):
Footnotes
|
My main concern is that I always considered the use of Do we really want
The reproduces Pradyun mentioned were situations where a user had a pyproject.toml for some other purpose (linter config, etc), then were surprised when it built a distribution. I don't recall the specifics. I agree, it does seem like a pretty unlikely scenario. What I'm aiming to do is narrow the scope of the problem to a single cause (setuptools asked to build something the user didn't intend) versus relying on a proxy within the setuptools build of insufficient specificity of certain config fields. I think I agree that the scope of this issue is still ambiguous. The title describes "empty pyproject.toml", but other complaints include "improperly configured environment". Pradyun has grouped these concerns as he feels strongly that a project should fail to build if it can't resolve a name and version from somewhere. I do think it would be preferable for setuptools to fail if the user has declared that "version comes from VCS" or "manifest comes from VCS" but setuptools_scm (or an equivalent) isn't available. Unfortunately, the plugin model and setuptools_scm's configuration model don't make that easy. Now that I think about it, maybe the issue with the VCS version inference should have been caught by pip (or pyproject-hooks) - if the user is using It sounds like your proposal is to continue to refine some of the rough edges around interactions between tools and see if that largely mitigates the concerns. I'm open to that, and I agree we want to address the problems at the right scope. |
…heel by setuptools 64 Fixes pypa#3511
…heel by setuptools 64 Fixes pypa#3511
…heel by setuptools 64 Fixes pypa#3511
…heel by setuptools 64 Fixes pypa#3511
…heel by setuptools 64 Fixes pypa#3511
setuptools version
setuptools==64.0.1
Python version
3.10.6
OS
RHEL 7
Additional environment information
No response
Description
A directory with an empty pyproject.toml files is built into an sdist+wheel by setuptools 64
Expected behavior
Setuptools should refuse to build a project that does not have a name and version.
How to Reproduce
Output
The text was updated successfully, but these errors were encountered: