diff mbox series

[blacksail,59/60] python3targetconfig: Do not add the current directory to PYTHONPATH

Message ID ebd8ff92916699a09b933eb26dab7a5ffcbf25b8.1793867929.git.yoann.congal@smile.fr
State RFC, archived
Delegated to: Yoann Congal
Headers show
Series [blacksail,01/60] gstreamer1.0-plugins-bad: use gtk+3 dependency name | expand

Commit Message

Yoann Congal Nov. 5, 2026, 8:43 a.m. UTC
From: Khem Raj <raj.khem@gmail.com>

setup_target_config prepends the sysconfigdata directory as

  export PYTHONPATH=${STAGING_LIBDIR}/python-sysconfigdata:$PYTHONPATH

PYTHONPATH is normally unset in tasks, so this leaves a trailing empty
entry, which python treats as the current directory. The tasks run in
${S}, so any top level module in the source tree shadows the modules the
build tools import. wxPython ships a build.py there, and pyproject-build
then fails before it starts:

  File ".../recipe-sysroot-native/usr/bin/pyproject-build", line 5, in <module>
    from build.__main__ import entrypoint
  ModuleNotFoundError: No module named 'build.__main__'; 'build' is not a package

Currently, the wxPython recipe is unable to use
python_setuptools_build_meta class even though it should
It keeps using setuptools3 bbclass and disables QA warnings for
pep517-backend

Fix it by only adding the separator when PYTHONPATH already has a value.

Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit 18712106f7506544ee361b5634b76abed2845403)
Signed-off-by: Yoann Congal <yoann.congal@smile.fr>
---
 meta/classes-recipe/python3targetconfig.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/meta/classes-recipe/python3targetconfig.bbclass b/meta/classes-recipe/python3targetconfig.bbclass
index 3b9333a4be2..08be22ae654 100644
--- a/meta/classes-recipe/python3targetconfig.bbclass
+++ b/meta/classes-recipe/python3targetconfig.bbclass
@@ -14,7 +14,7 @@  DEPENDS:append = " ${EXTRA_PYTHON_DEPENDS}"
 setup_target_config() {
         export _PYTHON_SYSCONFIGDATA_NAME="_sysconfigdata"
         export _PYTHON_PROJECT_BASE="${B}"
-        export PYTHONPATH=${STAGING_LIBDIR}/python-sysconfigdata:$PYTHONPATH
+        export PYTHONPATH=${STAGING_LIBDIR}/python-sysconfigdata${PYTHONPATH:+:$PYTHONPATH}
         export PATH=${STAGING_EXECPREFIXDIR}/python-target-config/:$PATH
 }