-
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 diagnose when setup.py/cfg cannot be found #9945
Better diagnose when setup.py/cfg cannot be found #9945
Conversation
This adds a check before invoking 'egg_info' to make sure either setup.py or setup.cfg actually exists, and emit a clearer error message when neither can be found and the egg_info command can never succeed.
5b14f05
to
1983ef0
Compare
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.
Thanks @uranusjr
Interestingly, while testing this I noticed that, assuming
The "fix" for that would be easy (in |
I grep-ed the code base, |
@uranusjr pre-commit is complaining. |
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.
@uranusjr I think it can help. It sounds fine. Thanks.
9f28003
to
1904e4d
Compare
Please consider changing this check to only |
Allowing a setup.cfg without a pyproject.toml does seem like a step backward. For ease of reference: $ pip wheel .
ERROR: Directory '.' is not installable. Neither 'setup.py' nor 'pyproject.toml' found.
WARNING: You are using pip version 21.1.1; however, version 21.1.2 is available.
You should consider upgrading via the '/Users/henryschreiner/tmp/quickcheck/venv/bin/python3.9 -m pip install --upgrade pip' command.
$ pip install --upgrade pip
$ pip wheel .
Processing /Users/henryschreiner/tmp/quickcheck
DEPRECATION: A future pip version will change local packages to be built in-place without first copying to a temporary directory. We recommend you use --use-feature=in-tree-build to test your packages with this new behavior before it becomes the default.
pip 21.3 will remove support for this functionality. You can find discussion regarding this at https://github.com/pypa/pip/issues/7555.
Collecting numpy>=1.13.3
File was already downloaded /Users/henryschreiner/tmp/quickcheck/numpy-1.20.3-cp39-cp39-macosx_10_9_x86_64.whl
Building wheels for collected packages: quickcheck
Building wheel for quickcheck (setup.py) ... done
Created wheel for quickcheck: filename=quickcheck-0.0.0-py3-none-any.whl size=3372 sha256=57acfb84109eedde21404ffdea6ef0e87d6ef7663498e3220bb0c4a72b066d35
Stored in directory: /private/var/folders/_8/xtbws09n017fbzdx9dmgnyyr0000gn/T/pip-ephem-wheel-cache-62ksr1uu/wheels/9a/34/3d/e8d9298f424ae357bac078a56990fce39937c7ed9018594f47
Successfully built quickcheck |
I don’t understand. This is about legacy setuptools projects and not related to PEP 517 in any way. A PEP 517 project should not go through any of the changed code paths with or without this change (and if they do, their behavioural changes should be considered a bug).
I don’t understand this either. What is in directory It seems like there is a big missing link between this PR and things you are complaining about. |
If you create a project with just a @pfmoore added a static check to $ tree
.
├── LICENSE
├── README.md
├── setup.cfg
└── src
└── quickcheck
└── __init__.py |
@@ -269,18 +269,14 @@ def tabulate(rows): | |||
return table, sizes | |||
|
|||
|
|||
def is_installable_dir(path): | |||
# type: (str) -> bool | |||
"""Is path is a directory containing setup.py or 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.
This didn't allow setup.cfg only before.
return False | ||
return any( | ||
os.path.isfile(os.path.join(path, signifier)) | ||
for signifier in ("pyproject.toml", "setup.cfg", "setup.py") |
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.
This is a logic change! before setup.cfg
only didn't pass this check, now it does.
And, relevant messages from the build discussion, where @pfmoore argued we could not add
I was arguing that setup.cfg-only was valid, but pip didn't support it, so I conceded it was okay for This is, in both tools, just a check to provide an error message; both tools actually do support setup.cfg only packages if you let them pass this check. |
To clarify the position, PEP 517 explicitly requires
However, on re-reading PEP 517, the following paragraph
can be interpreted (if we ignore the implication that tools must be able to run So technically, I stand by the principle that if you only support PEP 517 source trees need However, I will also point out that the cases for This is of course all rules-lawyering. And I don't really have much interest in arguing fine points like this. In reality my view is that all new projects should be using PEP 517, with a |
I've responded in the build issue (pypa/build#302), but in short, the paragraph mentioned above (which is listed in the "changes since acceptance section", so it is "new"ish) clearly means that anything This is just for a check to see if the source tree is valid - a setup.cfg-only project is otherwise completely supported by both pip (>=21.1.1) and build (<0.4.0) since |
AFAIK, Furthermore, I haven't seen anyone asking for pip to support this use-case. The issue this is supposed to fix is related to nothing of the sort.
is the news entry, it does not mention anything about the behavior change. PEP 517 is designed to be backwards compatible, PEP 517 builders should be able to build all Python projects. Making pip work with If you don't want to discuss this, then please defer this discussion until someone actually asks for this use-case. |
Just to clarify here:
I think this is technically valid, but with a strong caveat. This is what PEP 517 says (this is in the modifications since release):
Due to the "acceptable alternative", that also indicates a perfectly valid PEP 517 builder could manually execute setup.py, and not call This static check was not put in place to limit packages to PEP 517 compliance, but instead to give nice error messages (in build, pip, and cibuildwheel, all have simliar checks). My preference would be to restore the check here, then maybe discuss adding mention of setup.cfg being valid to PEP 517 if @pypa/setuptools-developers want setup.cfg-only packages to be valid - that would require requiring |
I don't think that anyone anticipated that Personally, I view |
I disagree. The PEP says
which is very clear about running
PEP 517 specifies a new standard for interchangeable build backends, and also specifies how to that interacts with legacy projects and how frontends should behave. pip is deliberately adopting only part of the PEP and saying 'well, I think I know better than the PEP so I am gonna choose how to handle this "legacy" case'. Please don't do this, either implement things how the PEP says, or raise an issue and ask for the PEP to be updated to handle this specific case the way you want. Build frontends should not be behaving in different ways, the PEP is specific how legacy cases should be handled. I don't really think I have anything else constructive to add to this discussion. I am not a pip maintainer, so this is not my decision to make, I'll leave you be now. |
As the original |
That is already possible with the mechanism introduced in PEP 517, the question here is if setuptools should have special treatment and be able to bypass the standard mechanism for specifying the backend. |
I remembered a way to more clearly show how this is wrong. If you do this, setuptools/setup.py is no longer the legacy mechanism but rather it is effectively the default packaging backend. |
From a practical standpoint, moving to setup.cfg-only being distinct from adding a pyproject.toml is nice - convincing someone to adopt one is easier if it is not dependent not the other. From a purity standpoint, PEP 517 allows a builder to either directly call Both pip and build call Personally, I don't really care that much which is decided on (purity vs. practicality), I just want consistency. I'm done now too, just will wait and see how it plays out. |
I feel at this point we’re only arguing over semantics without anything actually meaningful. What counts as “the Setuptools also explicitly refused to add any build front-end features and told people to get a proper front-end instead, which I took as a sign that front-ends should interpret what “running [1]: Quoting the PEP, There is an existing, legacy source tree format involving |
IMO (as a pip maintainer) the PEP says that we can either call I don't have much sympathy for setuptools saying it's for the front end to deal with this. If we were talking about the non-legacy backend, that would be a different matter, but the legacy backend was explicitly added (in PEP 517) to allow frontends to fall back to the old becahviour while still using a PEP 517 hook. New behaviour should happen on the non-legacy hook. Because the PR I created for build (as a fix for pypa/build#259) is being quoted as the reason for the checks there, I feel as though I'm expected to be in support of build's behaviour. But in reality I don't care that much¹, all I care about is that "obvious mistakes" are caught. And IMO, that's all that both pip and build should care about. My interest in build's behaviour here is purely as a build user, who was caught out by the lack of any validation. But I've never used a From a pip maintainer's point of view, I'd be fine with accepting a PR that flagged an error if a directory contained only ¹ Even though I don't really care if we warn, flag an error, or just let things fall through to setuptools, I do think that projects that omit |
The |
Per the discussion in pypa#9945. Signed-off-by: Filipe Laíns <[email protected]>
Per the discussion in pypa#9945. Signed-off-by: Filipe Laíns <[email protected]>
Per the discussion in pypa#9945. Signed-off-by: Filipe Laíns <[email protected]>
Per the discussion in pypa#9945. Signed-off-by: Filipe Laíns <[email protected]>
Per the discussion in pypa#9945. Signed-off-by: Filipe Laíns <[email protected]>
Per the discussion in pypa#9945. Signed-off-by: Filipe Laíns <[email protected]>
See also pypa/setuptools#2329 |
Required with newer pip versions. See pypa/pip#9945 for some related discussion.
This adds a check before invoking
egg_info
to make sure either setup.py or setup.cfg actually exists, and emit a clearer error message when neither can be found.Fix #9944.