python-utils-r1.eclass: Obtain PYTHON_SITEDIR from the interpreter

Obtain the Python site-packages directory path using
the distutils.sysconfig module, rather than hardcoding it.
This commit is contained in:
Michał Górny
2015-11-11 11:21:25 +01:00
parent e0d0c11486
commit fd4001e968
2 changed files with 12 additions and 16 deletions
+5 -11
View File
@@ -126,6 +126,7 @@ _python_impl_supported() {
# The path to Python site-packages directory.
#
# Set and exported on request using python_export().
# Requires a proper build-time dependency on the Python implementation.
#
# Example value:
# @CODE
@@ -267,17 +268,10 @@ python_export() {
debug-print "${FUNCNAME}: PYTHON = ${PYTHON}"
;;
PYTHON_SITEDIR)
local dir
case "${impl}" in
python*|pypy|pypy3)
dir=/usr/$(get_libdir)/${impl}
;;
jython*)
dir=/usr/share/${impl/n/n-}/Lib
;;
esac
export PYTHON_SITEDIR=${EPREFIX}${dir}/site-packages
# sysconfig can't be used because:
# 1) pypy doesn't give site-packages but stdlib
# 2) jython gives paths with wrong case
export PYTHON_SITEDIR=$("${PYTHON}" -c 'import distutils.sysconfig; print(distutils.sysconfig.get_python_lib())')
debug-print "${FUNCNAME}: PYTHON_SITEDIR = ${PYTHON_SITEDIR}"
;;
PYTHON_INCLUDEDIR)