1 |
# $Id$ |
# $Id$ |
2 |
|
|
3 |
# needed for mbindir() |
# simulate the old behavior |
4 |
sminclude mtools |
if [[ -z ${MAGE_PYTHON_EXEC} ]] |
5 |
|
then |
6 |
|
MAGE_PYTHON_EXEC="python" |
7 |
|
|
8 |
|
SDEPEND="${SDEPEND} |
9 |
|
>= dev-lang/python-2.7" |
10 |
|
fi |
11 |
|
|
12 |
# get the major.minor current installed python version |
# get the major.minor current installed python version |
13 |
# -> ex 2.4 |
# -> ex 2.4 |
14 |
get_python_version() |
mget-python-version() |
15 |
{ |
{ |
16 |
# PYVER="$(python -V 2>&1 | cut -d' ' -f2 | cut -d. -f1-2)" |
local pyver |
17 |
PYVER=$(python -c "import sys ; print sys.version[:3]") |
# pyver="$(${MAGE_PYTHON_EXEC} -V 2>&1 | cut -d' ' -f2 | cut -d. -f1-2)" |
18 |
[[ -z ${PYVER} ]] && return 1 |
pyver=$(${MAGE_PYTHON_EXEC} -c "import sys ; print (sys.version[:3])") |
19 |
echo "${PYVER}" |
[[ -z ${pyver} ]] && return 1 |
20 |
|
echo "${pyver}" |
21 |
return 0 |
return 0 |
22 |
} |
} |
23 |
|
|
24 |
get_python_libdir() |
mget-python-libdir() |
25 |
{ |
{ |
26 |
local pylib |
local pylib |
27 |
pylib=$(python -c 'from distutils import sysconfig; print sysconfig.get_python_lib()') |
pylib=$(${MAGE_PYTHON_EXEC} -c 'from distutils import sysconfig; print (sysconfig.get_python_lib())') |
28 |
|
[[ -z ${pylib} ]] && return 1 |
29 |
echo "${pylib}" |
echo "${pylib}" |
30 |
return 0 |
return 0 |
31 |
} |
} |
32 |
|
|
33 |
|
mget-python-includedir() |
34 |
|
{ |
35 |
|
local pyinc |
36 |
|
pyinc=$(${MAGE_PYTHON_EXEC} -c 'from distutils import sysconfig; print (sysconfig.get_python_inc())') |
37 |
|
[[ -z ${pyinc} ]] && return 1 |
38 |
|
echo "${pyinc}" |
39 |
|
return 0 |
40 |
|
} |
41 |
|
|
42 |
|
# fallback functions to support old smage scripts, dropped in near future |
43 |
|
get_python_version() |
44 |
|
{ |
45 |
|
echo -e "${COLYELLOW}Warning: get_python_version() is depcrecated, please use mget-python-version() instead${COLDEFAULT}" >&2 |
46 |
|
mget-python-version |
47 |
|
} |
48 |
|
get_python_libdir() |
49 |
|
{ |
50 |
|
echo -e "${COLYELLOW}Warning: get_python_libdir() is depcrecated, please use mget-python-libdir() instead${COLDEFAULT}" >&2 |
51 |
|
mget-python-libdir |
52 |
|
} |
53 |
|
get_python_includedir() |
54 |
|
{ |
55 |
|
echo -e "${COLYELLOW}Warning: get_python_includedir() is depcrecated, please use mget-python-includedir() instead${COLDEFAULT}" >&2 |
56 |
|
mget-python-includedir |
57 |
|
} |
58 |
|
|
59 |
python_src_prepare() |
python_src_prepare() |
60 |
{ |
{ |
61 |
munpack ${SRCFILE} || die |
munpack ${SRCFILE} || die |
62 |
} |
} |
63 |
|
|
64 |
python_src_compile() |
python_docompile() |
65 |
{ |
{ |
|
cd ${SRCDIR} |
|
|
|
|
66 |
if [[ -e setup.py ]] |
if [[ -e setup.py ]] |
67 |
then |
then |
68 |
python setup.py build "$@" || die |
${MAGE_PYTHON_EXEC} setup.py build $@ || die |
69 |
elif [[ -e waf ]] |
elif [[ -e waf ]] |
70 |
then |
then |
71 |
python waf configure --prefix=/usr --libdir=/usr/$(mlibdir) "$@" || die |
${MAGE_PYTHON_EXEC} waf configure --prefix=/usr --libdir=/usr/$(mlibdir) $@ || die |
72 |
python waf build "$@" || die |
${MAGE_PYTHON_EXEC} waf build $@ || die |
73 |
elif [[ -e configure ]] |
elif [[ -e configure ]] |
74 |
then |
then |
75 |
mconfigure "$@" || die |
mconfigure $@ || die |
76 |
mmake || die |
mmake || die |
77 |
|
elif [[ -e install.py ]] |
78 |
|
then |
79 |
|
echo "install.py found - nothing to compile here." |
80 |
else |
else |
81 |
mmake || die |
mmake || die |
82 |
fi |
fi |
83 |
} |
} |
84 |
|
|
85 |
python_src_install() |
python_doinstall() |
86 |
{ |
{ |
|
cd ${SRCDIR} |
|
|
|
|
87 |
if [[ -e setup.py ]] |
if [[ -e setup.py ]] |
88 |
then |
then |
89 |
python setup.py install --no-compile --root $(mbindir) "$@" || die |
${MAGE_PYTHON_EXEC} setup.py install --no-compile --root ${BINDIR} $@ || die |
90 |
elif [[ -e waf ]] |
elif [[ -e waf ]] |
91 |
then |
then |
92 |
python waf install --destdir="$(mbindir)" "$@" || die |
${MAGE_PYTHON_EXEC} waf install --destdir=${BINDIR} $@ || die |
93 |
|
elif [[ -e install.py ]] |
94 |
|
then |
95 |
|
${MAGE_PYTHON_EXEC} install.py --prefix=/usr --files-only --destdir=${BINDIR} $@ || die |
96 |
else |
else |
97 |
mmake DESTDIR=$(mbindir) install || die |
mmake DESTDIR=${BINDIR} install || die |
98 |
fi |
fi |
99 |
|
} |
100 |
|
|
101 |
|
python_src_compile() |
102 |
|
{ |
103 |
|
cd ${SRCDIR} |
104 |
|
python_docompile $@ || die |
105 |
|
} |
106 |
|
|
107 |
|
python_multilib_src_compile() |
108 |
|
{ |
109 |
|
local abi |
110 |
|
local saved_SRCDIR="${SRCDIR}" |
111 |
|
|
112 |
|
for abi in ${MULTILIB_ABIS} |
113 |
|
do |
114 |
|
SRCDIR="${saved_SRCDIR}-${abi}/${SRCSUBDIR}" |
115 |
|
cd ${SRCDIR} |
116 |
|
abi-${abi} python_docompile $@ || die |
117 |
|
done |
118 |
|
SRCDIR="${saved_SRCDIR}" |
119 |
|
} |
120 |
|
|
121 |
|
python_src_check() |
122 |
|
{ |
123 |
|
return 0 |
124 |
|
} |
125 |
|
|
126 |
|
python_src_install() |
127 |
|
{ |
128 |
|
cd ${SRCDIR} |
129 |
|
python_doinstall $@ || die |
130 |
|
|
131 |
local i |
local i |
132 |
for i in ABOUT-NLS AUTHORS BUGS CHANGES ChangeLog COPYING \ |
for i in ABOUT-NLS AUTHORS BUGS CHANGES ChangeLog COPYING \ |
139 |
done |
done |
140 |
} |
} |
141 |
|
|
142 |
export_inherits python src_prepare src_compile src_install |
python_multilib_src_install() |
143 |
|
{ |
144 |
|
local abi |
145 |
|
local saved_SRCDIR="${SRCDIR}" |
146 |
|
|
147 |
|
for abi in ${MULTILIB_ABIS} |
148 |
|
do |
149 |
|
SRCDIR="${saved_SRCDIR}-${abi}/${SRCSUBDIR}" |
150 |
|
cd ${SRCDIR} |
151 |
|
abi-${abi} python_doinstall $@ || die |
152 |
|
|
153 |
|
local i |
154 |
|
for i in ABOUT-NLS AUTHORS BUGS CHANGES ChangeLog COPYING \ |
155 |
|
FAQ LICENSE NEWS README TODO |
156 |
|
do |
157 |
|
if [ -f ${SRCDIR}/${i} ] |
158 |
|
then |
159 |
|
oldminstalldocs ${i} || die |
160 |
|
fi |
161 |
|
done |
162 |
|
done |
163 |
|
SRCDIR="${saved_SRCDIR}" |
164 |
|
} |
165 |
|
|
166 |
|
export_inherits python src_prepare src_check |
167 |
|
if [[ ${MULTILIB_BUILD} = true ]] |
168 |
|
then |
169 |
|
export_inherits python_multilib src_compile src_install |
170 |
|
else |
171 |
|
export_inherits python src_compile src_install |
172 |
|
fi |