commit: aff1a7696b6fe7b83374ea20c2e08772b7186cc2
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Tue May 6 09:18:06 2025 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu May 8 12:32:48 2025 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=aff1a769
python-utils-r1.eclass: Switch python_optimize to use -s
Switch `python_optimize()` to use a combination of `-s` and `-p` options
instead of `-d`, since the latter does not seem to work correctly
in some cases, e.g. with `www-servers/uwsgi`:
```
The stripdir path
'/tmp/portage/www-servers/uwsgi-2.0.27/image/usr/lib/python3.13/site-packages/'
is not a valid prefix for source path
'/tmp/portage/www-servers/uwsgi-2.0.27/image/usr/lib/python3.13/site-packages/uwsgidecorators.py';
ignoring
```
These options are supported in all Python versions the eclasses
currently do support.
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
eclass/python-utils-r1.eclass | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index b61bf730b8c4..4fedd2b8a790 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -624,13 +624,11 @@ python_optimize() {
local jobs=$(makeopts_jobs)
local d
for d; do
- # make sure to get a nice path without //
- local instpath=${d#${D}}
- instpath=/${instpath##/}
-
einfo "Optimize Python modules for ${instpath}"
+ # NB: '-s' makes the path relative, so we need '-p /' to make it
+ # absolute again;
https://github.com/python/cpython/issues/133503
"${PYTHON}" -m compileall -j "${jobs}" -o 0 -o 1 -o 2 \
- --hardlink-dupes -q -f -d "${instpath}" "${d}"
+ --hardlink-dupes -q -f -s "${D}" -p / "${d}"
done
}