Put files from installed tests into a separate package to avoid having
them in an image unwanted and to avoid having more runtime
dependencies than necessary.

Background:
As setuptools is pretty much unregulated in terms what is installed
by some module, even tests are installed into base package, which then
go right into production, although completely unnecessary.
When now trying to determine the needed runtime dependencies, more
than actually needed will slip into the image.
To give a really bad example GitPython ships its tests into production
leading to the effect that theoretically besides the known RDEPENDS
python3-asyncio, python3-distutils, python3-idle, python3-misc,
python3-pickle, python3-shell, python3-ddt and python3-nose would be
required.
That's why I came up with the idea to package tests (if existing) into
a separate package, which is NOT installed by default.
Please let me know if you see any issues with that patch

Signed-off-by: Konrad Weihmann <kweihm...@outlook.com>
---
 meta/classes/distutils-common-base.bbclass | 5 +++++
 meta/classes/distutils3-base.bbclass       | 1 +
 2 files changed, 6 insertions(+)

diff --git a/meta/classes/distutils-common-base.bbclass 
b/meta/classes/distutils-common-base.bbclass
index 94b5fd426d..50dca7550b 100644
--- a/meta/classes/distutils-common-base.bbclass
+++ b/meta/classes/distutils-common-base.bbclass
@@ -13,8 +13,13 @@ export CCSHARED  = "-fPIC -DPIC"
 # the python executable
 export LINKFORSHARED = "{SECURITY_CFLAGS} -Xlinker -export-dynamic"
 
+PACKAGES =+ "${@oe.utils.ifelse(bb.data.inherits_class('image', d), '', 
'${PN}-tests')}"
+
 FILES_${PN} += "${libdir}/* ${libdir}/${PYTHON_DIR}/*"
 
+FILES_${PN}-tests += "${PYTHON_SITEPACKAGES_DIR}/**/test/*"
+ALLOW_EMPTY_${PN}-tests = "1"
+
 FILES_${PN}-staticdev += "\
   ${PYTHON_SITEPACKAGES_DIR}/*.a \
 "
diff --git a/meta/classes/distutils3-base.bbclass 
b/meta/classes/distutils3-base.bbclass
index 7dbf07ac4b..54bb963a57 100644
--- a/meta/classes/distutils3-base.bbclass
+++ b/meta/classes/distutils3-base.bbclass
@@ -1,5 +1,6 @@
 DEPENDS  += "${@["${PYTHON_PN}-native ${PYTHON_PN}", ""][(d.getVar('PACKAGES') 
== '')]}"
 RDEPENDS_${PN} += "${@['', '${PYTHON_PN}-core']['${CLASSOVERRIDE}' == 
'class-target']}"
+RDEPENDS_${PN}-tests += "${PN}"
 
 inherit distutils-common-base python3native
 
-- 
2.20.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#140383): 
https://lists.openembedded.org/g/openembedded-core/message/140383
Mute This Topic: https://lists.openembedded.org/mt/75361807/21656
Group Owner: openembedded-core+ow...@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub  
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to