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] python-utils-r1.eclass: Grab paths from sysconfig module
Date: Wed, 05 May 2021 18:01:47
Message-Id: 20210505180134.835751-1-mgorny@gentoo.org
1 Grab site-packages and includedir paths from sysconfig rather than
2 distutils.sysconfig, as the latter module is deprecated. The new method
3 results in the same paths for all supported implementations,
4 as confirmed by the tests.
5
6 Signed-off-by: Michał Górny <mgorny@g.o>
7 ---
8 eclass/python-utils-r1.eclass | 7 ++-----
9 1 file changed, 2 insertions(+), 5 deletions(-)
10
11 diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
12 index 60526b1f6b14..0082a231f0a0 100644
13 --- a/eclass/python-utils-r1.eclass
14 +++ b/eclass/python-utils-r1.eclass
15 @@ -318,16 +318,13 @@ _python_export() {
16 ;;
17 PYTHON_SITEDIR)
18 [[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it"
19 - # sysconfig can't be used because:
20 - # 1) pypy doesn't give site-packages but stdlib
21 - # 2) jython gives paths with wrong case
22 - PYTHON_SITEDIR=$("${PYTHON}" -c 'import distutils.sysconfig; print(distutils.sysconfig.get_python_lib())') || die
23 + PYTHON_SITEDIR=$("${PYTHON}" -c 'import sysconfig; print(sysconfig.get_path("purelib"))') || die
24 export PYTHON_SITEDIR
25 debug-print "${FUNCNAME}: PYTHON_SITEDIR = ${PYTHON_SITEDIR}"
26 ;;
27 PYTHON_INCLUDEDIR)
28 [[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it"
29 - PYTHON_INCLUDEDIR=$("${PYTHON}" -c 'import distutils.sysconfig; print(distutils.sysconfig.get_python_inc())') || die
30 + PYTHON_INCLUDEDIR=$("${PYTHON}" -c 'import sysconfig; print(sysconfig.get_path("platinclude"))') || die
31 export PYTHON_INCLUDEDIR
32 debug-print "${FUNCNAME}: PYTHON_INCLUDEDIR = ${PYTHON_INCLUDEDIR}"
33
34 --
35 2.31.1