kumquat-buildroot/package/python3
Yann E. MORIN 5894ab0107 package/python3: ensure pyc embed rooted paths
To report usable tracebacks, pyc files embed the path of the original py
files, so that users can more easily try and debug the reported issue.

We generate the pyc files by calling the python3-supplied compileall
script, to scan the directory where python modules are installed. Since
this is done on the build machine, we tell compileall.py to strip away
the TARGET_DIR prefix, as that has no meaning at runtime.

However, compileall.py forgets [0] to keep a leading / in the front of
the paths, thus generating non-rooted paths., e.g.:
     /path/buildroot.ouput/targt/usr/lib/python3.10/argparse.py
gets embedded as:
     usr/lib/python3.10/argparse.py

This is a bit confusing but, as far as we could see, should be mostly be
used for display purposes in tracebacks, and does not seem to impact
actual functionality.

We fix that by instructing compileall.py that the embedded paths should
be rooted to / which generates proper paths in tracebacks.

And alternate solution would be to swith gears, and tell compileall.py
exactly the resulting runtime "base" directory, which replaces the
stripping and prefixing; i.e. it's either:
    -s $(TARGET_DIR) -p /
or
    -d /usr/lib/python$(PYTHON3_MAJOR_VERSION)

We choose to keep the first solution, because that is semantically what
we really want to do: to strip the leading build-time path, rather than
to force anything.

Note: the python test-suite was executed with both solutions (in a
pyc-only setup), and the results were exactly the same; so in practice,
-d or -s+-p yield the same results.

Many thanks go to Vincent for reporting the issue and suggesting the
solutions.

[0] Not sure whether this is a bug or a feature...

Reported-by: Vincent Fazio <vfazio@xes-inc.com>
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2022-08-29 21:14:45 +02:00
..
0001-Make-the-build-of-pyc-files-conditional.patch
0002-Disable-buggy_getaddrinfo-configure-test-when-cross-.patch
0003-Add-infrastructure-to-disable-the-build-of-certain-e.patch
0004-Adjust-library-header-paths-for-cross-compilation.patch
0005-Don-t-look-in-usr-lib-termcap-for-libraries.patch
0006-Don-t-add-multiarch-paths.patch
0007-Abort-on-failed-module-build.patch
0008-Serial-ioctl-workaround.patch
0009-Do-not-adjust-the-shebang-of-Python-scripts-for-cros.patch
0010-Misc-python-config.sh.in-ensure-sed-invocations-only.patch
0011-Add-an-option-to-disable-pydoc.patch
0012-Add-an-option-to-disable-lib2to3.patch
0013-Add-option-to-disable-the-sqlite3-module.patch
0014-Add-an-option-to-disable-the-tk-module.patch
0015-Add-an-option-to-disable-the-curses-module.patch
0016-Add-an-option-to-disable-expat.patch
0017-Add-an-option-to-disable-CJK-codecs.patch
0018-Add-an-option-to-disable-NIS.patch
0019-Add-an-option-to-disable-unicodedata.patch
0020-Add-an-option-to-disable-IDLE.patch
0021-Add-an-option-to-disable-decimal.patch
0022-Add-an-option-to-disable-the-ossaudiodev-module.patch
0023-Add-an-option-to-disable-openssl-support.patch
0024-Add-an-option-to-disable-the-readline-module.patch
0025-Add-options-to-disable-zlib-bzip2-and-xz-modules.patch
0026-python-config.sh-don-t-reassign-prefix.patch
0027-Fix-cross-compiling-the-uuid-module.patch
0028-Add-an-option-to-disable-uuid-module.patch
0029-fix-building-on-older-distributions.patch
0030-configure.ac-fixup-CC-print-multiarch-output-for-mus.patch
0031-Add-an-option-to-disable-the-berkeleydb-module.patch
0032-lib-crypt-uClibc-ng-doesn-t-set-errno-when-encryptio.patch
Config.in
Config.in.host
python3.hash
python3.mk