Github messages for voidlinux
 help / color / mirror / Atom feed
From: ahesford <ahesford@users.noreply.github.com>
To: ml@inbox.vuxu.org
Subject: Re: [PR PATCH] [Updated] build-style/python3-{module,pep517}.sh: fix check for pytest
Date: Tue, 08 Jun 2021 06:16:41 +0200	[thread overview]
Message-ID: <20210608041641.DM_WfGplNyGGyge-xtFNECOywpz_D8_Ge2Knu_jNYfQ@z> (raw)
In-Reply-To: <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-31354@inbox.vuxu.org>

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

There is an updated pull request by ahesford against master on the void-packages repository

https://github.com/ahesford/void-packages pytest
https://github.com/void-linux/void-packages/pull/31354

build-style/python3-{module,pep517}.sh: fix check for pytest
Relying on `python3 -m pytest --help` to test for pytest can fail
because the pytest packages's __main__ is still invoked; this can
trigger import problems and falsely indicate that pytest is missing.

A simpler test is to just confirm that pytest is importable. If so, the
interpreter returns 0. Otherwise, an ImportError is thrown and the
interpreter will return 1.


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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-pytest-31354.patch --]
[-- Type: text/x-diff, Size: 2370 bytes --]

From 879c11675f52b0f234ae917b28d67b764815a272 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 7 Jun 2021 23:41:26 -0400
Subject: [PATCH] build-style/python3-{module,pep517}.sh: improve pytest check
 and run

1. Relying on `python3 -m pytest --help` to test for pytest can fail
   because the pytest packages's __main__ is still invoked; this can
   trigger import problems and falsely indicate that pytest is missing.
   A simpler test is to just confirm that pytest is importable. If so,
   the interpreter returns 0. Otherwise, an ImportError is thrown and
   the interpreter will return 1.

2. Many templates require a custom do_check just to set PYTHONPATH to
   either a build directory (especially for compiled extensions) or some
   subdirectory of the source tree. Setting PYTHONPATH automatically to
   the build directory should drastically reduce the need for custom
   do_check in py3 templates.
---
 common/build-style/python3-module.sh | 5 +++--
 common/build-style/python3-pep517.sh | 5 +++--
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/common/build-style/python3-module.sh b/common/build-style/python3-module.sh
index ad5fdff252b3..093bdae8a006 100644
--- a/common/build-style/python3-module.sh
+++ b/common/build-style/python3-module.sh
@@ -24,8 +24,9 @@ do_build() {
 }
 
 do_check() {
-	if python3 -m pytest --help >/dev/null 2>&1; then
-		python3 -m pytest ${make_check_args} ${make_check_target}
+	if python3 -c 'import pytest' >/dev/null 2>&1; then
+		PYTHONPATH="$(cd build/lib* && pwd)" \
+			python3 -m pytest ${make_check_args} ${make_check_target}
 	else
 		# Fall back to deprecated setup.py test orchestration without pytest
 		if [ -z "$make_check_target" ]; then
diff --git a/common/build-style/python3-pep517.sh b/common/build-style/python3-pep517.sh
index 4051185a28e6..944f37daf441 100644
--- a/common/build-style/python3-pep517.sh
+++ b/common/build-style/python3-pep517.sh
@@ -13,8 +13,9 @@ do_build() {
 }
 
 do_check() {
-	if python3 -m pytest --help >/dev/null 2>&1; then
-		python3 -m pytest ${make_check_args} ${make_check_target}
+	if python3 -c 'import pytest' >/dev/null 2>&1; then
+		PYTHONPATH="$(cd build/lib* && pwd)" \
+			python3 -m pytest ${make_check_args} ${make_check_target}
 	else
 		msg_warn "Unable to determine tests for PEP517 Python templates"
 		return 0

  reply	other threads:[~2021-06-08  4:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-08  3:48 [PR PATCH] " ahesford
2021-06-08  4:16 ` ahesford [this message]
2021-06-08  5:00 ` [PR PATCH] [Updated] " ahesford
2021-06-08 17:53 ` [PR PATCH] [Closed]: build-style/python3-{module,pep517}.sh: improve pytest usage ahesford

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210608041641.DM_WfGplNyGGyge-xtFNECOywpz_D8_Ge2Knu_jNYfQ@z \
    --to=ahesford@users.noreply.github.com \
    --cc=ml@inbox.vuxu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).