pyproject-hooks
pyproject-hooks copied to clipboard
pep517: in_process: try _in_process.pyc file if _in_process.py doesn't exist
This change came about to exist after this bug report: https://github.com/openwrt/packages/issues/11912
The general context is that OpenWrt does not ship Python source-code by default. Instead, the build byte-compiles all .py files into .pyc files and removes the .py files. There's a wide reasoning for this, from performance to reducing the size of these packages.
This change is kept in the Python3 build as this patch: https://github.com/openwrt/packages/blob/master/lang/python/python3/patches-pip/001-pep517-pyc-fix.patch
This is an attempt to start a discussion, to see whether it makes sense to remove it from the OpenWrt packages feed, and live in the pip source-base.
The original author of this patch is Jeffery To. I am the submitter to this repo. We're both co-maintainers of the Python3 package in the OpenWrt realm.
Signed-off-by: Jeffery To [email protected] Signed-off-by: Alexandru Ardelean [email protected]
ping on this;
not saying this is the best solution, but i would like an idea on how to handle this better;
i'm fine to implement it
ping on this :)
Assuming the .pyc
is in the same location as the .py
is wrong. You should probably use importlib.util.cache_from_source
, but even with that, there could be problems - for example running pip from a metapath hook that references a sourceless pip[^1] - which should be tested.
[^1]: This would happen in real life when setting up an isolated build environment from a sourceless pip, for example.
Assuming the
.pyc
is in the same location as the.py
is wrong. You should probably useimportlib.util.cache_from_source
, but even with that, there could be problems - for example running pip from a metapath hook that references a sourceless pip1 - which should be tested.Footnotes
1. This would happen in real life when setting up an isolated build environment from a sourceless pip, for example. [leftwards_arrow_with_hook](#user-content-fnref-1-de8c8293481778e25b7a0f5852353604)
phew, it's been a while since i opened this PR;
anyway the use-case for OpenWrt is a bit specific (with regards to .pyc files); we store them along-side with .py
usually;
i'll re-review this and comeback;
Closing this out since its not been updated in a while and there's some significant changes needed for this to even be considered.
Let's keep the discussion in #148 before we get back to this.