[prev in list] [next in list] [prev in thread] [next in thread]
List: gentoo-dev
Subject: [gentoo-dev] [PATCH 13/25] python-utils-r2.eclass: Remove PYTHON_SITEDIR export
From: Michał Górny <mgorny () gentoo ! org>
Date: 2020-02-29 20:41:49
Message-ID: 20200229204201.99290-14-mgorny () gentoo ! org
[Download RAW message or body]
Signed-off-by: Michał Górny <mgorny@gentoo.org>
---
eclass/python-utils-r2.eclass | 34 +++++++++++----------------------
eclass/tests/python-utils-r2.sh | 25 ++++++++++++++++++------
2 files changed, 30 insertions(+), 29 deletions(-)
diff --git a/eclass/python-utils-r2.eclass b/eclass/python-utils-r2.eclass
index e7f2b4c68c59..971dd4393963 100644
--- a/eclass/python-utils-r2.eclass
+++ b/eclass/python-utils-r2.eclass
@@ -235,10 +235,6 @@ _python_impl_matches() {
# implementation (either as PYTHON_TARGETS value, e.g. python2_7,
# or an EPYTHON one, e.g. python2.7). If no implementation passed,
# the current one will be obtained from ${EPYTHON}.
-#
-# The variables which can be exported are: PYTHON, EPYTHON,
-# PYTHON_SITEDIR. They are described more completely in the eclass
-# variable documentation.
_python_export() {
debug-print-function ${FUNCNAME} "${@}"
@@ -272,15 +268,6 @@ _python_export() {
export PYTHON=${EPREFIX}/usr/bin/${impl}
debug-print "${FUNCNAME}: PYTHON = ${PYTHON}"
;;
- 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
- 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 @@ -390,16 +377,18 @@ \
_python_export() { }
# @FUNCTION: python_get_sitedir
-# @USAGE: [<impl>]
# @DESCRIPTION:
-# Obtain and print the 'site-packages' path for the given
-# implementation. If no implementation is provided, ${EPYTHON} will
-# be used.
+# Obtain and print the 'site-packages' path for ${EPYTHON}.
python_get_sitedir() {
debug-print-function ${FUNCNAME} "${@}"
-
- _python_export "${@}" PYTHON_SITEDIR
- echo "${PYTHON_SITEDIR}"
+ [[ ${EPYTHON} ]] || die "EPYTHON must be set before calling ${FUNCNAME}"
+
+ # sysconfig can't be used because:
+ # 1) pypy doesn't give site-packages but stdlib
+ # 2) jython gives paths with wrong case
+ local out=$("${EPYTHON}" -c 'import distutils.sysconfig; \
print(distutils.sysconfig.get_python_lib())') || die + debug-print "${FUNCNAME} -> \
${out}" + echo "${out}"
}
# @FUNCTION: python_get_includedir
@@ -749,7 +738,7 @@ python_newscript() {
# @CODE
# src_install() {
# python_moduleinto bar
-# # installs ${PYTHON_SITEDIR}/bar/baz.py
+# # installs $(python_get_sitedir)/bar/baz.py
# python_foreach_impl python_domodule baz.py
# }
# @CODE
@@ -785,8 +774,7 @@ python_domodule() {
d=${python_moduleroot}
else
# relative to site-packages
- local PYTHON_SITEDIR=${PYTHON_SITEDIR}
- [[ ${PYTHON_SITEDIR} ]] || _python_export PYTHON_SITEDIR
+ local PYTHON_SITEDIR=$(python_get_sitedir)
d=${PYTHON_SITEDIR#${EPREFIX}}/${python_moduleroot//.//}
fi
diff --git a/eclass/tests/python-utils-r2.sh b/eclass/tests/python-utils-r2.sh
index c5e618256519..423a0465d39a 100755
--- a/eclass/tests/python-utils-r2.sh
+++ b/eclass/tests/python-utils-r2.sh
@@ -19,6 +19,19 @@ test_var() {
tend ${?}
}
+test_get() {
+ local getter=python_get_${1}
+ local impl=${2}
+ local expect=${3}
+
+ tbegin "${getter} for ${impl}"
+
+ local val=$(EPYTHON=${impl} ${getter})
+ [[ ${val} == ${expect} ]] || eerror "(${impl}: ${getter}: ${val} != ${expect}"
+
+ tend ${?}
+}
+
test_is() {
local func=${1}
local expect=${2}
@@ -63,7 +76,7 @@ inherit python-utils-r2
test_var EPYTHON python2_7 python2.7
test_var PYTHON python2_7 /usr/bin/python2.7
if [[ -x /usr/bin/python2.7 ]]; then
- test_var PYTHON_SITEDIR python2_7 "/usr/lib*/python2.7/site-packages"
+ test_get sitedir python2.7 "/usr/lib*/python2.7/site-packages"
test_var PYTHON_INCLUDEDIR python2_7 /usr/include/python2.7
test_var PYTHON_LIBPATH python2_7 "/usr/lib*/libpython2.7$(get_libname)"
test_var PYTHON_CONFIG python2_7 /usr/bin/python2.7-config
@@ -77,7 +90,7 @@ test_var EPYTHON python3_6 python3.6
test_var PYTHON python3_6 /usr/bin/python3.6
if [[ -x /usr/bin/python3.6 ]]; then
abiflags=$(/usr/bin/python3.6 -c 'import sysconfig; \
print(sysconfig.get_config_var("ABIFLAGS"))')
- test_var PYTHON_SITEDIR python3_6 "/usr/lib*/python3.6/site-packages"
+ test_get sitedir python3.6 "/usr/lib*/python3.6/site-packages"
test_var PYTHON_INCLUDEDIR python3_6 "/usr/include/python3.6${abiflags}"
test_var PYTHON_LIBPATH python3_6 "/usr/lib*/libpython3.6${abiflags}$(get_libname)"
test_var PYTHON_CONFIG python3_6 "/usr/bin/python3.6${abiflags}-config"
@@ -91,7 +104,7 @@ test_var EPYTHON python3_7 python3.7
test_var PYTHON python3_7 /usr/bin/python3.7
if [[ -x /usr/bin/python3.7 ]]; then
abiflags=$(/usr/bin/python3.7 -c 'import sysconfig; \
print(sysconfig.get_config_var("ABIFLAGS"))')
- test_var PYTHON_SITEDIR python3_7 "/usr/lib/python3.7/site-packages"
+ test_get sitedir python3.7 "/usr/lib/python3.7/site-packages"
test_var PYTHON_INCLUDEDIR python3_7 "/usr/include/python3.7${abiflags}"
test_var PYTHON_LIBPATH python3_7 "/usr/lib*/libpython3.7${abiflags}$(get_libname)"
test_var PYTHON_CONFIG python3_7 "/usr/bin/python3.7${abiflags}-config"
@@ -104,7 +117,7 @@ test_var PYTHON_SCRIPTDIR python3_7 \
/usr/lib/python-exec/python3.7 test_var EPYTHON jython2_7 jython2.7
test_var PYTHON jython2_7 /usr/bin/jython2.7
if [[ -x /usr/bin/jython2.7 ]]; then
- test_var PYTHON_SITEDIR jython2_7 /usr/share/jython-2.7/Lib/site-packages
+ test_get sitedir jython2.7 /usr/share/jython-2.7/Lib/site-packages
fi
test_var PYTHON_PKG_DEP jython2_7 '*dev-java/jython*:2.7'
test_var PYTHON_SCRIPTDIR jython2_7 /usr/lib/python-exec/jython2.7
@@ -112,7 +125,7 @@ test_var PYTHON_SCRIPTDIR jython2_7 \
/usr/lib/python-exec/jython2.7 test_var EPYTHON pypy pypy
test_var PYTHON pypy /usr/bin/pypy
if [[ -x /usr/bin/pypy ]]; then
- test_var PYTHON_SITEDIR pypy "/usr/lib*/pypy2.7/site-packages"
+ test_get sitedir pypy "/usr/lib*/pypy2.7/site-packages"
test_var PYTHON_INCLUDEDIR pypy "/usr/lib*/pypy2.7/include"
fi
test_var PYTHON_PKG_DEP pypy '*dev-python/pypy*:0='
@@ -121,7 +134,7 @@ test_var PYTHON_SCRIPTDIR pypy /usr/lib/python-exec/pypy
test_var EPYTHON pypy3 pypy3
test_var PYTHON pypy3 /usr/bin/pypy3
if [[ -x /usr/bin/pypy3 ]]; then
- test_var PYTHON_SITEDIR pypy3 "/usr/lib*/pypy3.?/site-packages"
+ test_get sitedir pypy3 "/usr/lib*/pypy3.?/site-packages"
test_var PYTHON_INCLUDEDIR pypy3 "/usr/lib*/pypy3.?/include"
fi
test_var PYTHON_PKG_DEP pypy3 '*dev-python/pypy3*:0='
--
2.25.1
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic