mirror of
git://git.yoctoproject.org/poky.git
synced 2025-07-05 05:04:44 +02:00
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>
This commit is contained in:
parent
e12072c7e0
commit
f50b230c27
1
meta-selftest/lib/pseudo_pyc_test1.py
Normal file
1
meta-selftest/lib/pseudo_pyc_test1.py
Normal file
|
@ -0,0 +1 @@
|
|||
STRING = "pseudo_pyc_test1"
|
1
meta-selftest/lib/pseudo_pyc_test2.py
Normal file
1
meta-selftest/lib/pseudo_pyc_test2.py
Normal file
|
@ -0,0 +1 @@
|
|||
STRING = "pseudo_pyc_test2"
|
|
@ -0,0 +1,15 @@
|
|||
SUMMARY = "pseudo env test"
|
||||
LICENSE = "MIT"
|
||||
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
|
||||
|
||||
INHIBIT_DEFAULT_DEPS = "1"
|
||||
|
||||
python do_compile() {
|
||||
import pseudo_pyc_test1
|
||||
print(pseudo_pyc_test1.STRING)
|
||||
}
|
||||
|
||||
python do_install() {
|
||||
import pseudo_pyc_test2
|
||||
print(pseudo_pyc_test2.STRING)
|
||||
}
|
|
@ -685,13 +685,13 @@ SRC_URI = ""
|
|||
PSEUDO_LOCALSTATEDIR ?= "${WORKDIR}/pseudo/"
|
||||
PSEUDO_PASSWD ?= "${STAGING_DIR_TARGET}:${PSEUDO_SYSROOT}"
|
||||
PSEUDO_SYSROOT = "${COMPONENTS_DIR}/${BUILD_ARCH}/pseudo-native"
|
||||
PSEUDO_IGNORE_PATHS = "/usr/,/etc/,/lib,/dev/,${T},${WORKDIR}/recipe-sysroot,${SSTATE_DIR},${STAMPS_DIR},${WORKDIR}/pkgdata-sysroot,${TMPDIR}/sstate-control,${DEPLOY_DIR},${WORKDIR}/deploy-,${TMPDIR}/buildstats,${WORKDIR}/sstate-build-package_,${WORKDIR}/sstate-install-package_,${WORKDIR}/sstate-build-image_complete,${TMPDIR}/sysroots-components,${BUILDHISTORY_DIR},${TMPDIR}/pkgdata,${TOPDIR}/cache,${COREBASE}/scripts,${COREBASE}/meta,${CCACHE_DIR}"
|
||||
PSEUDO_IGNORE_PATHS = "/usr/,/etc/,/lib,/dev/,${T},${WORKDIR}/recipe-sysroot,${SSTATE_DIR},${STAMPS_DIR},${WORKDIR}/pkgdata-sysroot,${TMPDIR}/sstate-control,${DEPLOY_DIR},${WORKDIR}/deploy-,${TMPDIR}/buildstats,${WORKDIR}/sstate-build-package_,${WORKDIR}/sstate-install-package_,${WORKDIR}/sstate-build-image_complete,${TMPDIR}/sysroots-components,${BUILDHISTORY_DIR},${TMPDIR}/pkgdata,${TOPDIR}/cache,${COREBASE}/scripts,${CCACHE_DIR}"
|
||||
|
||||
export PSEUDO_DISABLED = "1"
|
||||
#export PSEUDO_PREFIX = "${STAGING_DIR_NATIVE}${prefix_native}"
|
||||
#export PSEUDO_BINDIR = "${STAGING_DIR_NATIVE}${bindir_native}"
|
||||
#export PSEUDO_LIBDIR = "${STAGING_DIR_NATIVE}$PSEUDOBINDIR/../lib/pseudo/lib
|
||||
FAKEROOTBASEENV = "PSEUDO_BINDIR=${PSEUDO_SYSROOT}${bindir_native} PSEUDO_LIBDIR=${PSEUDO_SYSROOT}${prefix_native}/lib/pseudo/lib PSEUDO_PREFIX=${PSEUDO_SYSROOT}${prefix_native} PSEUDO_IGNORE_PATHS=${@oe.path.canonicalize(d.getVar('PSEUDO_IGNORE_PATHS'))} PSEUDO_DISABLED=1"
|
||||
FAKEROOTBASEENV = "PSEUDO_BINDIR=${PSEUDO_SYSROOT}${bindir_native} PSEUDO_LIBDIR=${PSEUDO_SYSROOT}${prefix_native}/lib/pseudo/lib PSEUDO_PREFIX=${PSEUDO_SYSROOT}${prefix_native} PSEUDO_IGNORE_PATHS=${@oe.path.canonicalize(d.getVar('PSEUDO_IGNORE_PATHS'))} PSEUDO_DISABLED=1 PYTHONDONTWRITEBYTECODE=1"
|
||||
FAKEROOTCMD = "${PSEUDO_SYSROOT}${bindir_native}/pseudo"
|
||||
FAKEROOTENV = "PSEUDO_PREFIX=${PSEUDO_SYSROOT}${prefix_native} PSEUDO_LOCALSTATEDIR=${PSEUDO_LOCALSTATEDIR} PSEUDO_PASSWD=${PSEUDO_PASSWD} PSEUDO_NOSYMLINKEXP=1 PSEUDO_IGNORE_PATHS=${@oe.path.canonicalize(d.getVar('PSEUDO_IGNORE_PATHS'))} PSEUDO_DISABLED=0"
|
||||
FAKEROOTNOENV = "PSEUDO_UNLOAD=1"
|
||||
|
|
27
meta/lib/oeqa/selftest/cases/pseudo.py
Normal file
27
meta/lib/oeqa/selftest/cases/pseudo.py
Normal file
|
@ -0,0 +1,27 @@
|
|||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
import glob
|
||||
import os
|
||||
import shutil
|
||||
from oeqa.utils.commands import bitbake, get_test_layer
|
||||
from oeqa.selftest.case import OESelftestTestCase
|
||||
|
||||
class Pseudo(OESelftestTestCase):
|
||||
|
||||
def test_pseudo_pyc_creation(self):
|
||||
self.write_config("")
|
||||
|
||||
metaselftestpath = get_test_layer()
|
||||
pycache_path = os.path.join(metaselftestpath, 'lib/__pycache__')
|
||||
if os.path.exists(pycache_path):
|
||||
shutil.rmtree(pycache_path)
|
||||
|
||||
bitbake('pseudo-pyc-test -c install')
|
||||
|
||||
test1_pyc_present = len(glob.glob(os.path.join(pycache_path, 'pseudo_pyc_test1.*.pyc')))
|
||||
self.assertTrue(test1_pyc_present, 'test1 pyc file missing, should be created outside of pseudo context.')
|
||||
|
||||
test2_pyc_present = len(glob.glob(os.path.join(pycache_path, 'pseudo_pyc_test2.*.pyc')))
|
||||
self.assertFalse(test2_pyc_present, 'test2 pyc file present, should not be created in pseudo context.')
|
Loading…
Reference in New Issue
Block a user