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
Add CLI command to py-compile wheels #3253
Conversation
I failed too :<
Maybe we should open a discussion in discuss.python.org. There might be people who already have been thinking about this before. |
Agreed. |
As mentioned on pyodide/micropip#24, it may be worth further exploring some packages that could be trivially For example, simply importing |
Yeah, certainly worth exploring but maybe in a separate issue. Also worth keeping in mind that while it has the potential to make computing faster, it means more WASM binary code to compile by the browser which can make loading slower (or at least more CPU intensive). Anyway for now, I have to fix tests a couple of tests that started to fail for unknown reasons, and syntactically invalid files apparently distributed in one of the wheels. |
Opened a discussion: https://discuss.python.org/t/proper-file-paths-to-show-in-exception-for-py-compiled-files/21108. I would appreciate if you can add some extra information if I missed something. |
This should be ready for review. I reverted all patches that affected the build, so now this only adds the |
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 @rth!
url: https://files.pythonhosted.org/packages/df/9e/d1a7217f69310c1db8fdf8ab396229f55a699ce34a203691794c5d1cad0c/packaging-21.3.tar.gz | ||
|
||
patches: | ||
- patches/allow-cpp310-none-any-tag.patch |
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.
Packaging 0.22.0 is released now, so probably we can go ahead and update.
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.
For now, we are still blocked by pypa/packaging#638 due to pyodide/micropip#36 so we would need to wait for 0.22.1.
I'll update the comment in the patch.
[skip ci] Co-authored-by: Gyeongjae Choi <def6488@gmail.com>
Together with #3166 this would address #3050 by py-compiling .py files inside wheels into .pyc
There are two ways to use this feature,
Currently, the logic is the input is a wheel (i.e. a zip files) we py-compile individual files, and create the output wheel. Although this means we do wheel repacking twice, the advantage is that it's easier to debug, since in the build/ folder we would have the original wheel in the dist/ we would get this py-compiled wheel. If we do everything in the same extracted folder, it means we have to remove original .py files and if anything goes wrong we no longer have them.
Similarly I haven't managed to use compileall as it puts
.pyc
files in the__pycache__
folder instead of alongside the.py
files that we want. Instead I'm using a lower level py_compile module.This is an initial implementation, but it still needs
adding tests
fixing existing tests
making sure for input tag
py3-none-any
in the wheel filename, the output iscp310-none-any
and that it's compatible according topackaging.compatible_tags
(currently it's not the case): cp310-none-any not in compatible tags pypa/packaging#615Decide how we want to disable/enable this feature (e.g. via some flag inMakefile.env
)fixing the file path in exceptions. Currently similarly to Vendor standard libraries in a zip file #3166 cc @ryanking13 it shows the path in the folder where it was py-compiled. This is fixable, but it also means you have to set this path at compilation time rather than at run time which can be rather confusing if the wheel is later installed under a different folder. Maybe for now the easiest would be to display the relative path, then see if there is a way to improve this in the exception handling code.
Benchmarks for some packages with Firefox 106 and Chrome 106 (both with console open, which can impact performance),
So overall pretty good. It would make sense to include this in the same release as #3166