1 |
Obtain the Python site-packages directory path using |
2 |
the distutils.sysconfig module, rather than hardcoding it. |
3 |
--- |
4 |
eclass/python-utils-r1.eclass | 16 +++++----------- |
5 |
eclass/tests/python-utils-r1.sh | 12 +++++++----- |
6 |
2 files changed, 12 insertions(+), 16 deletions(-) |
7 |
|
8 |
diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass |
9 |
index ec85d8a..e8de6b9 100644 |
10 |
--- a/eclass/python-utils-r1.eclass |
11 |
+++ b/eclass/python-utils-r1.eclass |
12 |
@@ -126,6 +126,7 @@ _python_impl_supported() { |
13 |
# The path to Python site-packages directory. |
14 |
# |
15 |
# Set and exported on request using python_export(). |
16 |
+# Requires a proper build-time dependency on the Python implementation. |
17 |
# |
18 |
# Example value: |
19 |
# @CODE |
20 |
@@ -267,17 +268,10 @@ python_export() { |
21 |
debug-print "${FUNCNAME}: PYTHON = ${PYTHON}" |
22 |
;; |
23 |
PYTHON_SITEDIR) |
24 |
- local dir |
25 |
- case "${impl}" in |
26 |
- python*|pypy|pypy3) |
27 |
- dir=/usr/$(get_libdir)/${impl} |
28 |
- ;; |
29 |
- jython*) |
30 |
- dir=/usr/share/${impl/n/n-}/Lib |
31 |
- ;; |
32 |
- esac |
33 |
- |
34 |
- export PYTHON_SITEDIR=${EPREFIX}${dir}/site-packages |
35 |
+ # sysconfig can't be used because: |
36 |
+ # 1) pypy doesn't give site-packages but stdlib |
37 |
+ # 2) jython gives paths with wrong case |
38 |
+ export PYTHON_SITEDIR=$("${PYTHON}" -c 'import distutils.sysconfig; print(distutils.sysconfig.get_python_lib())') |
39 |
debug-print "${FUNCNAME}: PYTHON_SITEDIR = ${PYTHON_SITEDIR}" |
40 |
;; |
41 |
PYTHON_INCLUDEDIR) |
42 |
diff --git a/eclass/tests/python-utils-r1.sh b/eclass/tests/python-utils-r1.sh |
43 |
index e54550d..457756d 100755 |
44 |
--- a/eclass/tests/python-utils-r1.sh |
45 |
+++ b/eclass/tests/python-utils-r1.sh |
46 |
@@ -63,8 +63,8 @@ inherit python-utils-r1 |
47 |
|
48 |
test_var EPYTHON python2_7 python2.7 |
49 |
test_var PYTHON python2_7 /usr/bin/python2.7 |
50 |
-test_var PYTHON_SITEDIR python2_7 /usr/lib/python2.7/site-packages |
51 |
if [[ -x /usr/bin/python2.7 ]]; then |
52 |
+ test_var PYTHON_SITEDIR python2_7 "/usr/lib*/python2.7/site-packages" |
53 |
test_var PYTHON_INCLUDEDIR python2_7 /usr/include/python2.7 |
54 |
test_var PYTHON_LIBPATH python2_7 "/usr/lib*/libpython2.7$(get_libname)" |
55 |
fi |
56 |
@@ -73,9 +73,9 @@ test_var PYTHON_SCRIPTDIR python2_7 /usr/lib/python-exec/python2.7 |
57 |
|
58 |
test_var EPYTHON python3_4 python3.4 |
59 |
test_var PYTHON python3_4 /usr/bin/python3.4 |
60 |
-test_var PYTHON_SITEDIR python3_4 /usr/lib/python3.4/site-packages |
61 |
if [[ -x /usr/bin/python3.4 ]]; then |
62 |
abiflags=$(/usr/bin/python3.4 -c 'import sysconfig; print(sysconfig.get_config_var("ABIFLAGS"))') |
63 |
+ test_var PYTHON_SITEDIR python3_4 "/usr/lib*/python3.4/site-packages" |
64 |
test_var PYTHON_INCLUDEDIR python3_4 "/usr/include/python3.4${abiflags}" |
65 |
test_var PYTHON_LIBPATH python3_4 "/usr/lib*/libpython3.4${abiflags}$(get_libname)" |
66 |
fi |
67 |
@@ -84,14 +84,16 @@ test_var PYTHON_SCRIPTDIR python3_4 /usr/lib/python-exec/python3.4 |
68 |
|
69 |
test_var EPYTHON jython2_7 jython2.7 |
70 |
test_var PYTHON jython2_7 /usr/bin/jython2.7 |
71 |
-test_var PYTHON_SITEDIR jython2_7 /usr/share/jython-2.7/Lib/site-packages |
72 |
+if [[ -x /usr/bin/jython2.7 ]]; then |
73 |
+ test_var PYTHON_SITEDIR jython2_7 /usr/share/jython-2.7/Lib/site-packages |
74 |
+fi |
75 |
test_var PYTHON_PKG_DEP jython2_7 '*dev-java/jython*:2.7' |
76 |
test_var PYTHON_SCRIPTDIR jython2_7 /usr/lib/python-exec/jython2.7 |
77 |
|
78 |
test_var EPYTHON pypy pypy |
79 |
test_var PYTHON pypy /usr/bin/pypy |
80 |
-test_var PYTHON_SITEDIR pypy /usr/lib/pypy/site-packages |
81 |
if [[ -x /usr/bin/pypy ]]; then |
82 |
+ test_var PYTHON_SITEDIR pypy "/usr/lib*/pypy/site-packages" |
83 |
test_var PYTHON_INCLUDEDIR pypy "/usr/lib*/pypy/include" |
84 |
fi |
85 |
test_var PYTHON_PKG_DEP pypy '*virtual/pypy*:0=' |
86 |
@@ -99,8 +101,8 @@ test_var PYTHON_SCRIPTDIR pypy /usr/lib/python-exec/pypy |
87 |
|
88 |
test_var EPYTHON pypy3 pypy3 |
89 |
test_var PYTHON pypy3 /usr/bin/pypy3 |
90 |
-test_var PYTHON_SITEDIR pypy3 /usr/lib/pypy3/site-packages |
91 |
if [[ -x /usr/bin/pypy3 ]]; then |
92 |
+ test_var PYTHON_SITEDIR pypy3 "/usr/lib*/pypy3/site-packages" |
93 |
test_var PYTHON_INCLUDEDIR pypy3 /usr/lib/pypy3/include |
94 |
fi |
95 |
test_var PYTHON_PKG_DEP pypy3 '*virtual/pypy3*:0=' |
96 |
-- |
97 |
2.6.3 |