* [gentoo-dev] [PATCHES] python-utils-r1.eclass: Getter cleanup & ABIFLAGS preparation
@ 2015-11-08 9:35 Michał Górny
2015-11-08 9:35 ` [gentoo-dev] [PATCH 1/7] python-utils-r1.eclass: Switch tests to use python3.4 Michał Górny
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: Michał Górny @ 2015-11-08 9:35 UTC (permalink / raw
To: gentoo-dev; +Cc: python
Hello, everyone.
As you probably don't know, Justin lately noticed that we're carrying
some ugly hacks in Python 3.2+ where we diverge from upstream and break
binary compatibility for the sake of 'aesthetics'. While we're not yet
ready to kill them completely (the current work being kept
in python-soabi-cleanup branch), here's a batch of patches that clean up
python-utils-r1 getters and future-proof them for restoring ABIFLAGS.
In order:
1. updates tests to use py3.4 rather than py3.3,
2. prepares python_export() for spawning python,
3. gets includedir from python,
4. gets library path from python,
5. gets site-packages path from python,
6. adds API to get python-config path,
7. updates python_wrapper_setup() appropriately.
Summarizing, when the changes are done, the eclass is going to hardcode
less variables and call Python more often. Implications for ebuilds:
a. calling the relevant getters will require build-time dependency on
Python. Not that it really made sense without it -- why would you get
library path or include directory if you're not going to link or compile
against Python? Or why would you get sitedir if you're not going to
install modules (=> byte-compile them)?
b. ${PYTHON}-config hacks need to replaced by
$(python_get_PYTHON_CONFIG). Direct python-config calls are still fine
(wrapped by the eclass). The GNOME ebuilds which used the former syntax
directly are already fixed in the branch.
c. The getters will get a little slower. However, that shouldn't be
really important since they are forbidden during metadata regen, and in
ebuild runs we can expect the relevant Python version to be spawned
anyway (=> hot cache).
^ permalink raw reply [flat|nested] 10+ messages in thread
* [gentoo-dev] [PATCH 1/7] python-utils-r1.eclass: Switch tests to use python3.4
2015-11-08 9:35 [gentoo-dev] [PATCHES] python-utils-r1.eclass: Getter cleanup & ABIFLAGS preparation Michał Górny
@ 2015-11-08 9:35 ` Michał Górny
2015-11-08 9:35 ` [gentoo-dev] [PATCH 2/7] python-utils-r1.eclass: set PYTHON locally in python_export() Michał Górny
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Michał Górny @ 2015-11-08 9:35 UTC (permalink / raw
To: gentoo-dev; +Cc: python, Michał Górny
Use Python 3.4 during tests since Python 3.3 is now deprecated and is
less likely to be installed on user's systems and some tests will
require Python installed.
---
eclass/tests/python-utils-r1.sh | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/eclass/tests/python-utils-r1.sh b/eclass/tests/python-utils-r1.sh
index e49636a..bd05e9e 100755
--- a/eclass/tests/python-utils-r1.sh
+++ b/eclass/tests/python-utils-r1.sh
@@ -69,13 +69,13 @@ 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
-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
-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
+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
+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
test_var EPYTHON jython2_7 jython2.7
test_var PYTHON jython2_7 /usr/bin/jython2.7
--
2.6.3
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [gentoo-dev] [PATCH 2/7] python-utils-r1.eclass: set PYTHON locally in python_export()
2015-11-08 9:35 [gentoo-dev] [PATCHES] python-utils-r1.eclass: Getter cleanup & ABIFLAGS preparation Michał Górny
2015-11-08 9:35 ` [gentoo-dev] [PATCH 1/7] python-utils-r1.eclass: Switch tests to use python3.4 Michał Górny
@ 2015-11-08 9:35 ` Michał Górny
2015-11-08 9:35 ` [gentoo-dev] [PATCH 3/7] python-utils-r1.eclass: Obtain include directory from the interpreter Michał Górny
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Michał Górny @ 2015-11-08 9:35 UTC (permalink / raw
To: gentoo-dev; +Cc: python, Michał Górny
Ensure that PYTHON is always set inside python_export() for convenience.
If it wasn't requested for explicit export, make it a local variable.
---
eclass/python-utils-r1.eclass | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index a80bdf4..69166cf 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -248,6 +248,12 @@ python_export() {
esac
debug-print "${FUNCNAME}: implementation: ${impl}"
+ # make sure it doesn't leave our function unless desired
+ if ! has PYTHON "${@}"; then
+ local PYTHON
+ fi
+ export PYTHON=${EPREFIX}/usr/bin/${impl}
+
for var; do
case "${var}" in
EPYTHON)
@@ -255,7 +261,7 @@ python_export() {
debug-print "${FUNCNAME}: EPYTHON = ${EPYTHON}"
;;
PYTHON)
- export PYTHON=${EPREFIX}/usr/bin/${impl}
+ # already exported above
debug-print "${FUNCNAME}: PYTHON = ${PYTHON}"
;;
PYTHON_SITEDIR)
--
2.6.3
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [gentoo-dev] [PATCH 3/7] python-utils-r1.eclass: Obtain include directory from the interpreter
2015-11-08 9:35 [gentoo-dev] [PATCHES] python-utils-r1.eclass: Getter cleanup & ABIFLAGS preparation Michał Górny
2015-11-08 9:35 ` [gentoo-dev] [PATCH 1/7] python-utils-r1.eclass: Switch tests to use python3.4 Michał Górny
2015-11-08 9:35 ` [gentoo-dev] [PATCH 2/7] python-utils-r1.eclass: set PYTHON locally in python_export() Michał Górny
@ 2015-11-08 9:35 ` Michał Górny
2015-11-08 9:35 ` [gentoo-dev] [PATCH 4/7] python-utils-r1.eclass: Obtain library path " Michał Górny
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Michał Górny @ 2015-11-08 9:35 UTC (permalink / raw
To: gentoo-dev; +Cc: python, Michał Górny
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
--
2.6.3
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [gentoo-dev] [PATCH 4/7] python-utils-r1.eclass: Obtain library path from the interpreter
2015-11-08 9:35 [gentoo-dev] [PATCHES] python-utils-r1.eclass: Getter cleanup & ABIFLAGS preparation Michał Górny
` (2 preceding siblings ...)
2015-11-08 9:35 ` [gentoo-dev] [PATCH 3/7] python-utils-r1.eclass: Obtain include directory from the interpreter Michał Górny
@ 2015-11-08 9:35 ` Michał Górny
2015-11-08 9:35 ` [gentoo-dev] [PATCH 5/7] python-utils-r1.eclass: Obtain PYTHON_SITEDIR " Michał Górny
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Michał Górny @ 2015-11-08 9:35 UTC (permalink / raw
To: gentoo-dev; +Cc: python, Michał Górny
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
--
2.6.3
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [gentoo-dev] [PATCH 5/7] python-utils-r1.eclass: Obtain PYTHON_SITEDIR from the interpreter
2015-11-08 9:35 [gentoo-dev] [PATCHES] python-utils-r1.eclass: Getter cleanup & ABIFLAGS preparation Michał Górny
` (3 preceding siblings ...)
2015-11-08 9:35 ` [gentoo-dev] [PATCH 4/7] python-utils-r1.eclass: Obtain library path " Michał Górny
@ 2015-11-08 9:35 ` Michał Górny
2015-11-08 9:35 ` [gentoo-dev] [PATCH 6/7] python-utils-r1.eclass: Support getting PYTHON_CONFIG path Michał Górny
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Michał Górny @ 2015-11-08 9:35 UTC (permalink / raw
To: gentoo-dev; +Cc: python, Michał Górny
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='
--
2.6.3
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [gentoo-dev] [PATCH 6/7] python-utils-r1.eclass: Support getting PYTHON_CONFIG path
2015-11-08 9:35 [gentoo-dev] [PATCHES] python-utils-r1.eclass: Getter cleanup & ABIFLAGS preparation Michał Górny
` (4 preceding siblings ...)
2015-11-08 9:35 ` [gentoo-dev] [PATCH 5/7] python-utils-r1.eclass: Obtain PYTHON_SITEDIR " Michał Górny
@ 2015-11-08 9:35 ` Michał Górny
2015-11-08 9:35 ` [gentoo-dev] [PATCH 7/7] python-utils-r1.eclass: Reuse PYTHON_CONFIG in python_wrapper_setup() Michał Górny
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Michał Górny @ 2015-11-08 9:35 UTC (permalink / raw
To: gentoo-dev; +Cc: python, Michał Górny
---
eclass/python-utils-r1.eclass | 47 +++++++++++++++++++++++++++++++++++++++++
eclass/tests/python-utils-r1.sh | 2 ++
2 files changed, 49 insertions(+)
diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index e8de6b9..68926ab 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -190,6 +190,20 @@ _python_impl_supported() {
# -lpython2.7
# @CODE
+# @ECLASS-VARIABLE: PYTHON_CONFIG
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# Path to the python-config executable.
+#
+# Set and exported on request using python_export().
+# Valid only for CPython. Requires a proper build-time dependency
+# on the Python implementation and on pkg-config.
+#
+# Example value:
+# @CODE
+# /usr/bin/python2.7-config
+# @CODE
+
# @ECLASS-VARIABLE: PYTHON_PKG_DEP
# @DEFAULT_UNSET
# @DESCRIPTION:
@@ -323,6 +337,22 @@ python_export() {
export PYTHON_LIBS=${val}
debug-print "${FUNCNAME}: PYTHON_LIBS = ${PYTHON_LIBS}"
;;
+ PYTHON_CONFIG)
+ local flags val
+
+ case "${impl}" in
+ python*)
+ flags=$("${PYTHON}" -c 'import sysconfig; print(sysconfig.get_config_var("ABIFLAGS") or "")')
+ val=${PYTHON}${flags}-config
+ ;;
+ *)
+ die "${impl}: obtaining ${var} not supported"
+ ;;
+ esac
+
+ export PYTHON_CONFIG=${val}
+ debug-print "${FUNCNAME}: PYTHON_CONFIG = ${PYTHON_CONFIG}"
+ ;;
PYTHON_PKG_DEP)
local d
case ${impl} in
@@ -443,6 +473,23 @@ python_get_LIBS() {
echo "${PYTHON_LIBS}"
}
+# @FUNCTION: python_get_PYTHON_CONFIG
+# @USAGE: [<impl>]
+# @DESCRIPTION:
+# Obtain and print the PYTHON_CONFIG location for the given
+# implementation. If no implementation is provided, ${EPYTHON} will be
+# used.
+#
+# Please note that this function can be used with CPython only.
+# It requires Python installed, and therefore proper build-time
+# dependencies need be added to the ebuild.
+python_get_PYTHON_CONFIG() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ python_export "${@}" PYTHON_CONFIG
+ echo "${PYTHON_CONFIG}"
+}
+
# @FUNCTION: python_get_scriptdir
# @USAGE: [<impl>]
# @DESCRIPTION:
diff --git a/eclass/tests/python-utils-r1.sh b/eclass/tests/python-utils-r1.sh
index 457756d..b683c51 100755
--- a/eclass/tests/python-utils-r1.sh
+++ b/eclass/tests/python-utils-r1.sh
@@ -67,6 +67,7 @@ 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)"
+ test_var PYTHON_CONFIG python2_7 /usr/bin/python2.7-config
fi
test_var PYTHON_PKG_DEP python2_7 '*dev-lang/python*:2.7'
test_var PYTHON_SCRIPTDIR python2_7 /usr/lib/python-exec/python2.7
@@ -78,6 +79,7 @@ if [[ -x /usr/bin/python3.4 ]]; then
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)"
+ test_var PYTHON_CONFIG python3_4 "/usr/bin/python3.4${abiflags}-config"
fi
test_var PYTHON_PKG_DEP python3_4 '*dev-lang/python*:3.4'
test_var PYTHON_SCRIPTDIR python3_4 /usr/lib/python-exec/python3.4
--
2.6.3
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [gentoo-dev] [PATCH 7/7] python-utils-r1.eclass: Reuse PYTHON_CONFIG in python_wrapper_setup()
2015-11-08 9:35 [gentoo-dev] [PATCHES] python-utils-r1.eclass: Getter cleanup & ABIFLAGS preparation Michał Górny
` (5 preceding siblings ...)
2015-11-08 9:35 ` [gentoo-dev] [PATCH 6/7] python-utils-r1.eclass: Support getting PYTHON_CONFIG path Michał Górny
@ 2015-11-08 9:35 ` Michał Górny
2015-11-08 18:28 ` [gentoo-dev] Re: [PATCHES] python-utils-r1.eclass: Getter cleanup & ABIFLAGS preparation Mike Gilbert
2015-11-11 10:28 ` [gentoo-dev] " Michał Górny
8 siblings, 0 replies; 10+ messages in thread
From: Michał Górny @ 2015-11-08 9:35 UTC (permalink / raw
To: gentoo-dev; +Cc: python, Michał Górny
---
eclass/python-utils-r1.eclass | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index 68926ab..33cee1b 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -877,8 +877,8 @@ python_wrapper_setup() {
rm -f "${workdir}"/bin/2to3 || die
rm -f "${workdir}"/pkgconfig/python{,2,3}.pc || die
- local EPYTHON PYTHON
- python_export "${impl}" EPYTHON PYTHON
+ local EPYTHON PYTHON PYTHON_CONFIG
+ python_export "${impl}" EPYTHON PYTHON PYTHON_CONFIG
local pyver pyother
if python_is_python3; then
@@ -906,7 +906,7 @@ python_wrapper_setup() {
if [[ ${EPYTHON} == python* ]]; then
cat > "${workdir}/bin/python-config" <<-_EOF_
#!/bin/sh
- exec "${PYTHON}-config" "\${@}"
+ exec "${PYTHON_CONFIG}" "\${@}"
_EOF_
cp "${workdir}/bin/python-config" \
"${workdir}/bin/python${pyver}-config" || die
--
2.6.3
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [gentoo-dev] Re: [PATCHES] python-utils-r1.eclass: Getter cleanup & ABIFLAGS preparation
2015-11-08 9:35 [gentoo-dev] [PATCHES] python-utils-r1.eclass: Getter cleanup & ABIFLAGS preparation Michał Górny
` (6 preceding siblings ...)
2015-11-08 9:35 ` [gentoo-dev] [PATCH 7/7] python-utils-r1.eclass: Reuse PYTHON_CONFIG in python_wrapper_setup() Michał Górny
@ 2015-11-08 18:28 ` Mike Gilbert
2015-11-11 10:28 ` [gentoo-dev] " Michał Górny
8 siblings, 0 replies; 10+ messages in thread
From: Mike Gilbert @ 2015-11-08 18:28 UTC (permalink / raw
To: Michał Górny; +Cc: Gentoo Dev, Gentoo Python Project
On Sun, Nov 8, 2015 at 4:35 AM, Michał Górny <mgorny@gentoo.org> wrote:
> Hello, everyone.
>
> As you probably don't know, Justin lately noticed that we're carrying
> some ugly hacks in Python 3.2+ where we diverge from upstream and break
> binary compatibility for the sake of 'aesthetics'. While we're not yet
> ready to kill them completely (the current work being kept
> in python-soabi-cleanup branch), here's a batch of patches that clean up
> python-utils-r1 getters and future-proof them for restoring ABIFLAGS.
>
> In order:
>
> 1. updates tests to use py3.4 rather than py3.3,
> 2. prepares python_export() for spawning python,
> 3. gets includedir from python,
> 4. gets library path from python,
> 5. gets site-packages path from python,
> 6. adds API to get python-config path,
> 7. updates python_wrapper_setup() appropriately.
>
> Summarizing, when the changes are done, the eclass is going to hardcode
> less variables and call Python more often. Implications for ebuilds:
>
> a. calling the relevant getters will require build-time dependency on
> Python. Not that it really made sense without it -- why would you get
> library path or include directory if you're not going to link or compile
> against Python? Or why would you get sitedir if you're not going to
> install modules (=> byte-compile them)?
>
> b. ${PYTHON}-config hacks need to replaced by
> $(python_get_PYTHON_CONFIG). Direct python-config calls are still fine
> (wrapped by the eclass). The GNOME ebuilds which used the former syntax
> directly are already fixed in the branch.
>
> c. The getters will get a little slower. However, that shouldn't be
> really important since they are forbidden during metadata regen, and in
> ebuild runs we can expect the relevant Python version to be spawned
> anyway (=> hot cache).
>
This series looks good to me. Thanks for the work.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [gentoo-dev] [PATCHES] python-utils-r1.eclass: Getter cleanup & ABIFLAGS preparation
2015-11-08 9:35 [gentoo-dev] [PATCHES] python-utils-r1.eclass: Getter cleanup & ABIFLAGS preparation Michał Górny
` (7 preceding siblings ...)
2015-11-08 18:28 ` [gentoo-dev] Re: [PATCHES] python-utils-r1.eclass: Getter cleanup & ABIFLAGS preparation Mike Gilbert
@ 2015-11-11 10:28 ` Michał Górny
8 siblings, 0 replies; 10+ messages in thread
From: Michał Górny @ 2015-11-11 10:28 UTC (permalink / raw
To: gentoo-dev; +Cc: python
[-- Attachment #1: Type: text/plain, Size: 625 bytes --]
On Sun, 8 Nov 2015 10:35:04 +0100
Michał Górny <mgorny@gentoo.org> wrote:
> Hello, everyone.
>
> As you probably don't know, Justin lately noticed that we're carrying
> some ugly hacks in Python 3.2+ where we diverge from upstream and break
> binary compatibility for the sake of 'aesthetics'. While we're not yet
> ready to kill them completely (the current work being kept
> in python-soabi-cleanup branch), here's a batch of patches that clean up
> python-utils-r1 getters and future-proof them for restoring ABIFLAGS.
Merged now.
--
Best regards,
Michał Górny
<http://dev.gentoo.org/~mgorny/>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 949 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2015-11-11 10:28 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-08 9:35 [gentoo-dev] [PATCHES] python-utils-r1.eclass: Getter cleanup & ABIFLAGS preparation Michał Górny
2015-11-08 9:35 ` [gentoo-dev] [PATCH 1/7] python-utils-r1.eclass: Switch tests to use python3.4 Michał Górny
2015-11-08 9:35 ` [gentoo-dev] [PATCH 2/7] python-utils-r1.eclass: set PYTHON locally in python_export() Michał Górny
2015-11-08 9:35 ` [gentoo-dev] [PATCH 3/7] python-utils-r1.eclass: Obtain include directory from the interpreter Michał Górny
2015-11-08 9:35 ` [gentoo-dev] [PATCH 4/7] python-utils-r1.eclass: Obtain library path " Michał Górny
2015-11-08 9:35 ` [gentoo-dev] [PATCH 5/7] python-utils-r1.eclass: Obtain PYTHON_SITEDIR " Michał Górny
2015-11-08 9:35 ` [gentoo-dev] [PATCH 6/7] python-utils-r1.eclass: Support getting PYTHON_CONFIG path Michał Górny
2015-11-08 9:35 ` [gentoo-dev] [PATCH 7/7] python-utils-r1.eclass: Reuse PYTHON_CONFIG in python_wrapper_setup() Michał Górny
2015-11-08 18:28 ` [gentoo-dev] Re: [PATCHES] python-utils-r1.eclass: Getter cleanup & ABIFLAGS preparation Mike Gilbert
2015-11-11 10:28 ` [gentoo-dev] " 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