Skip to content

Commit

Permalink
python-utils-r1.eclass: Grab paths from sysconfig module
Browse files Browse the repository at this point in the history
Grab site-packages and includedir paths from sysconfig rather than
distutils.sysconfig, as the latter module is deprecated.  The new method
results in the same paths for all supported implementations,
as confirmed by the tests.

Signed-off-by: Michał Górny <[email protected]>
  • Loading branch information
mgorny committed May 12, 2021
1 parent 8220082 commit 7c5a4f2
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions eclass/python-utils-r1.eclass
Original file line number Diff line number Diff line change
Expand Up @@ -318,16 +318,13 @@ _python_export() {
;;
PYTHON_SITEDIR)
[[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it"
# sysconfig can't be used because:
# 1) pypy doesn't give site-packages but stdlib
# 2) jython gives paths with wrong case
PYTHON_SITEDIR=$("${PYTHON}" -c 'import distutils.sysconfig; print(distutils.sysconfig.get_python_lib())') || die
PYTHON_SITEDIR=$("${PYTHON}" -c 'import sysconfig; print(sysconfig.get_path("purelib"))') || die
export PYTHON_SITEDIR
debug-print "${FUNCNAME}: PYTHON_SITEDIR = ${PYTHON_SITEDIR}"
;;
PYTHON_INCLUDEDIR)
[[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it"
PYTHON_INCLUDEDIR=$("${PYTHON}" -c 'import distutils.sysconfig; print(distutils.sysconfig.get_python_inc())') || die
PYTHON_INCLUDEDIR=$("${PYTHON}" -c 'import sysconfig; print(sysconfig.get_path("platinclude"))') || die
export PYTHON_INCLUDEDIR
debug-print "${FUNCNAME}: PYTHON_INCLUDEDIR = ${PYTHON_INCLUDEDIR}"

Expand Down

0 comments on commit 7c5a4f2

Please sign in to comment.