diff mbox series

python3targetconfig: Do not add the current directory to PYTHONPATH

Message ID 20261027191705.1880728-1-khem.raj@oss.qualcomm.com
State Under Review
Headers show
Series python3targetconfig: Do not add the current directory to PYTHONPATH | expand

Commit Message

Khem Raj Oct. 27, 2026, 7:17 p.m. UTC
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>
---
 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 3b9333a4be..08be22ae65 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
 }