-
-
Notifications
You must be signed in to change notification settings - Fork 22
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
Improve alternative index handling. #124
base: main
Are you sure you want to change the base?
Conversation
This improve the handling of indexes and error messages. Before this PR all errors reaching an index would be ValueError, thus not finding a wheel was the same as the index page having a non-handled content type, or even failing to parse the html because of a typo. This made it hard to debug, or even realize that an index url was wrong, or that the pages served by the index were incorrect. I thus introduce 3 New Errors that do not inherit from `ValueError`: - IndexMetadataFetchError - UnsupportedParserContentTypeError - WheelNotFoundError The first two of which trigger real error, as they likely suggest a problem with the index or the user config, and should not be ignored. In addition the `verbose=` option was unconditionally setting the log level. I think this is improper as if the logging level is set somewhere else (to DEBUG, or something else), then it is overwritten. - This then adds the option to pass `verbose=None`, (and make it the default), in which case it will not change the default. python -m http.server will serve ContentType with `; charset=utf-8`, which is not recognized. - This now handle the case where the index ContentType header contains parameters for example `; charset=utf-8`, by discarding everything after the semicolon `;`; this is not proper parsing, but should be sufficient here. - I found that more debug logging would be useful and added a number of debug logs calls With this I appear to get proper error message and debug statements when trying to work on the Cors proxy. Should close pyodide#123, and pyodide#121, and help with pyodide/pyodide#4898
There are still a few case that needs handling, in particular when fetching for a given wheel and the page does not exists, is it a problem with the index, or does the package really not exists. I think I might have to tweak the behavior a bit more. |
Ok, one of the issues is that in particular PYPI does not set CORS on 404, therefore we get an OS error when trying to fetch a non-existing page. I'm wondering if this is a bug upstream |
Thanks @Carreau.
This does seem to be a warehouse bug. |
Yep and it's known pypi/warehouse#14229 |
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. Looks good to me overall. Could you update the changelog and fix the failing tests? I think you need to update the Error type here
Co-authored-by: Gyeongjae Choi <def6488@gmail.com>
Yeah, I'm looking at understanding the failing tests. I'd like to figure out how to both get proper error messages if the index is invalid, and just keep going on 404, but because of PyPI not setting CORS on 404 I don't know if it's currently possible. So I'm wondering if i I should bake a an boolean for indexes (I also have limited time, so might not touch this that much by next week). |
We should look into fixing the warehouse bug. I tried a little bit but I didn't get the warehouse test suite running. |
Yep, +1 for fixing the warehouse bug. Let me see if I can understand and modify the warehouse codebase. |
Also pyodide/pyodide#4974 will be relevant for later refactor. |
crosslinking pypi/warehouse#16339 as well. |
So should I assume that we'll always get micropip on the latest pyodide, or can we have conditional that depends on versions ? |
If there are some changes in Pyodide and if you want to use those features in the micropip, you are welcome to do so. We try to keep the compatibility of micropip and Pyodide versions if possible, but it is not mandatory. |
This improve the handling of indexes and error messages.
Before this PR all errors reaching an index would be ValueError, thus not finding a wheel was the same as the index page having a non-handled content type, or even failing to parse the html because of a typo.
This made it hard to debug, or even realize that an index url was wrong, or that the pages served by the index were incorrect.
I thus introduce 3 New Errors that do not inherit from
ValueError
:The first two of which trigger real error, as they likely suggest a problem with the index or the user config, and should not be ignored.
In addition the
verbose=
option was unconditionally setting the log level. I think this is improper as if the logging level is set somewhere else (to DEBUG, or something else), then it is overwritten.verbose=None
, (and make it the default), in which case it will not change the default.python -m http.server will serve ContentType with
; charset=utf-8
, which is not recognized.This now handle the case where the index ContentType header contains parameters for example
; charset=utf-8
, by discarding everything after the semicolon;
; this is not proper parsing, but should be sufficient here.I found that more debug logging would be useful and added a number of debug logs calls
With this I appear to get proper error message and debug statements when trying to work on the Cors proxy.
Should close #123, and #121, and help with pyodide/pyodide#4898