package/{pkg-generic, python, python3}: add mechanism to exclude .py files from removal
authorThomas Petazzoni <thomas.petazzoni@bootlin.com>
Fri, 29 Nov 2019 19:07:05 +0000 (20:07 +0100)
committerPeter Korsgaard <peter@korsgaard.com>
Sat, 30 Nov 2019 08:46:27 +0000 (09:46 +0100)
commit56f3ed3fc1e1bee560e06b57237bd3d4af0def22
tree7ec8b9d1fb38d38e7b41edfb75b622ea05751663
parentb20487151af79563da763d0f053deb78ff63172a
package/{pkg-generic, python, python3}: add mechanism to exclude .py files from removal

When BR2_PACKAGE_PYTHON{,3}_PYC_ONLY=y, we force remove all .py files
from the system, as they have all been byte-compiled into their .pyc
variants.

However, it turns out that some packages (e.g: OpenCV) do some funky
things with a few .py files: they pass them through Python's
execfile() facility, which only works with .py files and not .pyc
files. It is used by OpenCV for example to read two small
configuration files.

In order to support such use cases, this commit introduces a very
simple mechanism by which packages can exclude some path patterns from
the .py removal: a per-package <pkg>_KEEP_PY_FILES variable that is
collected into a global PYTHON_KEEP_PY_FILES variable, then used by
the python/python3 target-finalize hooks.

This variable is intentionally not documented, this is really a hack
that we ideally would like to see go away, and we'd rather not see its
usage spread too much.

This is necessary to be able to fix bug #12171.

[Peter: check if PYTHON_KEEP_PY_FILES contains non-white space]
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
package/pkg-generic.mk
package/python/python.mk
package/python3/python3.mk