Skip to content

Commit

Permalink
python-utils-r1.eclass: Redo cross-prefix support using sysconfig
Browse files Browse the repository at this point in the history
We recently supported cross-prefix by rewriting PYTHON_SITEDIR and
PYTHON_INCLUDEDIR from BROOT to EPREFIX. We now know that you can get
sysconfig to use EPREFIX in the first place, which is cleaner.

Signed-off-by: James Le Cuirot <[email protected]>
  • Loading branch information
chewi committed Sep 12, 2023
1 parent ef8ae9f commit 8385562
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions eclass/python-utils-r1.eclass
Original file line number Diff line number Diff line change
Expand Up @@ -346,24 +346,22 @@ _python_export() {
PYTHON_SITEDIR)
[[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it"
PYTHON_SITEDIR=$(
"${PYTHON}" - <<-EOF || die
import sysconfig
print(sysconfig.get_path("purelib"))
"${PYTHON}" - "${EPREFIX}/usr" <<-EOF || die
import sys, sysconfig
print(sysconfig.get_path("purelib", vars={"base": sys.argv[1]}))
EOF
)
PYTHON_SITEDIR=${EPREFIX}${PYTHON_SITEDIR#"${BROOT-${EPREFIX}}"}
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}" - <<-EOF || die
import sysconfig
print(sysconfig.get_path("platinclude"))
"${PYTHON}" - "${ESYSROOT}/usr" <<-EOF || die
import sys, sysconfig
print(sysconfig.get_path("platinclude", vars={"installed_platbase": sys.argv[1]}))
EOF
)
PYTHON_INCLUDEDIR=${ESYSROOT}${PYTHON_INCLUDEDIR#"${BROOT-${EPREFIX}}"}
export PYTHON_INCLUDEDIR
debug-print "${FUNCNAME}: PYTHON_INCLUDEDIR = ${PYTHON_INCLUDEDIR}"

Expand Down

0 comments on commit 8385562

Please sign in to comment.