-
-
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
editable install after pep660 breaks setup.py that relies on specific exception type to retry setup() after a build error #3572
Comments
Hi @CaselIT, thank you very much for reporting the problem. This is a tricky one! I can see a clash between setuptools and the custom setup script: both parties want to control how the exception is handled. Setuptools wants to capture unknown errors and display instructions for how the user can workaround the situation and report the problem (this is specially important since PEP 660 changes the ways things used to work); the custom setup script wants to use exceptions in some sort of control flow. I believe setuptools should not stop showing that error message to user, at least not at this point in time. It is very important in other situations (e.g. plugins or local customisations that are not prepared to handle PEP 660). I can see that you guys already take into account the possibility that some command objects do not raise an exact exception class. I can also think about other ways of doing it:
|
I would say that editable mode now works more closely to non-editable installs than before (it will never be 1:1)... But that is very subjective. Is there any specific aspect that you are looking for? Based on the linked I am more than happy to discuss a different mechanism as long as we preserve he overall functionality (i.e. showing instructions/workarounds that users can do in the case of "mysterious errors" probably associated with plugins/customisations that are not PEP 660-ready). I welcome any PRs that would like to explore that direction.
I think the closest thing setuptools has is the
I don't think this is the case for a custom backend. So far the primary use-case I found for a custom backend is to dynamically decide about build dependencies. Another use case would be modifying the
Currently there are some ongoing discussions on that regard. I am afraid there is nothing "final" yet, but you might want to have a look on #2806 (specially the insights from Jason). |
Hi @abravalheri Thanks for the detailed answer! I'll look into the things you suggested.
My question was motivated by the fact that a normal install is still bubbling up the errors, while the editable mode was not, I wanted to know if the idea was to modify the normal install mode to be like the editable one regarding bubbling modes
Not necessarily, I mean the current setup.py is like it is because exception were bubbled up. The objective of the issue is to find a working solution, if any, with the new system, not to make thing work like before since this is probably a really niche use case, and it's most likely not worth changing the implementation to accommodate for it.
Ok thanks! |
The suggestion using Do you need to restart the build and try again? If that is the case, then the suggestion about using a wrapper for the
So far, the need for that hasn't presented itself. I don't know to which extent we can classify exception handling as part of the explicit API or simply Hyrum's Law in action. |
I just want to note that on our end (SQLAlchemy), the "retry" thing IMO is not the most important thing. If we could instead have a way to make a very good estimation that compiler tools are not expected to be present, or that they are, we could just choose one build or another. Another way I can see us going is that we go to an entirely non-intelligent system, but when a build fails, we can at least give our own error message that will say "Please use DISABLE_SQLALCHEMY_CEXT if build tools aren't installed". |
For that maybe the best is to engage in issue #2806. I believe that currently there is no API to check if the compiler is present (but I might be wrong). |
if Maybe the only thing we want to keep is a detection of errors to print a log to users regarding installing in pure python mode. I'll try playing with it and report back! |
@CaselIT please note that pip will by default hide anything from stdout. Users need to use |
@abravalheri thanks a lot for the support!
this is working perfectly. We were not aware of that keyword! It's great that's supported by setuptools without any strange shenanigan in the setup file. The final Thanks again! |
Thanks for shedding light on this @abravalheri! |
setuptools version
65.3, any after 64
Python version
3.7+
OS
any without compilers installed
Additional environment information
No response
Description
Not sure if this more of a bug or more of a discussion, feel free to move
I maintain two libraries, falcon and sqlalchemy, that have a similar install setup, namely they provide some optional extension modules that enable some speed up if compiled, but they have a pure python fallback in case compilation is not possible.
The setup.py take advantage of this and basically tries to compile the extension modules, then in case of a build error retries the
setup()
call without the extension modules, running a pure python install.The setup.py files are these
Since version setuptools version 64 that enabled pep660 for editable builds this workflow no longer works, since among other things the exception raised by
setup()
is aSystemExit
one.Normal, non editable installs (
pip install .
) continues to work correctly.I've tried to debug this and found a workaround, but it definitely seems like retrying the
setup()
call based on some condition is not something that should be done, at least in editable mode.Will normal installs (
pip install .
) behave similarly to editable mode when installing from source?Is there a better way of doing something similar in a supported or at least more robust way?
Should a custom backend be used, similar to what the documentation talks about here?
If that's the case, what's the best way for the backend to check if a compiler is available?
cc @zzzeek @vytas7
Expected behavior
Editable build installs in compiled or pure python version depending on the install machine
How to Reproduce
run in
docker run -ti --rm --name py python:3.10-slim bash
Output
The text was updated successfully, but these errors were encountered: