public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] repo/gentoo:python-soabi-cleanup commit in: eclass/tests/, eclass/
@ 2015-11-07 19:44 Michał Górny
  0 siblings, 0 replies; 8+ messages in thread
From: Michał Górny @ 2015-11-07 19:44 UTC (permalink / raw
  To: gentoo-commits

commit:     02a9b1b92ea4542788acd190b0b31eced943f647
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sat Nov  7 19:30:24 2015 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sat Nov  7 19:40:39 2015 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=02a9b1b9

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

Obtain the Python site-packages directory path using the site module,
rather than hardcoding it. The sysconfig module can not be used here
since it does not produce useful output for neither PyPy, nor Jython.

 eclass/python-utils-r1.eclass   | 16 +++++-----------
 eclass/tests/python-utils-r1.sh | 12 +++++++-----
 2 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index b8d093a..a8fb253 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -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 site; print(site.getsitepackages()[0])')
 				debug-print "${FUNCNAME}: PYTHON_SITEDIR = ${PYTHON_SITEDIR}"
 				;;
 			PYTHON_INCLUDEDIR)

diff --git a/eclass/tests/python-utils-r1.sh b/eclass/tests/python-utils-r1.sh
index 913cd7d..bc141f7 100755
--- a/eclass/tests/python-utils-r1.sh
+++ b/eclass/tests/python-utils-r1.sh
@@ -63,8 +63,8 @@ inherit python-utils-r1
 
 test_var EPYTHON python2_7 python2.7
 test_var PYTHON python2_7 /usr/bin/python2.7
-test_var PYTHON_SITEDIR python2_7 /usr/lib/python2.7/site-packages
 if [[ -x /usr/bin/python2.7 ]]; then
+	test_var PYTHON_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)"
 fi
@@ -73,8 +73,8 @@ test_var PYTHON_SCRIPTDIR python2_7 /usr/lib/python-exec/python2.7
 
 test_var EPYTHON python3_3 python3.3
 test_var PYTHON python3_3 /usr/bin/python3.3
-test_var PYTHON_SITEDIR python3_3 /usr/lib/python3.3/site-packages
 if [[ -x /usr/bin/python3.3 ]]; then
+	test_var PYTHON_SITEDIR python3_3 "/usr/lib*/python3.3/site-packages"
 	test_var PYTHON_INCLUDEDIR python3_3 "/usr/include/python3.3*"
 	test_var PYTHON_LIBPATH python3_3 "/usr/lib*/libpython3.3*$(get_libname)"
 fi
@@ -83,14 +83,16 @@ test_var PYTHON_SCRIPTDIR python3_3 /usr/lib/python-exec/python3.3
 
 test_var EPYTHON jython2_7 jython2.7
 test_var PYTHON jython2_7 /usr/bin/jython2.7
-test_var PYTHON_SITEDIR jython2_7 /usr/share/jython-2.7/Lib/site-packages
+if [[ -x /usr/bin/jython2.7 ]]; then
+	test_var PYTHON_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
 
 test_var EPYTHON pypy pypy
 test_var PYTHON pypy /usr/bin/pypy
-test_var PYTHON_SITEDIR pypy /usr/lib/pypy/site-packages
 if [[ -x /usr/bin/pypy ]]; then
+	test_var PYTHON_SITEDIR pypy "/usr/lib*/pypy/site-packages"
 	test_var PYTHON_INCLUDEDIR pypy "/usr/lib*/pypy/include"
 fi
 test_var PYTHON_PKG_DEP pypy '*virtual/pypy*:0='
@@ -98,8 +100,8 @@ test_var PYTHON_SCRIPTDIR pypy /usr/lib/python-exec/pypy
 
 test_var EPYTHON pypy3 pypy3
 test_var PYTHON pypy3 /usr/bin/pypy3
-test_var PYTHON_SITEDIR pypy3 /usr/lib/pypy3/site-packages
 if [[ -x /usr/bin/pypy3 ]]; then
+	test_var PYTHON_SITEDIR pypy3 "/usr/lib*/pypy3/site-packages"
 	test_var PYTHON_INCLUDEDIR pypy3 /usr/lib/pypy3/include
 fi
 test_var PYTHON_PKG_DEP pypy3 '*virtual/pypy3*:0='


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [gentoo-commits] repo/gentoo:python-soabi-cleanup commit in: eclass/tests/, eclass/
@ 2015-11-07 19:44 Michał Górny
  0 siblings, 0 replies; 8+ messages in thread
From: Michał Górny @ 2015-11-07 19:44 UTC (permalink / raw
  To: gentoo-commits

commit:     4c742184594c897e0f921cbe0041e0fad037268a
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Nov  6 22:21:37 2015 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sat Nov  7 18:34:36 2015 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=4c742184

python-utils-r1.eclass: Obtain include directory from the interpreter

Obtain the Python include directory using the sysconfig module of
the Python interpreter rather than hardcoding values for it. This makes
the code more maintainable, and clears the way for re-enabling ABIFLAGS
on new Python versions.

 eclass/python-utils-r1.eclass   | 21 +++++++--------------
 eclass/tests/python-utils-r1.sh | 16 ++++++++++++----
 2 files changed, 19 insertions(+), 18 deletions(-)

diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index 69166cf..467d83f 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -138,6 +138,7 @@ _python_impl_supported() {
 # The path to Python include directory.
 #
 # Set and exported on request using python_export().
+# Requires a proper build-time dependency on the Python implementation.
 #
 # Example value:
 # @CODE
@@ -279,21 +280,13 @@ python_export() {
 				debug-print "${FUNCNAME}: PYTHON_SITEDIR = ${PYTHON_SITEDIR}"
 				;;
 			PYTHON_INCLUDEDIR)
-				local dir
-				case "${impl}" in
-					python*)
-						dir=/usr/include/${impl}
-						;;
-					pypy|pypy3)
-						dir=/usr/$(get_libdir)/${impl}/include
-						;;
-					*)
-						die "${impl} lacks header files"
-						;;
-				esac
-
-				export PYTHON_INCLUDEDIR=${EPREFIX}${dir}
+				export PYTHON_INCLUDEDIR=$("${PYTHON}" -c 'import sysconfig; print(sysconfig.get_path("include"))')
 				debug-print "${FUNCNAME}: PYTHON_INCLUDEDIR = ${PYTHON_INCLUDEDIR}"
+
+				# Jython gives a non-existing directory
+				if [[ ! -d ${PYTHON_INCLUDEDIR} ]]; then
+					die "${impl} does not install any header files!"
+				fi
 				;;
 			PYTHON_LIBPATH)
 				local libname

diff --git a/eclass/tests/python-utils-r1.sh b/eclass/tests/python-utils-r1.sh
index e49636a..5bc3744 100755
--- a/eclass/tests/python-utils-r1.sh
+++ b/eclass/tests/python-utils-r1.sh
@@ -64,7 +64,9 @@ inherit python-utils-r1
 test_var EPYTHON python2_7 python2.7
 test_var PYTHON python2_7 /usr/bin/python2.7
 test_var PYTHON_SITEDIR python2_7 /usr/lib/python2.7/site-packages
-test_var PYTHON_INCLUDEDIR python2_7 /usr/include/python2.7
+if [[ -x /usr/bin/python2.7 ]]; then
+	test_var PYTHON_INCLUDEDIR python2_7 /usr/include/python2.7
+fi
 test_var PYTHON_LIBPATH python2_7 /usr/lib/libpython2.7$(get_libname)
 test_var PYTHON_PKG_DEP python2_7 '*dev-lang/python*:2.7'
 test_var PYTHON_SCRIPTDIR python2_7 /usr/lib/python-exec/python2.7
@@ -72,7 +74,9 @@ test_var PYTHON_SCRIPTDIR python2_7 /usr/lib/python-exec/python2.7
 test_var EPYTHON python3_3 python3.3
 test_var PYTHON python3_3 /usr/bin/python3.3
 test_var PYTHON_SITEDIR python3_3 /usr/lib/python3.3/site-packages
-test_var PYTHON_INCLUDEDIR python3_3 /usr/include/python3.3
+if [[ -x /usr/bin/python3.3 ]]; then
+	test_var PYTHON_INCLUDEDIR python3_3 "/usr/include/python3.3*"
+fi
 test_var PYTHON_LIBPATH python3_3 /usr/lib/libpython3.3$(get_libname)
 test_var PYTHON_PKG_DEP python3_3 '*dev-lang/python*:3.3'
 test_var PYTHON_SCRIPTDIR python3_3 /usr/lib/python-exec/python3.3
@@ -86,14 +90,18 @@ test_var PYTHON_SCRIPTDIR jython2_7 /usr/lib/python-exec/jython2.7
 test_var EPYTHON pypy pypy
 test_var PYTHON pypy /usr/bin/pypy
 test_var PYTHON_SITEDIR pypy /usr/lib/pypy/site-packages
-test_var PYTHON_INCLUDEDIR pypy /usr/lib/pypy/include
+if [[ -x /usr/bin/pypy ]]; then
+	test_var PYTHON_INCLUDEDIR pypy "/usr/lib*/pypy/include"
+fi
 test_var PYTHON_PKG_DEP pypy '*virtual/pypy*:0='
 test_var PYTHON_SCRIPTDIR pypy /usr/lib/python-exec/pypy
 
 test_var EPYTHON pypy3 pypy3
 test_var PYTHON pypy3 /usr/bin/pypy3
 test_var PYTHON_SITEDIR pypy3 /usr/lib/pypy3/site-packages
-test_var PYTHON_INCLUDEDIR pypy3 /usr/lib/pypy3/include
+if [[ -x /usr/bin/pypy3 ]]; then
+	test_var PYTHON_INCLUDEDIR pypy3 /usr/lib/pypy3/include
+fi
 test_var PYTHON_PKG_DEP pypy3 '*virtual/pypy3*:0='
 test_var PYTHON_SCRIPTDIR pypy3 /usr/lib/python-exec/pypy3
 


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [gentoo-commits] repo/gentoo:python-soabi-cleanup commit in: eclass/tests/, eclass/
@ 2015-11-07 19:58 Michał Górny
  0 siblings, 0 replies; 8+ messages in thread
From: Michał Górny @ 2015-11-07 19:58 UTC (permalink / raw
  To: gentoo-commits

commit:     df0b7168358d06dcdaf3eaf22341593e48af64b4
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sat Nov  7 19:30:24 2015 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sat Nov  7 19:56:48 2015 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=df0b7168

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

Obtain the Python site-packages directory path using the
distutils.config module, rather than hardcoding it.

 eclass/python-utils-r1.eclass   | 16 +++++-----------
 eclass/tests/python-utils-r1.sh | 12 +++++++-----
 2 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index ec85d8a..e8de6b9 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -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)

diff --git a/eclass/tests/python-utils-r1.sh b/eclass/tests/python-utils-r1.sh
index 913cd7d..bc141f7 100755
--- a/eclass/tests/python-utils-r1.sh
+++ b/eclass/tests/python-utils-r1.sh
@@ -63,8 +63,8 @@ inherit python-utils-r1
 
 test_var EPYTHON python2_7 python2.7
 test_var PYTHON python2_7 /usr/bin/python2.7
-test_var PYTHON_SITEDIR python2_7 /usr/lib/python2.7/site-packages
 if [[ -x /usr/bin/python2.7 ]]; then
+	test_var PYTHON_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)"
 fi
@@ -73,8 +73,8 @@ test_var PYTHON_SCRIPTDIR python2_7 /usr/lib/python-exec/python2.7
 
 test_var EPYTHON python3_3 python3.3
 test_var PYTHON python3_3 /usr/bin/python3.3
-test_var PYTHON_SITEDIR python3_3 /usr/lib/python3.3/site-packages
 if [[ -x /usr/bin/python3.3 ]]; then
+	test_var PYTHON_SITEDIR python3_3 "/usr/lib*/python3.3/site-packages"
 	test_var PYTHON_INCLUDEDIR python3_3 "/usr/include/python3.3*"
 	test_var PYTHON_LIBPATH python3_3 "/usr/lib*/libpython3.3*$(get_libname)"
 fi
@@ -83,14 +83,16 @@ test_var PYTHON_SCRIPTDIR python3_3 /usr/lib/python-exec/python3.3
 
 test_var EPYTHON jython2_7 jython2.7
 test_var PYTHON jython2_7 /usr/bin/jython2.7
-test_var PYTHON_SITEDIR jython2_7 /usr/share/jython-2.7/Lib/site-packages
+if [[ -x /usr/bin/jython2.7 ]]; then
+	test_var PYTHON_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
 
 test_var EPYTHON pypy pypy
 test_var PYTHON pypy /usr/bin/pypy
-test_var PYTHON_SITEDIR pypy /usr/lib/pypy/site-packages
 if [[ -x /usr/bin/pypy ]]; then
+	test_var PYTHON_SITEDIR pypy "/usr/lib*/pypy/site-packages"
 	test_var PYTHON_INCLUDEDIR pypy "/usr/lib*/pypy/include"
 fi
 test_var PYTHON_PKG_DEP pypy '*virtual/pypy*:0='
@@ -98,8 +100,8 @@ test_var PYTHON_SCRIPTDIR pypy /usr/lib/python-exec/pypy
 
 test_var EPYTHON pypy3 pypy3
 test_var PYTHON pypy3 /usr/bin/pypy3
-test_var PYTHON_SITEDIR pypy3 /usr/lib/pypy3/site-packages
 if [[ -x /usr/bin/pypy3 ]]; then
+	test_var PYTHON_SITEDIR pypy3 "/usr/lib*/pypy3/site-packages"
 	test_var PYTHON_INCLUDEDIR pypy3 /usr/lib/pypy3/include
 fi
 test_var PYTHON_PKG_DEP pypy3 '*virtual/pypy3*:0='


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [gentoo-commits] repo/gentoo:python-soabi-cleanup commit in: eclass/tests/, eclass/
@ 2015-11-07 20:00 Michał Górny
  0 siblings, 0 replies; 8+ messages in thread
From: Michał Górny @ 2015-11-07 20:00 UTC (permalink / raw
  To: gentoo-commits

commit:     f9003705f04a52f3cb0f47f3533fdb2de8dd166f
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sat Nov  7 19:30:24 2015 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sat Nov  7 19:59:52 2015 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f9003705

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.

 eclass/python-utils-r1.eclass   | 16 +++++-----------
 eclass/tests/python-utils-r1.sh | 12 +++++++-----
 2 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index ec85d8a..e8de6b9 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -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)

diff --git a/eclass/tests/python-utils-r1.sh b/eclass/tests/python-utils-r1.sh
index 913cd7d..bc141f7 100755
--- a/eclass/tests/python-utils-r1.sh
+++ b/eclass/tests/python-utils-r1.sh
@@ -63,8 +63,8 @@ inherit python-utils-r1
 
 test_var EPYTHON python2_7 python2.7
 test_var PYTHON python2_7 /usr/bin/python2.7
-test_var PYTHON_SITEDIR python2_7 /usr/lib/python2.7/site-packages
 if [[ -x /usr/bin/python2.7 ]]; then
+	test_var PYTHON_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)"
 fi
@@ -73,8 +73,8 @@ test_var PYTHON_SCRIPTDIR python2_7 /usr/lib/python-exec/python2.7
 
 test_var EPYTHON python3_3 python3.3
 test_var PYTHON python3_3 /usr/bin/python3.3
-test_var PYTHON_SITEDIR python3_3 /usr/lib/python3.3/site-packages
 if [[ -x /usr/bin/python3.3 ]]; then
+	test_var PYTHON_SITEDIR python3_3 "/usr/lib*/python3.3/site-packages"
 	test_var PYTHON_INCLUDEDIR python3_3 "/usr/include/python3.3*"
 	test_var PYTHON_LIBPATH python3_3 "/usr/lib*/libpython3.3*$(get_libname)"
 fi
@@ -83,14 +83,16 @@ test_var PYTHON_SCRIPTDIR python3_3 /usr/lib/python-exec/python3.3
 
 test_var EPYTHON jython2_7 jython2.7
 test_var PYTHON jython2_7 /usr/bin/jython2.7
-test_var PYTHON_SITEDIR jython2_7 /usr/share/jython-2.7/Lib/site-packages
+if [[ -x /usr/bin/jython2.7 ]]; then
+	test_var PYTHON_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
 
 test_var EPYTHON pypy pypy
 test_var PYTHON pypy /usr/bin/pypy
-test_var PYTHON_SITEDIR pypy /usr/lib/pypy/site-packages
 if [[ -x /usr/bin/pypy ]]; then
+	test_var PYTHON_SITEDIR pypy "/usr/lib*/pypy/site-packages"
 	test_var PYTHON_INCLUDEDIR pypy "/usr/lib*/pypy/include"
 fi
 test_var PYTHON_PKG_DEP pypy '*virtual/pypy*:0='
@@ -98,8 +100,8 @@ test_var PYTHON_SCRIPTDIR pypy /usr/lib/python-exec/pypy
 
 test_var EPYTHON pypy3 pypy3
 test_var PYTHON pypy3 /usr/bin/pypy3
-test_var PYTHON_SITEDIR pypy3 /usr/lib/pypy3/site-packages
 if [[ -x /usr/bin/pypy3 ]]; then
+	test_var PYTHON_SITEDIR pypy3 "/usr/lib*/pypy3/site-packages"
 	test_var PYTHON_INCLUDEDIR pypy3 /usr/lib/pypy3/include
 fi
 test_var PYTHON_PKG_DEP pypy3 '*virtual/pypy3*:0='


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [gentoo-commits] repo/gentoo:python-soabi-cleanup commit in: eclass/tests/, eclass/
@ 2015-11-07 20:00 Michał Górny
  0 siblings, 0 replies; 8+ messages in thread
From: Michał Górny @ 2015-11-07 20:00 UTC (permalink / raw
  To: gentoo-commits

commit:     4495c25f33d691ffb88e851b22b9977fb68d1a92
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Nov  6 22:41:52 2015 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sat Nov  7 19:59:49 2015 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=4495c25f

python-utils-r1.eclass: Obtain library path from the interpreter

Obtain library path as concatenation of LIBDIR and LDLIBRARY config
variables (from sysconfig module) rather than hardcoding it in the
eclass. This improves maintainability and fixes compatibility with
ABIFLAGS-enabled Python 3.3+.

 eclass/python-utils-r1.eclass   | 21 +++++++--------------
 eclass/tests/python-utils-r1.sh |  4 ++--
 2 files changed, 9 insertions(+), 16 deletions(-)

diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index a0274f6..ec85d8a 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -151,7 +151,8 @@ _python_impl_supported() {
 # The path to Python library.
 #
 # Set and exported on request using python_export().
-# Valid only for CPython.
+# Valid only for CPython. Requires a proper build-time dependency
+# on the Python implementation.
 #
 # Example value:
 # @CODE
@@ -289,20 +290,12 @@ python_export() {
 				fi
 				;;
 			PYTHON_LIBPATH)
-				local libname
-				case "${impl}" in
-					python*)
-						libname=lib${impl}
-						;;
-					*)
-						die "${impl} lacks a dynamic library"
-						;;
-				esac
-
-				local path=${EPREFIX}/usr/$(get_libdir)
-
-				export PYTHON_LIBPATH=${path}/${libname}$(get_libname)
+				export PYTHON_LIBPATH=$("${PYTHON}" -c 'import os.path, sysconfig; print(os.path.join(sysconfig.get_config_var("LIBDIR"), sysconfig.get_config_var("LDLIBRARY")) if sysconfig.get_config_var("LDLIBRARY") else "")')
 				debug-print "${FUNCNAME}: PYTHON_LIBPATH = ${PYTHON_LIBPATH}"
+
+				if [[ ! ${PYTHON_LIBPATH} ]]; then
+					die "${impl} lacks a (usable) dynamic library"
+				fi
 				;;
 			PYTHON_CFLAGS)
 				local val

diff --git a/eclass/tests/python-utils-r1.sh b/eclass/tests/python-utils-r1.sh
index 5bc3744..913cd7d 100755
--- a/eclass/tests/python-utils-r1.sh
+++ b/eclass/tests/python-utils-r1.sh
@@ -66,8 +66,8 @@ test_var PYTHON python2_7 /usr/bin/python2.7
 test_var PYTHON_SITEDIR python2_7 /usr/lib/python2.7/site-packages
 if [[ -x /usr/bin/python2.7 ]]; then
 	test_var PYTHON_INCLUDEDIR python2_7 /usr/include/python2.7
+	test_var PYTHON_LIBPATH python2_7 "/usr/lib*/libpython2.7$(get_libname)"
 fi
-test_var PYTHON_LIBPATH python2_7 /usr/lib/libpython2.7$(get_libname)
 test_var PYTHON_PKG_DEP python2_7 '*dev-lang/python*:2.7'
 test_var PYTHON_SCRIPTDIR python2_7 /usr/lib/python-exec/python2.7
 
@@ -76,8 +76,8 @@ test_var PYTHON python3_3 /usr/bin/python3.3
 test_var PYTHON_SITEDIR python3_3 /usr/lib/python3.3/site-packages
 if [[ -x /usr/bin/python3.3 ]]; then
 	test_var PYTHON_INCLUDEDIR python3_3 "/usr/include/python3.3*"
+	test_var PYTHON_LIBPATH python3_3 "/usr/lib*/libpython3.3*$(get_libname)"
 fi
-test_var PYTHON_LIBPATH python3_3 /usr/lib/libpython3.3$(get_libname)
 test_var PYTHON_PKG_DEP python3_3 '*dev-lang/python*:3.3'
 test_var PYTHON_SCRIPTDIR python3_3 /usr/lib/python-exec/python3.3
 


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [gentoo-commits] repo/gentoo:python-soabi-cleanup commit in: eclass/tests/, eclass/
@ 2015-11-08  8:42 Michał Górny
  0 siblings, 0 replies; 8+ messages in thread
From: Michał Górny @ 2015-11-08  8:42 UTC (permalink / raw
  To: gentoo-commits

commit:     37f1067316c4059554c6fde35c026e01e1d4d493
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Nov  6 22:21:37 2015 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sun Nov  8 08:40:43 2015 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=37f10673

python-utils-r1.eclass: Obtain include directory from the interpreter

Obtain the Python include directory using the distutils.sysconfig module
of the Python interpreter rather than hardcoding values for it. This
makes the code more maintainable, and clears the way for re-enabling
ABIFLAGS on new Python versions.

 eclass/python-utils-r1.eclass   | 21 +++++++--------------
 eclass/tests/python-utils-r1.sh | 17 +++++++++++++----
 2 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index 69166cf..a0274f6 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -138,6 +138,7 @@ _python_impl_supported() {
 # The path to Python include directory.
 #
 # Set and exported on request using python_export().
+# Requires a proper build-time dependency on the Python implementation.
 #
 # Example value:
 # @CODE
@@ -279,21 +280,13 @@ python_export() {
 				debug-print "${FUNCNAME}: PYTHON_SITEDIR = ${PYTHON_SITEDIR}"
 				;;
 			PYTHON_INCLUDEDIR)
-				local dir
-				case "${impl}" in
-					python*)
-						dir=/usr/include/${impl}
-						;;
-					pypy|pypy3)
-						dir=/usr/$(get_libdir)/${impl}/include
-						;;
-					*)
-						die "${impl} lacks header files"
-						;;
-				esac
-
-				export PYTHON_INCLUDEDIR=${EPREFIX}${dir}
+				export PYTHON_INCLUDEDIR=$("${PYTHON}" -c 'import distutils.sysconfig; print(distutils.sysconfig.get_python_inc())')
 				debug-print "${FUNCNAME}: PYTHON_INCLUDEDIR = ${PYTHON_INCLUDEDIR}"
+
+				# Jython gives a non-existing directory
+				if [[ ! -d ${PYTHON_INCLUDEDIR} ]]; then
+					die "${impl} does not install any header files!"
+				fi
 				;;
 			PYTHON_LIBPATH)
 				local libname

diff --git a/eclass/tests/python-utils-r1.sh b/eclass/tests/python-utils-r1.sh
index bd05e9e..dc6676b 100755
--- a/eclass/tests/python-utils-r1.sh
+++ b/eclass/tests/python-utils-r1.sh
@@ -64,7 +64,9 @@ inherit python-utils-r1
 test_var EPYTHON python2_7 python2.7
 test_var PYTHON python2_7 /usr/bin/python2.7
 test_var PYTHON_SITEDIR python2_7 /usr/lib/python2.7/site-packages
-test_var PYTHON_INCLUDEDIR python2_7 /usr/include/python2.7
+if [[ -x /usr/bin/python2.7 ]]; then
+	test_var PYTHON_INCLUDEDIR python2_7 /usr/include/python2.7
+fi
 test_var PYTHON_LIBPATH python2_7 /usr/lib/libpython2.7$(get_libname)
 test_var PYTHON_PKG_DEP python2_7 '*dev-lang/python*:2.7'
 test_var PYTHON_SCRIPTDIR python2_7 /usr/lib/python-exec/python2.7
@@ -72,7 +74,10 @@ test_var PYTHON_SCRIPTDIR python2_7 /usr/lib/python-exec/python2.7
 test_var EPYTHON python3_4 python3.4
 test_var PYTHON python3_4 /usr/bin/python3.4
 test_var PYTHON_SITEDIR python3_4 /usr/lib/python3.4/site-packages
-test_var PYTHON_INCLUDEDIR python3_4 /usr/include/python3.4
+if [[ -x /usr/bin/python3.4 ]]; then
+	abiflags=$(/usr/bin/python3.4 -c 'import sysconfig; print(sysconfig.get_config_var("ABIFLAGS"))')
+	test_var PYTHON_INCLUDEDIR python3_4 "/usr/include/python3.4${abiflags}"
+fi
 test_var PYTHON_LIBPATH python3_4 /usr/lib/libpython3.4$(get_libname)
 test_var PYTHON_PKG_DEP python3_4 '*dev-lang/python*:3.4'
 test_var PYTHON_SCRIPTDIR python3_4 /usr/lib/python-exec/python3.4
@@ -86,14 +91,18 @@ test_var PYTHON_SCRIPTDIR jython2_7 /usr/lib/python-exec/jython2.7
 test_var EPYTHON pypy pypy
 test_var PYTHON pypy /usr/bin/pypy
 test_var PYTHON_SITEDIR pypy /usr/lib/pypy/site-packages
-test_var PYTHON_INCLUDEDIR pypy /usr/lib/pypy/include
+if [[ -x /usr/bin/pypy ]]; then
+	test_var PYTHON_INCLUDEDIR pypy "/usr/lib*/pypy/include"
+fi
 test_var PYTHON_PKG_DEP pypy '*virtual/pypy*:0='
 test_var PYTHON_SCRIPTDIR pypy /usr/lib/python-exec/pypy
 
 test_var EPYTHON pypy3 pypy3
 test_var PYTHON pypy3 /usr/bin/pypy3
 test_var PYTHON_SITEDIR pypy3 /usr/lib/pypy3/site-packages
-test_var PYTHON_INCLUDEDIR pypy3 /usr/lib/pypy3/include
+if [[ -x /usr/bin/pypy3 ]]; then
+	test_var PYTHON_INCLUDEDIR pypy3 /usr/lib/pypy3/include
+fi
 test_var PYTHON_PKG_DEP pypy3 '*virtual/pypy3*:0='
 test_var PYTHON_SCRIPTDIR pypy3 /usr/lib/python-exec/pypy3
 


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [gentoo-commits] repo/gentoo:python-soabi-cleanup commit in: eclass/tests/, eclass/
@ 2015-11-08  8:42 Michał Górny
  0 siblings, 0 replies; 8+ messages in thread
From: Michał Górny @ 2015-11-08  8:42 UTC (permalink / raw
  To: gentoo-commits

commit:     1248bd1b81e953ca592ee70b614eb9e5787ea365
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sat Nov  7 19:30:24 2015 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sun Nov  8 08:41:50 2015 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1248bd1b

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.

 eclass/python-utils-r1.eclass   | 16 +++++-----------
 eclass/tests/python-utils-r1.sh | 12 +++++++-----
 2 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index ec85d8a..e8de6b9 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -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)

diff --git a/eclass/tests/python-utils-r1.sh b/eclass/tests/python-utils-r1.sh
index e54550d..457756d 100755
--- a/eclass/tests/python-utils-r1.sh
+++ b/eclass/tests/python-utils-r1.sh
@@ -63,8 +63,8 @@ inherit python-utils-r1
 
 test_var EPYTHON python2_7 python2.7
 test_var PYTHON python2_7 /usr/bin/python2.7
-test_var PYTHON_SITEDIR python2_7 /usr/lib/python2.7/site-packages
 if [[ -x /usr/bin/python2.7 ]]; then
+	test_var PYTHON_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)"
 fi
@@ -73,9 +73,9 @@ test_var PYTHON_SCRIPTDIR python2_7 /usr/lib/python-exec/python2.7
 
 test_var EPYTHON python3_4 python3.4
 test_var PYTHON python3_4 /usr/bin/python3.4
-test_var PYTHON_SITEDIR python3_4 /usr/lib/python3.4/site-packages
 if [[ -x /usr/bin/python3.4 ]]; then
 	abiflags=$(/usr/bin/python3.4 -c 'import sysconfig; print(sysconfig.get_config_var("ABIFLAGS"))')
+	test_var PYTHON_SITEDIR python3_4 "/usr/lib*/python3.4/site-packages"
 	test_var PYTHON_INCLUDEDIR python3_4 "/usr/include/python3.4${abiflags}"
 	test_var PYTHON_LIBPATH python3_4 "/usr/lib*/libpython3.4${abiflags}$(get_libname)"
 fi
@@ -84,14 +84,16 @@ test_var PYTHON_SCRIPTDIR python3_4 /usr/lib/python-exec/python3.4
 
 test_var EPYTHON jython2_7 jython2.7
 test_var PYTHON jython2_7 /usr/bin/jython2.7
-test_var PYTHON_SITEDIR jython2_7 /usr/share/jython-2.7/Lib/site-packages
+if [[ -x /usr/bin/jython2.7 ]]; then
+	test_var PYTHON_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
 
 test_var EPYTHON pypy pypy
 test_var PYTHON pypy /usr/bin/pypy
-test_var PYTHON_SITEDIR pypy /usr/lib/pypy/site-packages
 if [[ -x /usr/bin/pypy ]]; then
+	test_var PYTHON_SITEDIR pypy "/usr/lib*/pypy/site-packages"
 	test_var PYTHON_INCLUDEDIR pypy "/usr/lib*/pypy/include"
 fi
 test_var PYTHON_PKG_DEP pypy '*virtual/pypy*:0='
@@ -99,8 +101,8 @@ test_var PYTHON_SCRIPTDIR pypy /usr/lib/python-exec/pypy
 
 test_var EPYTHON pypy3 pypy3
 test_var PYTHON pypy3 /usr/bin/pypy3
-test_var PYTHON_SITEDIR pypy3 /usr/lib/pypy3/site-packages
 if [[ -x /usr/bin/pypy3 ]]; then
+	test_var PYTHON_SITEDIR pypy3 "/usr/lib*/pypy3/site-packages"
 	test_var PYTHON_INCLUDEDIR pypy3 /usr/lib/pypy3/include
 fi
 test_var PYTHON_PKG_DEP pypy3 '*virtual/pypy3*:0='


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [gentoo-commits] repo/gentoo:python-soabi-cleanup commit in: eclass/tests/, eclass/
@ 2015-11-08  8:42 Michał Górny
  0 siblings, 0 replies; 8+ messages in thread
From: Michał Górny @ 2015-11-08  8:42 UTC (permalink / raw
  To: gentoo-commits

commit:     8b5b817be61b8f851e5d37f97615223bf6b07082
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Nov  6 22:41:52 2015 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sun Nov  8 08:41:05 2015 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=8b5b817b

python-utils-r1.eclass: Obtain library path from the interpreter

Obtain library path as concatenation of LIBDIR and LDLIBRARY config
variables (from sysconfig module) rather than hardcoding it in the
eclass. This improves maintainability and fixes compatibility with
ABIFLAGS-enabled Python 3.3+.

 eclass/python-utils-r1.eclass   | 21 +++++++--------------
 eclass/tests/python-utils-r1.sh |  4 ++--
 2 files changed, 9 insertions(+), 16 deletions(-)

diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index a0274f6..ec85d8a 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -151,7 +151,8 @@ _python_impl_supported() {
 # The path to Python library.
 #
 # Set and exported on request using python_export().
-# Valid only for CPython.
+# Valid only for CPython. Requires a proper build-time dependency
+# on the Python implementation.
 #
 # Example value:
 # @CODE
@@ -289,20 +290,12 @@ python_export() {
 				fi
 				;;
 			PYTHON_LIBPATH)
-				local libname
-				case "${impl}" in
-					python*)
-						libname=lib${impl}
-						;;
-					*)
-						die "${impl} lacks a dynamic library"
-						;;
-				esac
-
-				local path=${EPREFIX}/usr/$(get_libdir)
-
-				export PYTHON_LIBPATH=${path}/${libname}$(get_libname)
+				export PYTHON_LIBPATH=$("${PYTHON}" -c 'import os.path, sysconfig; print(os.path.join(sysconfig.get_config_var("LIBDIR"), sysconfig.get_config_var("LDLIBRARY")) if sysconfig.get_config_var("LDLIBRARY") else "")')
 				debug-print "${FUNCNAME}: PYTHON_LIBPATH = ${PYTHON_LIBPATH}"
+
+				if [[ ! ${PYTHON_LIBPATH} ]]; then
+					die "${impl} lacks a (usable) dynamic library"
+				fi
 				;;
 			PYTHON_CFLAGS)
 				local val

diff --git a/eclass/tests/python-utils-r1.sh b/eclass/tests/python-utils-r1.sh
index dc6676b..e54550d 100755
--- a/eclass/tests/python-utils-r1.sh
+++ b/eclass/tests/python-utils-r1.sh
@@ -66,8 +66,8 @@ test_var PYTHON python2_7 /usr/bin/python2.7
 test_var PYTHON_SITEDIR python2_7 /usr/lib/python2.7/site-packages
 if [[ -x /usr/bin/python2.7 ]]; then
 	test_var PYTHON_INCLUDEDIR python2_7 /usr/include/python2.7
+	test_var PYTHON_LIBPATH python2_7 "/usr/lib*/libpython2.7$(get_libname)"
 fi
-test_var PYTHON_LIBPATH python2_7 /usr/lib/libpython2.7$(get_libname)
 test_var PYTHON_PKG_DEP python2_7 '*dev-lang/python*:2.7'
 test_var PYTHON_SCRIPTDIR python2_7 /usr/lib/python-exec/python2.7
 
@@ -77,8 +77,8 @@ test_var PYTHON_SITEDIR python3_4 /usr/lib/python3.4/site-packages
 if [[ -x /usr/bin/python3.4 ]]; then
 	abiflags=$(/usr/bin/python3.4 -c 'import sysconfig; print(sysconfig.get_config_var("ABIFLAGS"))')
 	test_var PYTHON_INCLUDEDIR python3_4 "/usr/include/python3.4${abiflags}"
+	test_var PYTHON_LIBPATH python3_4 "/usr/lib*/libpython3.4${abiflags}$(get_libname)"
 fi
-test_var PYTHON_LIBPATH python3_4 /usr/lib/libpython3.4$(get_libname)
 test_var PYTHON_PKG_DEP python3_4 '*dev-lang/python*:3.4'
 test_var PYTHON_SCRIPTDIR python3_4 /usr/lib/python-exec/python3.4
 


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-11-08  8:43 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-07 20:00 [gentoo-commits] repo/gentoo:python-soabi-cleanup commit in: eclass/tests/, eclass/ Michał Górny
  -- strict thread matches above, loose matches on Subject: below --
2015-11-08  8:42 Michał Górny
2015-11-08  8:42 Michał Górny
2015-11-08  8:42 Michał Górny
2015-11-07 20:00 Michał Górny
2015-11-07 19:58 Michał Górny
2015-11-07 19:44 Michał Górny
2015-11-07 19:44 Michał Górny

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox