public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [PATCH 0/6] distutils-r1.eclass: Enable wheel reuse by default and add `distutils_enable_tests import-check`
@ 2024-07-19 14:56 Michał Górny
  2024-07-19 14:56 ` [gentoo-dev] [PATCH 1/6] distutils-r1.eclass: Fix QA to ignore non-generic "pure" wheels Michał Górny
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Michał Górny @ 2024-07-19 14:56 UTC (permalink / raw
  To: gentoo-dev; +Cc: Michał Górny

Hello,

Here's another batch of changes to distutils-r1.  Its focused on two
topics:

1. Enabling the new wheel reuse code (added 2024-05-20) by default.
   This means that whenever possible, the eclass will invoke the PEP517
   build system just once and install the resulting wheel for all
   suitable implementations.

   This is NFC if you have only a single target enabled.  If you enable
   multiple targets, this gives a major performance boost, as most
   of the time we don't need to spend significant time repeatedly
   invoking slowtools, I mean setuptools.

   It also means that for Python packages using the stable API, we don't
   build roughly identical C or Rust extensions multiple times.

2. Adding `distutils_enable_tests import-check` option.  This is meant
   as a "last resort" for packages that don't feature test suites
   at all.  It uses dev-python/pytest-import-check plugin to verify
   that all installed modules (both .py and .so) are at least
   importable.

   I'm including three example uses of that.  Since it's implemented
   on top of pytest, EPYTEST_DESELECT can be used to skip modules
   that don't meant to be importable.

Pull request: https://github.com/gentoo/gentoo/pull/37187

(note that it's failing because of keywords on pytest-import-check)


Michał Górny (6):
  distutils-r1.eclass: Fix QA to ignore non-generic "pure" wheels
  distutils-r1.eclass: Allow wheel reuse by default
  distutils-r1.eclass: Add distutils_enable_tests import-check
  dev-python/ytmusicapi: Enable import-check testing (sample)
  dev-python/pymountboot: Enable import-check testing (sample)
  dev-python/miniupnpc: Enable import-check testing (sample)

 dev-python/miniupnpc/miniupnpc-2.2.8.ebuild      |  1 +
 .../pymountboot/pymountboot-0.2.3-r1.ebuild      |  2 ++
 dev-python/ytmusicapi/ytmusicapi-1.7.5.ebuild    |  2 +-
 eclass/distutils-r1.eclass                       | 16 +++++++++++++---
 4 files changed, 17 insertions(+), 4 deletions(-)

-- 
2.45.2



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

* [gentoo-dev] [PATCH 1/6] distutils-r1.eclass: Fix QA to ignore non-generic "pure" wheels
  2024-07-19 14:56 [gentoo-dev] [PATCH 0/6] distutils-r1.eclass: Enable wheel reuse by default and add `distutils_enable_tests import-check` Michał Górny
@ 2024-07-19 14:56 ` Michał Górny
  2024-07-19 14:56 ` [gentoo-dev] [PATCH 2/6] distutils-r1.eclass: Allow wheel reuse by default Michał Górny
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Michał Górny @ 2024-07-19 14:56 UTC (permalink / raw
  To: gentoo-dev; +Cc: Michał Górny

Fix the QA check to match on `*py3-none-any.whl` to match the code
matching reusable wheels.  This avoids false positives over
`dev-python/backrefs` that creates separate pure Python wheels for every
Python version.

Signed-off-by: Michał Górny <mgorny@gentoo.org>
---
 eclass/distutils-r1.eclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
index 61c0a80323ec..8227466b4d4c 100644
--- a/eclass/distutils-r1.eclass
+++ b/eclass/distutils-r1.eclass
@@ -1933,7 +1933,7 @@ _distutils-r1_compare_installed_files() {
 	# Perform the check only if at least one potentially reusable wheel
 	# has been produced.  Nonpure packages (e.g. NumPy) may install
 	# interpreter configuration details into sitedir.
-	if [[ ${!DISTUTILS_WHEELS[*]} != *-none-any.whl* &&
+	if [[ ${!DISTUTILS_WHEELS[*]} != *py3-none-any.whl* &&
 			${!DISTUTILS_WHEELS[*]} != *-abi3-*.whl ]]; then
 		return
 	fi
-- 
2.45.2



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

* [gentoo-dev] [PATCH 2/6] distutils-r1.eclass: Allow wheel reuse by default
  2024-07-19 14:56 [gentoo-dev] [PATCH 0/6] distutils-r1.eclass: Enable wheel reuse by default and add `distutils_enable_tests import-check` Michał Górny
  2024-07-19 14:56 ` [gentoo-dev] [PATCH 1/6] distutils-r1.eclass: Fix QA to ignore non-generic "pure" wheels Michał Górny
@ 2024-07-19 14:56 ` Michał Górny
  2024-07-19 14:56 ` [gentoo-dev] [PATCH 3/6] distutils-r1.eclass: Add distutils_enable_tests import-check Michał Górny
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Michał Górny @ 2024-07-19 14:56 UTC (permalink / raw
  To: gentoo-dev; +Cc: Michał Górny

Enable wheel reuse by default, since no issues were revealed during
the testing so far.  The option to disable them remains available, as it
can be useful e.g. to verify that reproducible wheels are actually
produced across implementation.

Signed-off-by: Michał Górny <mgorny@gentoo.org>
---
 eclass/distutils-r1.eclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
index 8227466b4d4c..645b5df5a6e5 100644
--- a/eclass/distutils-r1.eclass
+++ b/eclass/distutils-r1.eclass
@@ -195,7 +195,6 @@ esac
 # @CODE
 
 # @ECLASS_VARIABLE: DISTUTILS_ALLOW_WHEEL_REUSE
-# @DEFAULT_UNSET
 # @USER_VARIABLE
 # @DESCRIPTION:
 # If set to a non-empty value, the eclass is allowed to reuse a wheel
@@ -205,6 +204,7 @@ esac
 # This is an optimization that can avoid the overhead of calling into
 # the build system in pure Python packages and packages using the stable
 # Python ABI.
+DISTUTILS_ALLOW_WHEEL_REUSE=1
 
 # @ECLASS_VARIABLE: BUILD_DIR
 # @OUTPUT_VARIABLE
-- 
2.45.2



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

* [gentoo-dev] [PATCH 3/6] distutils-r1.eclass: Add distutils_enable_tests import-check
  2024-07-19 14:56 [gentoo-dev] [PATCH 0/6] distutils-r1.eclass: Enable wheel reuse by default and add `distutils_enable_tests import-check` Michał Górny
  2024-07-19 14:56 ` [gentoo-dev] [PATCH 1/6] distutils-r1.eclass: Fix QA to ignore non-generic "pure" wheels Michał Górny
  2024-07-19 14:56 ` [gentoo-dev] [PATCH 2/6] distutils-r1.eclass: Allow wheel reuse by default Michał Górny
@ 2024-07-19 14:56 ` Michał Górny
  2024-07-19 14:56 ` [gentoo-dev] [PATCH 4/6] dev-python/ytmusicapi: Enable import-check testing (sample) Michał Górny
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Michał Górny @ 2024-07-19 14:56 UTC (permalink / raw
  To: gentoo-dev; +Cc: Michał Górny

Add support for using the dev-python/pytest-import-check plugin to
test if all modules installed by the package can be imported.

Signed-off-by: Michał Górny <mgorny@gentoo.org>
---
 eclass/distutils-r1.eclass | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
index 645b5df5a6e5..fa8edb5cdfb7 100644
--- a/eclass/distutils-r1.eclass
+++ b/eclass/distutils-r1.eclass
@@ -572,6 +572,9 @@ distutils_enable_sphinx() {
 # with the specified test runner.  Also copies the current value
 # of RDEPEND to test?-BDEPEND.  The test-runner argument must be one of:
 #
+# - import-check: `pytest --import-check` fallback (for use when there are
+#   no tests to run)
+#
 # - pytest: dev-python/pytest
 #
 # - setup.py: setup.py test (no deps included)
@@ -597,9 +600,13 @@ distutils_enable_tests() {
 	[[ ${#} -eq 1 ]] || die "${FUNCNAME} takes exactly one argument: test-runner"
 
 	local test_deps=${RDEPEND}
+	local test_pkgs=
 	case ${1} in
+		import-check)
+			test_pkgs+=' dev-python/pytest-import-check[${PYTHON_USEDEP}]'
+			;&
 		pytest)
-			local test_pkgs='>=dev-python/pytest-7.4.4[${PYTHON_USEDEP}]'
+			test_pkgs+=' >=dev-python/pytest-7.4.4[${PYTHON_USEDEP}]'
 			if [[ -n ${EPYTEST_TIMEOUT} ]]; then
 				test_pkgs+=' dev-python/pytest-timeout[${PYTHON_USEDEP}]'
 			fi
@@ -1560,6 +1567,9 @@ distutils-r1_python_test() {
 	_python_check_EPYTHON
 
 	case ${_DISTUTILS_TEST_RUNNER} in
+		import-check)
+			epytest --import-check "${BUILD_DIR}/install$(python_get_sitedir)"
+			;;
 		pytest)
 			epytest
 			;;
-- 
2.45.2



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

* [gentoo-dev] [PATCH 4/6] dev-python/ytmusicapi: Enable import-check testing (sample)
  2024-07-19 14:56 [gentoo-dev] [PATCH 0/6] distutils-r1.eclass: Enable wheel reuse by default and add `distutils_enable_tests import-check` Michał Górny
                   ` (2 preceding siblings ...)
  2024-07-19 14:56 ` [gentoo-dev] [PATCH 3/6] distutils-r1.eclass: Add distutils_enable_tests import-check Michał Górny
@ 2024-07-19 14:56 ` Michał Górny
  2024-07-19 14:56 ` [gentoo-dev] [PATCH 5/6] dev-python/pymountboot: " Michał Górny
  2024-07-19 14:56 ` [gentoo-dev] [PATCH 6/6] dev-python/miniupnpc: " Michał Górny
  5 siblings, 0 replies; 7+ messages in thread
From: Michał Górny @ 2024-07-19 14:56 UTC (permalink / raw
  To: gentoo-dev; +Cc: Michał Górny

Signed-off-by: Michał Górny <mgorny@gentoo.org>
---
 dev-python/ytmusicapi/ytmusicapi-1.7.5.ebuild | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/dev-python/ytmusicapi/ytmusicapi-1.7.5.ebuild b/dev-python/ytmusicapi/ytmusicapi-1.7.5.ebuild
index b1568c0ab835..e101a972e750 100644
--- a/dev-python/ytmusicapi/ytmusicapi-1.7.5.ebuild
+++ b/dev-python/ytmusicapi/ytmusicapi-1.7.5.ebuild
@@ -15,10 +15,10 @@ HOMEPAGE="https://ytmusicapi.readthedocs.io/
 LICENSE="MIT"
 SLOT="0"
 KEYWORDS="~amd64 ~x86"
-RESTRICT="test"
 
 RDEPEND="
 	dev-python/requests[${PYTHON_USEDEP}]
 "
 
 distutils_enable_sphinx docs/source dev-python/sphinx-rtd-theme
+distutils_enable_tests import-check
-- 
2.45.2



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

* [gentoo-dev] [PATCH 5/6] dev-python/pymountboot: Enable import-check testing (sample)
  2024-07-19 14:56 [gentoo-dev] [PATCH 0/6] distutils-r1.eclass: Enable wheel reuse by default and add `distutils_enable_tests import-check` Michał Górny
                   ` (3 preceding siblings ...)
  2024-07-19 14:56 ` [gentoo-dev] [PATCH 4/6] dev-python/ytmusicapi: Enable import-check testing (sample) Michał Górny
@ 2024-07-19 14:56 ` Michał Górny
  2024-07-19 14:56 ` [gentoo-dev] [PATCH 6/6] dev-python/miniupnpc: " Michał Górny
  5 siblings, 0 replies; 7+ messages in thread
From: Michał Górny @ 2024-07-19 14:56 UTC (permalink / raw
  To: gentoo-dev; +Cc: Michał Górny

Signed-off-by: Michał Górny <mgorny@gentoo.org>
---
 dev-python/pymountboot/pymountboot-0.2.3-r1.ebuild | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/dev-python/pymountboot/pymountboot-0.2.3-r1.ebuild b/dev-python/pymountboot/pymountboot-0.2.3-r1.ebuild
index 470b4e018e5b..ee6883922cd4 100644
--- a/dev-python/pymountboot/pymountboot-0.2.3-r1.ebuild
+++ b/dev-python/pymountboot/pymountboot-0.2.3-r1.ebuild
@@ -29,3 +29,5 @@ RDEPEND="
 BDEPEND="
 	virtual/pkgconfig
 "
+
+distutils_enable_tests import-check
-- 
2.45.2



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

* [gentoo-dev] [PATCH 6/6] dev-python/miniupnpc: Enable import-check testing (sample)
  2024-07-19 14:56 [gentoo-dev] [PATCH 0/6] distutils-r1.eclass: Enable wheel reuse by default and add `distutils_enable_tests import-check` Michał Górny
                   ` (4 preceding siblings ...)
  2024-07-19 14:56 ` [gentoo-dev] [PATCH 5/6] dev-python/pymountboot: " Michał Górny
@ 2024-07-19 14:56 ` Michał Górny
  5 siblings, 0 replies; 7+ messages in thread
From: Michał Górny @ 2024-07-19 14:56 UTC (permalink / raw
  To: gentoo-dev; +Cc: Michał Górny

Signed-off-by: Michał Górny <mgorny@gentoo.org>
---
 dev-python/miniupnpc/miniupnpc-2.2.8.ebuild | 1 +
 1 file changed, 1 insertion(+)

diff --git a/dev-python/miniupnpc/miniupnpc-2.2.8.ebuild b/dev-python/miniupnpc/miniupnpc-2.2.8.ebuild
index cb0ab1a5907e..4dc7d2542ada 100644
--- a/dev-python/miniupnpc/miniupnpc-2.2.8.ebuild
+++ b/dev-python/miniupnpc/miniupnpc-2.2.8.ebuild
@@ -49,3 +49,4 @@ DOCS=()
 
 # Example test command:
 # python -c 'import miniupnpc; u = miniupnpc.UPnP(); u.discover(); u.selectigd(); print(u.externalipaddress())'
+distutils_enable_tests import-check
-- 
2.45.2



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

end of thread, other threads:[~2024-07-19 15:06 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-19 14:56 [gentoo-dev] [PATCH 0/6] distutils-r1.eclass: Enable wheel reuse by default and add `distutils_enable_tests import-check` Michał Górny
2024-07-19 14:56 ` [gentoo-dev] [PATCH 1/6] distutils-r1.eclass: Fix QA to ignore non-generic "pure" wheels Michał Górny
2024-07-19 14:56 ` [gentoo-dev] [PATCH 2/6] distutils-r1.eclass: Allow wheel reuse by default Michał Górny
2024-07-19 14:56 ` [gentoo-dev] [PATCH 3/6] distutils-r1.eclass: Add distutils_enable_tests import-check Michał Górny
2024-07-19 14:56 ` [gentoo-dev] [PATCH 4/6] dev-python/ytmusicapi: Enable import-check testing (sample) Michał Górny
2024-07-19 14:56 ` [gentoo-dev] [PATCH 5/6] dev-python/pymountboot: " Michał Górny
2024-07-19 14:56 ` [gentoo-dev] [PATCH 6/6] dev-python/miniupnpc: " Michał Górny

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox