All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC][PATCH] distutils: put tests to a separate package
@ 2020-07-07 19:01 Konrad Weihmann
  2020-07-07 19:25 ` [OE-core] " Richard Purdie
  0 siblings, 1 reply; 4+ messages in thread
From: Konrad Weihmann @ 2020-07-07 19:01 UTC (permalink / raw)
  To: openembedded-core; +Cc: Konrad Weihmann

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 <kweihmann@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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [OE-core] [RFC][PATCH] distutils: put tests to a separate package
  2020-07-07 19:01 [RFC][PATCH] distutils: put tests to a separate package Konrad Weihmann
@ 2020-07-07 19:25 ` Richard Purdie
  2020-07-07 19:34   ` Konrad Weihmann
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Purdie @ 2020-07-07 19:25 UTC (permalink / raw)
  To: Konrad Weihmann, openembedded-core

On Tue, 2020-07-07 at 21:01 +0200, Konrad Weihmann wrote:
> 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

Shouldn't these be part of a PN-ptests package to match the rest of the
system?

Cheers,

Richard




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [OE-core] [RFC][PATCH] distutils: put tests to a separate package
  2020-07-07 19:25 ` [OE-core] " Richard Purdie
@ 2020-07-07 19:34   ` Konrad Weihmann
  2020-07-07 19:57     ` Richard Purdie
  0 siblings, 1 reply; 4+ messages in thread
From: Konrad Weihmann @ 2020-07-07 19:34 UTC (permalink / raw)
  To: Richard Purdie, openembedded-core

That's a very good question.
I myself haven't seen python unit tests used via ptests in the wild, but 
if that is used, yes fully agree, it should be rather PN-ptests than 
PN-tests.
BTW it would also require to create a run-ptest file, which would 
complicate things even more.

Regards
Konrad

On 07.07.20 21:25, Richard Purdie wrote:
> On Tue, 2020-07-07 at 21:01 +0200, Konrad Weihmann wrote:
>> 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
> 
> Shouldn't these be part of a PN-ptests package to match the rest of the
> system?
> 
> Cheers,
> 
> Richard
> 
> 
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [OE-core] [RFC][PATCH] distutils: put tests to a separate package
  2020-07-07 19:34   ` Konrad Weihmann
@ 2020-07-07 19:57     ` Richard Purdie
  0 siblings, 0 replies; 4+ messages in thread
From: Richard Purdie @ 2020-07-07 19:57 UTC (permalink / raw)
  To: Konrad Weihmann, openembedded-core

On Tue, 2020-07-07 at 21:34 +0200, Konrad Weihmann wrote:
> That's a very good question.
> I myself haven't seen python unit tests used via ptests in the wild,
> but 
> if that is used, yes fully agree, it should be rather PN-ptests than 
> PN-tests.
> BTW it would also require to create a run-ptest file, which would 
> complicate things even more.

Even if we don't create the run-ptest yet, I think putting them there
is the more correct location...

Cheers,

Richard




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-07-07 19:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-07 19:01 [RFC][PATCH] distutils: put tests to a separate package Konrad Weihmann
2020-07-07 19:25 ` [OE-core] " Richard Purdie
2020-07-07 19:34   ` Konrad Weihmann
2020-07-07 19:57     ` Richard Purdie

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.