public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-dev@lists.gentoo.org
Cc: python@gentoo.org, "Michał Górny" <mgorny@gentoo.org>
Subject: [gentoo-dev] [PATCH v2 11/20] python-utils-r2.eclass: Remove PYTHON_SITEDIR export
Date: Thu,  5 Mar 2020 16:10:15 +0100	[thread overview]
Message-ID: <20200305151024.125834-12-mgorny@gentoo.org> (raw)
In-Reply-To: <20200305151024.125834-1-mgorny@gentoo.org>

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 dab4a5b5c87e..4f9df6000e16 100644
--- a/eclass/python-utils-r2.eclass
+++ b/eclass/python-utils-r2.eclass
@@ -238,10 +238,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} "${@}"
 
@@ -275,15 +271,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
@@ -393,16 +380,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
@@ -752,7 +741,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
@@ -788,8 +777,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



  parent reply	other threads:[~2020-03-05 15:15 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-05 15:10 [gentoo-dev] [PATCH v2 00/20] python-r2 suite Michał Górny
2020-03-05 15:10 ` [gentoo-dev] [PATCH v2 01/20] eclass: Copy python-r1 suite to python-r2 Michał Górny
2020-03-05 15:10 ` [gentoo-dev] [PATCH v2 02/20] distutils-r2.eclass: Remove EXAMPLES Michał Górny
2020-03-05 15:10 ` [gentoo-dev] [PATCH v2 03/20] distutils-r2.eclass: Remove no-op subphase defaults Michał Górny
2020-03-05 15:10 ` [gentoo-dev] [PATCH v2 04/20] distutils-r2.eclass: Remove distutils.eclass checks Michał Górny
2020-03-05 15:10 ` [gentoo-dev] [PATCH v2 05/20] python-r2.eclass: Remove python_gen_usedep Michał Górny
2020-03-05 15:10 ` [gentoo-dev] [PATCH v2 06/20] python-utils-r2.eclass: Remove python.eclass checks Michał Górny
2020-03-05 15:10 ` [gentoo-dev] [PATCH v2 07/20] python-utils-r2.eclass: Mark python_wrapper_setup private Michał Górny
2020-03-05 15:10 ` [gentoo-dev] [PATCH v2 08/20] python-utils-r2.eclass: Mark python_is_installed private Michał Górny
2020-03-05 15:10 ` [gentoo-dev] [PATCH v2 09/20] python-utils-r2.eclass: Fix obsolete docs on python_export_best Michał Górny
2020-03-05 15:10 ` [gentoo-dev] [PATCH v2 10/20] python-utils-r2.eclass: Mark python_export private Michał Górny
2020-03-05 15:10 ` Michał Górny [this message]
2020-03-05 15:10 ` [gentoo-dev] [PATCH v2 12/20] python-utils-r2.eclass: Remove PYTHON_INCLUDEDIR export Michał Górny
2020-03-05 15:10 ` [gentoo-dev] [PATCH v2 13/20] python-utils-r2.eclass: Remove PYTHON_LIBPATH export Michał Górny
2020-03-05 15:10 ` [gentoo-dev] [PATCH v2 14/20] python-utils-r2.eclass: Remove PYTHON_CFLAGS export Michał Górny
2020-03-05 15:10 ` [gentoo-dev] [PATCH v2 15/20] python-utils-r2.eclass: Remove PYTHON_LIBS export Michał Górny
2020-03-05 15:10 ` [gentoo-dev] [PATCH v2 16/20] python-utils-r2.eclass: Remove PYTHON_CONFIG export Michał Górny
2020-03-05 15:10 ` [gentoo-dev] [PATCH v2 17/20] python-utils-r2.eclass: Remove PYTHON_SCRIPTDIR export Michał Górny
2020-03-05 15:10 ` [gentoo-dev] [PATCH v2 18/20] python-single-r2.eclass: PYTHON_MULTI_USEDEP → PYTHON_USEDEP Michał Górny
2020-03-05 15:10 ` [gentoo-dev] [PATCH v2 19/20] distutils-r2.eclass: Pass --skip-build to install Michał Górny
2020-03-05 15:10 ` [gentoo-dev] [PATCH v2 20/20] eclass: python-r2.eclass → python-multi-r2.eclass Michał Górny

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200305151024.125834-12-mgorny@gentoo.org \
    --to=mgorny@gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    --cc=python@gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox