1 |
Obtain library path as concatenation of LIBDIR and LDLIBRARY config |
2 |
variables (from sysconfig module) rather than hardcoding it in the |
3 |
eclass. This improves maintainability and fixes compatibility with |
4 |
ABIFLAGS-enabled Python 3.3+. |
5 |
--- |
6 |
eclass/python-utils-r1.eclass | 21 +++++++-------------- |
7 |
eclass/tests/python-utils-r1.sh | 4 ++-- |
8 |
2 files changed, 9 insertions(+), 16 deletions(-) |
9 |
|
10 |
diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass |
11 |
index a0274f6..ec85d8a 100644 |
12 |
--- a/eclass/python-utils-r1.eclass |
13 |
+++ b/eclass/python-utils-r1.eclass |
14 |
@@ -151,7 +151,8 @@ _python_impl_supported() { |
15 |
# The path to Python library. |
16 |
# |
17 |
# Set and exported on request using python_export(). |
18 |
-# Valid only for CPython. |
19 |
+# Valid only for CPython. Requires a proper build-time dependency |
20 |
+# on the Python implementation. |
21 |
# |
22 |
# Example value: |
23 |
# @CODE |
24 |
@@ -289,20 +290,12 @@ python_export() { |
25 |
fi |
26 |
;; |
27 |
PYTHON_LIBPATH) |
28 |
- local libname |
29 |
- case "${impl}" in |
30 |
- python*) |
31 |
- libname=lib${impl} |
32 |
- ;; |
33 |
- *) |
34 |
- die "${impl} lacks a dynamic library" |
35 |
- ;; |
36 |
- esac |
37 |
- |
38 |
- local path=${EPREFIX}/usr/$(get_libdir) |
39 |
- |
40 |
- export PYTHON_LIBPATH=${path}/${libname}$(get_libname) |
41 |
+ 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 "")') |
42 |
debug-print "${FUNCNAME}: PYTHON_LIBPATH = ${PYTHON_LIBPATH}" |
43 |
+ |
44 |
+ if [[ ! ${PYTHON_LIBPATH} ]]; then |
45 |
+ die "${impl} lacks a (usable) dynamic library" |
46 |
+ fi |
47 |
;; |
48 |
PYTHON_CFLAGS) |
49 |
local val |
50 |
diff --git a/eclass/tests/python-utils-r1.sh b/eclass/tests/python-utils-r1.sh |
51 |
index dc6676b..e54550d 100755 |
52 |
--- a/eclass/tests/python-utils-r1.sh |
53 |
+++ b/eclass/tests/python-utils-r1.sh |
54 |
@@ -66,8 +66,8 @@ test_var PYTHON python2_7 /usr/bin/python2.7 |
55 |
test_var PYTHON_SITEDIR python2_7 /usr/lib/python2.7/site-packages |
56 |
if [[ -x /usr/bin/python2.7 ]]; then |
57 |
test_var PYTHON_INCLUDEDIR python2_7 /usr/include/python2.7 |
58 |
+ test_var PYTHON_LIBPATH python2_7 "/usr/lib*/libpython2.7$(get_libname)" |
59 |
fi |
60 |
-test_var PYTHON_LIBPATH python2_7 /usr/lib/libpython2.7$(get_libname) |
61 |
test_var PYTHON_PKG_DEP python2_7 '*dev-lang/python*:2.7' |
62 |
test_var PYTHON_SCRIPTDIR python2_7 /usr/lib/python-exec/python2.7 |
63 |
|
64 |
@@ -77,8 +77,8 @@ test_var PYTHON_SITEDIR python3_4 /usr/lib/python3.4/site-packages |
65 |
if [[ -x /usr/bin/python3.4 ]]; then |
66 |
abiflags=$(/usr/bin/python3.4 -c 'import sysconfig; print(sysconfig.get_config_var("ABIFLAGS"))') |
67 |
test_var PYTHON_INCLUDEDIR python3_4 "/usr/include/python3.4${abiflags}" |
68 |
+ test_var PYTHON_LIBPATH python3_4 "/usr/lib*/libpython3.4${abiflags}$(get_libname)" |
69 |
fi |
70 |
-test_var PYTHON_LIBPATH python3_4 /usr/lib/libpython3.4$(get_libname) |
71 |
test_var PYTHON_PKG_DEP python3_4 '*dev-lang/python*:3.4' |
72 |
test_var PYTHON_SCRIPTDIR python3_4 /usr/lib/python-exec/python3.4 |
73 |
|
74 |
-- |
75 |
2.6.3 |