pyproject-hooks icon indicating copy to clipboard operation
pyproject-hooks copied to clipboard

pep517: in_process: try _in_process.pyc file if _in_process.py doesn't exist

Open commodo opened this issue 3 years ago • 4 comments

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]

commodo avatar Sep 06 '21 09:09 commodo

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

commodo avatar Oct 27 '21 09:10 commodo

ping on this :)

commodo avatar Mar 16 '22 07:03 commodo

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.

pfmoore avatar Aug 26 '22 12:08 pfmoore

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 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;

commodo avatar Aug 29 '22 05:08 commodo

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.

pradyunsg avatar Nov 24 '22 19:11 pradyunsg