summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
authorPaul Barker <pbarker@konsulko.com>2020-12-16 18:16:16 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-12-20 00:03:04 +0000
commitf50b230c27077e32eeab38fde11308d90b73a664 (patch)
tree0ebf1707f5d579976c3c0c834a560e8e20b6a03c /meta/lib
parente12072c7e043a2d3e45b75cb1aaca70c49e94cb4 (diff)
downloadpoky-f50b230c27077e32eeab38fde11308d90b73a664.tar.gz
bitbake.conf: Prevent pyc file generation in pseudo context
This also effectively reverts commit b6d30c21b0: bitbake.conf: Extend PSEUDO_IGNORE_PATHS to ${COREBASE}/meta The contents of ${COREBASE}/meta were ignored as pyc files could be generated for the contents of the lib subdirectory if python modules were imported within a pseudo context. However this doesn't protect us from pyc files being generated in the lib directories for other layers. It's far better to tell python not to produce pyc files when running under pseudo (by setting the PYTHONDONTWRITEBYTECODE variable) as this will cover any location where pyc files could possibly be created. This variable is set in FAKEROOTBASEENV so that it applies to the bitbake-worker instance for fakeroot tasks, preventing pyc files from being generated for imports in python tasks themselves. Also add a test case to ensure that pyc files are not created in tasks which are executed under pseudo. (From OE-Core rev: 73d538f20743017a44cea4c20dbe09a0327cfc71) Signed-off-by: Paul Barker <pbarker@konsulko.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oeqa/selftest/cases/pseudo.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/meta/lib/oeqa/selftest/cases/pseudo.py b/meta/lib/oeqa/selftest/cases/pseudo.py
new file mode 100644
index 0000000000..33593d5ce9
--- /dev/null
+++ b/meta/lib/oeqa/selftest/cases/pseudo.py
@@ -0,0 +1,27 @@
1#
2# SPDX-License-Identifier: MIT
3#
4
5import glob
6import os
7import shutil
8from oeqa.utils.commands import bitbake, get_test_layer
9from oeqa.selftest.case import OESelftestTestCase
10
11class Pseudo(OESelftestTestCase):
12
13 def test_pseudo_pyc_creation(self):
14 self.write_config("")
15
16 metaselftestpath = get_test_layer()
17 pycache_path = os.path.join(metaselftestpath, 'lib/__pycache__')
18 if os.path.exists(pycache_path):
19 shutil.rmtree(pycache_path)
20
21 bitbake('pseudo-pyc-test -c install')
22
23 test1_pyc_present = len(glob.glob(os.path.join(pycache_path, 'pseudo_pyc_test1.*.pyc')))
24 self.assertTrue(test1_pyc_present, 'test1 pyc file missing, should be created outside of pseudo context.')
25
26 test2_pyc_present = len(glob.glob(os.path.join(pycache_path, 'pseudo_pyc_test2.*.pyc')))
27 self.assertFalse(test2_pyc_present, 'test2 pyc file present, should not be created in pseudo context.')