Github messages for voidlinux
 help / color / mirror / Atom feed
* [PR PATCH] common/build-style/python3-pep517.sh: unpack wheels for testing
@ 2023-02-01 14:52 icp1994
  2023-04-12 19:46 ` classabbyamp
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: icp1994 @ 2023-02-01 14:52 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1293 bytes --]

There is a new pull request by icp1994 against master on the void-packages repository

https://github.com/icp1994/void-packages pep517-build-style
https://github.com/void-linux/void-packages/pull/42013

common/build-style/python3-pep517.sh: unpack wheels for testing
#### Testing the changes
- I tested the changes in this PR: **YES**

Python packages built with pep517 system occasionally require accessing distinfo files and/or entry points provided by the package for tests to run. Since these assets are packed inside the wheel generated in `do_build`, the target wheel is unpacked in `do_check` first so that the said artifacts are accessible during test runs.

Initially I unpacked the wheel during `do_build` with the `do_install` only copying the unarchived files (similar to the zig build style). That required patching pep517 templates with explicit `do_build` but no explicit `do_install`. There were only four such cases and it worked fine for me locally but maybe that was too big of a change so submitting this version for now instead.

The later commits are for demonstration purpose and not intended for merging. Those templates (and hopefully all others) still work fine as is.

A patch file from https://github.com/void-linux/void-packages/pull/42013.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-pep517-build-style-42013.patch --]
[-- Type: text/x-diff, Size: 10769 bytes --]

From b9cc6b6690c3a6daed8a5c4472cb16c58c856c06 Mon Sep 17 00:00:00 2001
From: icp <pangolin@vivaldi.net>
Date: Wed, 1 Feb 2023 11:16:05 +0530
Subject: [PATCH 1/9] common/build-style/python3-pep517.sh: unpack wheels for
 testing

Python packages built with pep517 system occasionally require
accessing distinfo files and/or entry points provided by the
package for tests to run. Since these assets are packed inside
the wheel generated in `do_build`, the target wheel is unpacked
in `do_check` first so that the said artifacts are accessible
during test runs.
---
 common/build-style/python3-pep517.sh | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/common/build-style/python3-pep517.sh b/common/build-style/python3-pep517.sh
index b8bdee585208..f34b05c2a550 100644
--- a/common/build-style/python3-pep517.sh
+++ b/common/build-style/python3-pep517.sh
@@ -14,7 +14,18 @@ do_check() {
 		if python3 -c 'import xdist' >/dev/null 2>&1; then
 			testjobs="-n $XBPS_MAKEJOBS"
 		fi
-		${make_check_pre} python3 -m pytest ${testjobs} ${make_check_args} ${make_check_target}
+
+		if [ -z "${make_install_target}" ]; then
+			local wheelbase="${pkgname#python3-}"
+			make_install_target="dist/${wheelbase//-/_}-${version}-*-*-*.whl"
+		fi
+
+		local testdir="tmp/$(date +%s)"
+		python3 -m installer --destdir "${testdir}" \
+			${make_install_args} ${make_install_target}
+
+		PATH="${testdir}/usr/bin:${PATH}" PYTHONPATH="${testdir}/${py3_sitelib}" \
+			${make_check_pre} pytest3 ${testjobs} ${make_check_args} ${make_check_target}
 	else
 		msg_warn "Unable to determine tests for PEP517 Python templates\n"
 		return 0

From 9041067c1a0eb5e721c6920b7604af5b983bb0d9 Mon Sep 17 00:00:00 2001
From: icp <pangolin@vivaldi.net>
Date: Wed, 1 Feb 2023 11:48:00 +0530
Subject: [PATCH 2/9] fava: repackage with updated pep517 build style

---
 srcpkgs/fava/template | 1 -
 1 file changed, 1 deletion(-)

diff --git a/srcpkgs/fava/template b/srcpkgs/fava/template
index 5bf30cb3f3c3..8e7d7c914bb9 100644
--- a/srcpkgs/fava/template
+++ b/srcpkgs/fava/template
@@ -3,7 +3,6 @@ pkgname=fava
 version=1.23.1
 revision=1
 build_style=python3-pep517
-make_check_args="--deselect tests/test_cli.py::test_cli"
 hostmakedepends="python3-setuptools_scm python3-wheel"
 depends="python3-Babel python3-Cheroot python3-Flask-Babel python3-Flask
  python3-Jinja2 beancount python3-click python3-markdown2 python3-ply

From 4f9969f8f15eb9bb3a0def53a86210e29fafa18e Mon Sep 17 00:00:00 2001
From: icp <pangolin@vivaldi.net>
Date: Wed, 1 Feb 2023 18:30:34 +0530
Subject: [PATCH 3/9] hatch: repackage with updated pep517 build style

---
 srcpkgs/hatch/template | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/hatch/template b/srcpkgs/hatch/template
index 670f9b987fa6..1c047cec3821 100644
--- a/srcpkgs/hatch/template
+++ b/srcpkgs/hatch/template
@@ -5,10 +5,8 @@ revision=2
 build_style=python3-pep517
 # ignore backend tests, because updating hatchling when there is no new hatch
 # version yet breaks these in hatch.
-make_check_args="--deselect tests/cli/test_root.py::TestFreshInstallation::test_config_file_creation_verbose
- --deselect tests/cli/run/test_run.py::test_scripts_no_environment
- --ignore tests/backend
- --ignore backend/tests"
+make_check_args="--ignore tests/backend
+ --deselect tests/cli/run/test_run.py::test_scripts_no_environment"
 _deps="python3-click hatchling python3-httpx python3-hyperlink python3-keyring
  python3-packaging python3-pexpect python3-platformdirs python3-pyperclip
  python3-rich python3-shellingham python3-tomli-w python3-tomlkit

From df43b017ac23894faa4e564c00af9637225a572f Mon Sep 17 00:00:00 2001
From: icp <pangolin@vivaldi.net>
Date: Wed, 1 Feb 2023 18:22:59 +0530
Subject: [PATCH 4/9] python3-quart: repackage with updated pep517 build style

---
 srcpkgs/python3-quart/template | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/srcpkgs/python3-quart/template b/srcpkgs/python3-quart/template
index 71aefd7c7ebc..63c3e4975e1b 100644
--- a/srcpkgs/python3-quart/template
+++ b/srcpkgs/python3-quart/template
@@ -7,7 +7,7 @@ make_install_target="dist/quart-${version}-*-*-*.whl"
 hostmakedepends="python3-poetry-core"
 depends="python3-aiofiles python3-hypercorn python3-click python3-MarkupSafe
  python3-blinker python3-itsdangerous python3-Jinja2 python3-Werkzeug"
-checkdepends="python3-pytest-asyncio python3-hypothesis python3-mock python3-dotenv unzip $depends"
+checkdepends="python3-pytest-asyncio python3-hypothesis python3-mock python3-dotenv $depends"
 short_desc="Python asyncio ASGI web framework with Flask API"
 maintainer="Andrew J. Hesford <ajh@sideband.org>"
 license="MIT"
@@ -16,14 +16,8 @@ changelog="https://raw.githubusercontent.com/pallets/quart/main/CHANGES.rst"
 distfiles="https://github.com/pallets/quart/archive/refs/tags/${version}.tar.gz"
 checksum=68ce4e6f786d5bf4a6056569e07e7055e1dfbb7136a531a18087345d8ba34c5c
 
-do_check() {
-	# Tests require dist-info on the package, which is only in the wheel.
-	# Pip can install the wheel in the build tree, but unzip is less evil.
-	mkdir -p test
-	unzip ${make_install_target} -d test
-
+pre_check() {
 	vsed -e '/addopts/d' -i pyproject.toml
-	PYTHONPATH=test python3 -m pytest
 }
 
 post_install() {

From 2eea73bb5b0aa20b7e5c576c177fcab4e3dd9b7f Mon Sep 17 00:00:00 2001
From: icp <pangolin@vivaldi.net>
Date: Wed, 1 Feb 2023 18:45:21 +0530
Subject: [PATCH 5/9] python3-bcrypt: repackage with updated pep517 build style

---
 srcpkgs/python3-bcrypt/template | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/srcpkgs/python3-bcrypt/template b/srcpkgs/python3-bcrypt/template
index ae3006dd6695..869fe684ce2f 100644
--- a/srcpkgs/python3-bcrypt/template
+++ b/srcpkgs/python3-bcrypt/template
@@ -14,7 +14,3 @@ homepage="https://github.com/pyca/bcrypt"
 changelog="https://github.com/pyca/bcrypt/blob/main/README.rst#changelog"
 distfiles="${PYPI_SITE}/b/bcrypt/bcrypt-${version}.tar.gz"
 checksum=433c410c2177057705da2a9f2cd01dd157493b2a7ac14c8593a16b3dab6b6bfb
-
-do_check() {
-	PYTHONPATH="$(cd build/lib* && pwd)" pytest
-}

From ac7c0d9d4dd996c6457bc778ae76f3ebdba34778 Mon Sep 17 00:00:00 2001
From: icp <pangolin@vivaldi.net>
Date: Wed, 1 Feb 2023 19:32:19 +0530
Subject: [PATCH 6/9] python3-adblock: repackage with updated pep517 build
 style

---
 srcpkgs/python3-adblock/template | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/srcpkgs/python3-adblock/template b/srcpkgs/python3-adblock/template
index ebd4a7f62acc..6c44e84c6f13 100644
--- a/srcpkgs/python3-adblock/template
+++ b/srcpkgs/python3-adblock/template
@@ -33,11 +33,6 @@ do_build() {
 	mv adblock-${version}-*.whl dist/adblock-${version}-py3-none-any.whl
 }
 
-pre_check() {
-	# Tests require the compiled extension
-	cp target/${RUST_TARGET}/release/libadblock.so adblock/adblock.so
-}
-
 post_install() {
 	vlicense LICENSE-MIT
 	chmod 755 ${DESTDIR}/${py3_sitelib}/adblock/*.so

From a93746a7ef9075b7e72e459425955c123a16cd68 Mon Sep 17 00:00:00 2001
From: icp <pangolin@vivaldi.net>
Date: Wed, 1 Feb 2023 18:33:39 +0530
Subject: [PATCH 7/9] python3-jsonschema: repackage with updated pep517 build
 style

---
 srcpkgs/python3-jsonschema/template | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/srcpkgs/python3-jsonschema/template b/srcpkgs/python3-jsonschema/template
index f9b0c2e19528..8ec7cef8d755 100644
--- a/srcpkgs/python3-jsonschema/template
+++ b/srcpkgs/python3-jsonschema/template
@@ -3,6 +3,7 @@ pkgname=python3-jsonschema
 version=4.17.3
 revision=1
 build_style=python3-pep517
+make_check_args="--deselect jsonschema/tests/test_jsonschema_test_suite.py::test_suite_bug"
 hostmakedepends="hatchling hatch-vcs"
 depends="python3-attrs python3-pyrsistent"
 checkdepends="${depends} python3-pytest python3-pip"
@@ -14,16 +15,6 @@ changelog="https://raw.githubusercontent.com/Julian/jsonschema/master/CHANGELOG.
 distfiles="${PYPI_SITE}/j/jsonschema/jsonschema-${version}.tar.gz"
 checksum=0f864437ab8b6076ba6707453ef8f98a6a0d512a80e93f8abdb676f737ecb60d
 
-do_check() {
-	rm -rf *.dist-info tmp # remove artifacts from previous unsuccessful check run
-	mkdir tmp
-	bsdtar xf dist/jsonschema-$version-py3-none-any.whl -C tmp
-	rm tmp/jsonschema/tests -rf
-	mv tmp/*.dist-info .
-	PYTHONPATH=. pytest --deselect jsonschema/tests/test_jsonschema_test_suite.py::test_suite_bug
-	rm -rf *.dist-info tmp
-}
-
 pre_build() {
 	export SETUPTOOLS_SCM_PRETEND_VERSION="${version}"
 }

From 8904bbe2673f7b6d4d0ba0392ef575aa41622077 Mon Sep 17 00:00:00 2001
From: icp <pangolin@vivaldi.net>
Date: Wed, 1 Feb 2023 18:52:21 +0530
Subject: [PATCH 8/9] python3-pytest-isort: repackage with updated pep517 build
 style

---
 srcpkgs/python3-pytest-isort/template | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/python3-pytest-isort/template b/srcpkgs/python3-pytest-isort/template
index c3566853a180..bf3b5dcab8b5 100644
--- a/srcpkgs/python3-pytest-isort/template
+++ b/srcpkgs/python3-pytest-isort/template
@@ -11,10 +11,8 @@ maintainer="Jan Christian Grünhage <jan.christian@gruenhage.xyz>"
 license="MIT"
 homepage="https://github.com/stephrdev/pytest-isort"
 changelog="https://github.com/stephrdev/pytest-isort/raw/master/CHANGELOG.rst"
-distfiles="${PYPI_SITE}/p/pytest_isort/pytest_isort-${version}.tar.gz"
-checksum=067801dc5e54a474330d074d521c815948ff6d5cf0ed3b9d057b78216851186c
-# cba for now
-make_check=no
+distfiles="https://github.com/stephrdev/pytest-isort/archive/refs/tags/${version}.tar.gz"
+checksum=c6994dd442e2fe50f2667d6fa6e14a5800192966b628cc31107c8f96c36a514b
 
 post_install() {
 	vlicense LICENSE.rst

From e836cba32e6c6ae1610a74bb6066fee1339be719 Mon Sep 17 00:00:00 2001
From: icp <pangolin@vivaldi.net>
Date: Wed, 1 Feb 2023 18:35:10 +0530
Subject: [PATCH 9/9] python3-pytest-httpserver: repackage with updated pep517
 build style

---
 srcpkgs/python3-pytest-httpserver/template | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/srcpkgs/python3-pytest-httpserver/template b/srcpkgs/python3-pytest-httpserver/template
index 5fa0f6f24ea5..f04aa3c6b4b5 100644
--- a/srcpkgs/python3-pytest-httpserver/template
+++ b/srcpkgs/python3-pytest-httpserver/template
@@ -14,14 +14,6 @@ changelog="https://raw.githubusercontent.com/csernazs/pytest-httpserver/master/C
 distfiles="https://github.com/csernazs/pytest-httpserver/archive/refs/tags/${version}.tar.gz"
 checksum=932843df9fa584e6a664b2e7a21dec4ddf9507c235a78853f21e00b111352395
 
-do_check() {
-	rm -rf tmp # remove artifacts from previous unsuccessful check run
-	mkdir tmp
-	bsdtar xf dist/pytest_httpserver-$version-py3-none-any.whl -C tmp
-	PYTHONPATH=tmp pytest tests
-	rm -rf tmp
-}
-
 post_install() {
 	vlicense LICENSE
 }

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

* Re: common/build-style/python3-pep517.sh: unpack wheels for testing
  2023-02-01 14:52 [PR PATCH] common/build-style/python3-pep517.sh: unpack wheels for testing icp1994
@ 2023-04-12 19:46 ` classabbyamp
  2023-04-12 19:55 ` ahesford
  2023-04-12 19:55 ` [PR PATCH] [Closed]: " ahesford
  2 siblings, 0 replies; 4+ messages in thread
From: classabbyamp @ 2023-04-12 19:46 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 307 bytes --]

New comment by classabbyamp on void-packages repository

https://github.com/void-linux/void-packages/pull/42013#issuecomment-1505830810

Comment:
> The later commits are for demonstration purpose and not intended for merging.

i think it's fine to merge those changes with this, it's a beneficial cleanup

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

* Re: common/build-style/python3-pep517.sh: unpack wheels for testing
  2023-02-01 14:52 [PR PATCH] common/build-style/python3-pep517.sh: unpack wheels for testing icp1994
  2023-04-12 19:46 ` classabbyamp
@ 2023-04-12 19:55 ` ahesford
  2023-04-12 19:55 ` [PR PATCH] [Closed]: " ahesford
  2 siblings, 0 replies; 4+ messages in thread
From: ahesford @ 2023-04-12 19:55 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 214 bytes --]

New comment by ahesford on void-packages repository

https://github.com/void-linux/void-packages/pull/42013#issuecomment-1505840612

Comment:
Rebased and merged in 2890951790ff1c357917a4a3ebac54446898ed50, thanks!

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

* Re: [PR PATCH] [Closed]: common/build-style/python3-pep517.sh: unpack wheels for testing
  2023-02-01 14:52 [PR PATCH] common/build-style/python3-pep517.sh: unpack wheels for testing icp1994
  2023-04-12 19:46 ` classabbyamp
  2023-04-12 19:55 ` ahesford
@ 2023-04-12 19:55 ` ahesford
  2 siblings, 0 replies; 4+ messages in thread
From: ahesford @ 2023-04-12 19:55 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1131 bytes --]

There's a closed pull request on the void-packages repository

common/build-style/python3-pep517.sh: unpack wheels for testing
https://github.com/void-linux/void-packages/pull/42013

Description:
#### Testing the changes
- I tested the changes in this PR: **YES**

Python packages built with pep517 system occasionally require accessing distinfo files and/or entry points provided by the package for tests to run. Since these assets are packed inside the wheel generated in `do_build`, the target wheel is unpacked in `do_check` first so that the said artifacts are accessible during test runs.

Initially I unpacked the wheel during `do_build` with the `do_install` only copying the unarchived files (similar to the zig build style). That required patching pep517 templates with explicit `do_build` but no explicit `do_install`. There were only four such cases and it worked fine for me locally but maybe that was too big of a change so submitting this version for now instead.

The later commits are for demonstration purpose and not intended for merging. Those templates (and hopefully all others) still work fine as is.

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

end of thread, other threads:[~2023-04-12 19:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-01 14:52 [PR PATCH] common/build-style/python3-pep517.sh: unpack wheels for testing icp1994
2023-04-12 19:46 ` classabbyamp
2023-04-12 19:55 ` ahesford
2023-04-12 19:55 ` [PR PATCH] [Closed]: " ahesford

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).