Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-dev@l.g.o
Cc: "Michał Górny" <mgorny@g.o>
Subject: [gentoo-dev] [PATCH 3/4] distutils-r1.eclass: Make build-backend getting more reliable
Date: Tue, 22 Feb 2022 23:31:11
Message-Id: 20220222233011.101456-3-mgorny@gentoo.org
In Reply to: [gentoo-dev] [PATCH 1/4] python-any-r1.eclass: Fix unsupported/invalid EPYTHON logic by "Michał Górny"
1 Protect build-backend getter against stray output to stdout.
2
3 Signed-off-by: Michał Górny <mgorny@g.o>
4 ---
5 eclass/distutils-r1.eclass | 6 ++++--
6 1 file changed, 4 insertions(+), 2 deletions(-)
7
8 diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
9 index 28e44cd790ef..1fe69f1a3dde 100644
10 --- a/eclass/distutils-r1.eclass
11 +++ b/eclass/distutils-r1.eclass
12 @@ -938,10 +938,12 @@ _distutils-r1_get_backend() {
13 # if pyproject.toml exists, try getting the backend from it
14 # NB: this could fail if pyproject.toml doesn't list one
15 build_backend=$(
16 - "${EPYTHON}" - <<-EOF 2>/dev/null
17 + "${EPYTHON}" - 3>&1 &>/dev/null <<-EOF
18 + import os
19 import tomli
20 print(tomli.load(open("pyproject.toml", "rb"))
21 - ["build-system"]["build-backend"])
22 + ["build-system"]["build-backend"],
23 + file=os.fdopen(3, "w"))
24 EOF
25 )
26 fi
27 --
28 2.35.1