Skip to contentSkip to conversation

prserv/serv: Avoid exception with newer versions of Python

bitbake-devel Peter Kjellerstedt 2 participants 2 messages Jun 5, 2020 1 message not in the archive

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive
Quoted 27 lines

-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of Peter Kjellerstedt
Sent: den 5 juni 2020 17:49
To: [email protected]
Subject: [bitbake-devel] [master][dunfell] prserv/serv: Avoid exception with newer versions of Python

The following exception was received when doing devtool modify ...:

Exception: ModuleNotFoundError: No module named '_sysconfigdata'

This was previously partially solved in OE-Core, in commit 4b26eaf7 (prservice.py: fix do_package with newer Python in Ubuntu 20.04). However, that only solved the problem for some cases where prserv was imported. This should solve if for all of them.

---
 bitbake/lib/prserv/serv.py | 6 ++++++
 1 file changed, 6 insertions(+)
bitbake/lib/prserv/serv.py +0 -0
index 25dcf8a0ee..48f4b5b05d 100644
@@ -2,6 +2,12 @@
 # SPDX-License-Identifier: GPL-2.0-only
 #

bitbake/lib/prserv/serv.py line 13

Quoted 10 lines
bitbake/lib/prserv/serv.py +6 -0
 
+# Make sure _PYTHON_SYSCONFIGDATA_NAME is not set in the environment, which may
+# happen for recipes that, e.g., inherit python3native, which sets it. Otherwise
+# importing from xmlrpc.server fails with "No module named '_sysconfigdata'"
+if '_PYTHON_SYSCONFIGDATA_NAME' in os.environ:
+    del os.environ['_PYTHON_SYSCONFIGDATA_NAME']
+
 import os,sys,logging
 import signal, time
 from xmlrpc.server import SimpleXMLRPCServer, SimpleXMLRPCRequestHandler

Without this, I can no longer use devtool with neither master nor Dunfell.

//Peter

#2 lore raw

Strange, I was seeing this error on my system in those do_package tasks when sending that initial work around, but devtool works for me fine on the same ubuntu 20.04 system.

But if this works better for you, them I'm fine with the revert of my change.

Quoted 50 lines · Peter Kjellerstedt
Quoted 2 lines

-----Original Message-----
From: [email protected] <

[email protected]> On Behalf Of Peter Kjellerstedt

Quoted 3 lines

Sent: den 5 juni 2020 17:49
To: [email protected]
Subject: [bitbake-devel] [master][dunfell] prserv/serv: Avoid exception

with newer versions of Python

Quoted 20 lines

The following exception was received when doing devtool modify ...:

Exception: ModuleNotFoundError: No module named '_sysconfigdata'

This was previously partially solved in OE-Core, in commit 4b26eaf7 (prservice.py: fix do_package with newer Python in Ubuntu 20.04). However, that only solved the problem for some cases where prserv was imported. This should solve if for all of them.

---
 bitbake/lib/prserv/serv.py | 6 ++++++
 1 file changed, 6 insertions(+)
bitbake/lib/prserv/serv.py +0 -0
index 25dcf8a0ee..48f4b5b05d 100644

bitbake/lib/prserv/serv.py line 5

Quoted 4 lines
bitbake/lib/prserv/serv.py +1 -0
@@ -2,6 +2,12 @@
 # SPDX-License-Identifier: GPL-2.0-only
 #
 
+# Make sure _PYTHON_SYSCONFIGDATA_NAME is not set in the environment,

which may

bitbake/lib/prserv/serv.py line 6

Quoted 1 line
bitbake/lib/prserv/serv.py +1 -0
+# happen for recipes that, e.g., inherit python3native, which sets it.

Otherwise

bitbake/lib/prserv/serv.py line 7

Quoted 1 line
bitbake/lib/prserv/serv.py +1 -0
+# importing from xmlrpc.server fails with "No module named

'_sysconfigdata'"

bitbake/lib/prserv/serv.py line 13

Quoted 6 lines
bitbake/lib/prserv/serv.py +3 -0
+if '_PYTHON_SYSCONFIGDATA_NAME' in os.environ:
+    del os.environ['_PYTHON_SYSCONFIGDATA_NAME']
+
 import os,sys,logging
 import signal, time
 from xmlrpc.server import SimpleXMLRPCServer, SimpleXMLRPCRequestHandler

Without this, I can no longer use devtool with neither master nor Dunfell.

//Peter