I am able to do 'devtool modify gpgme' without any errors. In what setting does it fail for you?

The purpose of _sysconfigdata is to substitute configuration values that are specific for target python when running native python in cross builds with requests from target component build systems to supply those values. For that to work, the recipe also needs to have target python3 in its DEPENDS. It

I feel the patch is fixing the symptom rather than the issue somehow?


Alex

On Fri, 10 Jul 2020 at 21:08, Taras Kondratiuk <takondra@cisco.com> wrote:
'devtool modify' fails for packages that inherit python3native (e.g.
gpgme or systemd, via meson class):
| Exception: ModuleNotFoundError: No module named '_sysconfigdata'

After commit 02714c105426 ("python3: upgrade to 3.7.2") python3native
class exports _PYTHON_SYSCONFIGDATA_NAME = '_sysconfigdata'. I think the
expectation is that it will find
usr/lib/python-sysconfigdata/_sysconfigdata.py prepared by the same
commit. But some places seems to still use host python3 which doesn't
have _sysconfigdata.py. This leads to "No module named '_sysconfigdata'"
errors. E.g. commit 4b26eaf7152f ("prservice.py: fix do_package with
newer Python in Ubuntu 20.04") recently tried to workaround it for PR
service. And now we see similar issue in devtool. To unblock devtool
apply similar workaround here.

But looks like there is some deeper issue here. I haven't fully grasped
the purpose of _sysconfigdata.py yet. It is copied from
_sysconfigdata_m_linux_x86_64-linux-gnu.py and then some variables are
modified. But new values seems to be wrong. For example:
In _sysconfigdata_m_linux_x86_64-linux-gnu.py:
'INCLUDEPY': 'FIXMESTAGINGDIRHOST/usr/include/python3.7m',
While in _sysconfigdata.py:
'INCLUDEPY': 'FIXMESTAGINGDIRHOSTFIXMESTAGINGDIRHOST/usr/include/python3.7m',

When FIXMESTAGINGDIRHOST is replaces by staging.bbclass, the path in
_sysconfigdata.py points to nowhere while
_sysconfigdata_m_linux_x86_64-linux-gnu.py has a correct path.

Signed-off-by: Taras Kondratiuk <takondra@cisco.com>
---
 meta/classes/devtool-source.bbclass | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/meta/classes/devtool-source.bbclass b/meta/classes/devtool-source.bbclass
index 280d6009f3c2..4a469bfacad7 100644
--- a/meta/classes/devtool-source.bbclass
+++ b/meta/classes/devtool-source.bbclass
@@ -65,6 +65,11 @@ python() {


 python devtool_post_unpack() {
+    # Otherwise this fails when called from recipes which e.g. inherit
+    # python3native (which sets _PYTHON_SYSCONFIGDATA_NAME) with: No module
+    # named '_sysconfigdata'
+    if '_PYTHON_SYSCONFIGDATA_NAME' in os.environ:
+        del os.environ['_PYTHON_SYSCONFIGDATA_NAME']
     import oe.recipeutils
     import shutil
     sys.path.insert(0, os.path.join(d.getVar('COREBASE'), 'scripts', 'lib'))
--
2.25.1