1 |
# $Id$ |
# $Id$ |
2 |
|
|
3 |
SDEPEND="${SDEPEND} |
# simulate the old behavior |
4 |
>= dev-lang/python-2.7" |
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 |
|
if [[ -z ${MAGE_PYTHON_BUILD_VERSIONS} ]] |
12 |
|
then |
13 |
|
MAGE_PYTHON_BUILD_VERSIONS="single" |
14 |
|
fi |
15 |
|
|
16 |
# get the major.minor current installed python version |
# get the major.minor current installed python version |
17 |
# -> ex 2.4 |
# -> ex 2.4 |
18 |
get_python_version() |
mget-python-version() |
19 |
{ |
{ |
20 |
local pyver |
local pyver |
21 |
# pyver="$(python -V 2>&1 | cut -d' ' -f2 | cut -d. -f1-2)" |
# pyver="$(${MAGE_PYTHON_EXEC} -V 2>&1 | cut -d' ' -f2 | cut -d. -f1-2)" |
22 |
pyver=$(python -c "import sys ; print sys.version[:3]") |
pyver=$(${MAGE_PYTHON_EXEC} -c "import sys ; (print sys.version[:3])") |
23 |
[[ -z ${pyver} ]] && return 1 |
[[ -z ${pyver} ]] && return 1 |
24 |
echo "${pyver}" |
echo "${pyver}" |
25 |
return 0 |
return 0 |
26 |
} |
} |
27 |
|
|
28 |
get_python_libdir() |
mget-python-libdir() |
29 |
{ |
{ |
30 |
local pylib |
local pylib |
31 |
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())') |
32 |
[[ -z ${pylib} ]] && return 1 |
[[ -z ${pylib} ]] && return 1 |
33 |
echo "${pylib}" |
echo "${pylib}" |
34 |
return 0 |
return 0 |
35 |
} |
} |
36 |
|
|
37 |
get_python_includedir() |
mget-python-includedir() |
38 |
{ |
{ |
39 |
local pyinc |
local pyinc |
40 |
pyinc=$(python -c 'from distutils import sysconfig; print sysconfig.get_python_inc()') |
pyinc=$(${MAGE_PYTHON_EXEC} -c 'from distutils import sysconfig; print (sysconfig.get_python_inc())') |
41 |
[[ -z ${pyinc} ]] && return 1 |
[[ -z ${pyinc} ]] && return 1 |
42 |
echo "${pyinc}" |
echo "${pyinc}" |
43 |
return 0 |
return 0 |
44 |
} |
} |
45 |
|
|
46 |
|
# fallback functions to support old smage scripts, dropped in near future |
47 |
|
get_python_version() |
48 |
|
{ |
49 |
|
echo -e "${COLYELLOW}Warning: get_python_version() is depcrecated, please use mget-python-version() instead${COLDEFAULT}" >&2 |
50 |
|
mget-python-version |
51 |
|
} |
52 |
|
get_python_libdir() |
53 |
|
{ |
54 |
|
echo -e "${COLYELLOW}Warning: get_python_libdir() is depcrecated, please use mget-python-libdir() instead${COLDEFAULT}" >&2 |
55 |
|
mget-python-libdir |
56 |
|
} |
57 |
|
get_python_includedir() |
58 |
|
{ |
59 |
|
echo -e "${COLYELLOW}Warning: get_python_includedir() is depcrecated, please use mget-python-includedir() instead${COLDEFAULT}" >&2 |
60 |
|
mget-python-includedir |
61 |
|
} |
62 |
|
|
63 |
python_src_prepare() |
python_src_prepare() |
64 |
{ |
{ |
65 |
munpack ${SRCFILE} || die |
munpack ${SRCFILE} || die |
69 |
{ |
{ |
70 |
if [[ -e setup.py ]] |
if [[ -e setup.py ]] |
71 |
then |
then |
72 |
python setup.py build $@ || die |
${MAGE_PYTHON_EXEC} setup.py build $@ || die |
73 |
elif [[ -e waf ]] |
elif [[ -e waf ]] |
74 |
then |
then |
75 |
python waf configure --prefix=/usr --libdir=/usr/$(mlibdir) $@ || die |
${MAGE_PYTHON_EXEC} waf configure --prefix=/usr --libdir=/usr/$(mlibdir) $@ || die |
76 |
python waf build $@ || die |
${MAGE_PYTHON_EXEC} waf build $@ || die |
77 |
elif [[ -e configure ]] |
elif [[ -e configure ]] |
78 |
then |
then |
79 |
mconfigure $@ || die |
mconfigure $@ || die |
90 |
{ |
{ |
91 |
if [[ -e setup.py ]] |
if [[ -e setup.py ]] |
92 |
then |
then |
93 |
python setup.py install --no-compile --root ${BINDIR} $@ || die |
${MAGE_PYTHON_EXEC} setup.py install --no-compile --root ${BINDIR} $@ || die |
94 |
elif [[ -e waf ]] |
elif [[ -e waf ]] |
95 |
then |
then |
96 |
python waf install --destdir=${BINDIR} $@ || die |
${MAGE_PYTHON_EXEC} waf install --destdir=${BINDIR} $@ || die |
97 |
elif [[ -e install.py ]] |
elif [[ -e install.py ]] |
98 |
then |
then |
99 |
python install.py --prefix=/usr --files-only --destdir=${BINDIR} $@ || die |
${MAGE_PYTHON_EXEC} install.py --prefix=/usr --files-only --destdir=${BINDIR} $@ || die |
100 |
else |
else |
101 |
mmake DESTDIR=${BINDIR} install || die |
mmake DESTDIR=${BINDIR} install || die |
102 |
fi |
fi |
105 |
python_src_compile() |
python_src_compile() |
106 |
{ |
{ |
107 |
cd ${SRCDIR} |
cd ${SRCDIR} |
108 |
python_docompile || die |
python_docompile $@ || die |
109 |
} |
} |
110 |
|
|
111 |
python_multilib_src_compile() |
python_multilib_src_compile() |
117 |
do |
do |
118 |
SRCDIR="${saved_SRCDIR}-${abi}/${SRCSUBDIR}" |
SRCDIR="${saved_SRCDIR}-${abi}/${SRCSUBDIR}" |
119 |
cd ${SRCDIR} |
cd ${SRCDIR} |
120 |
abi-${abi} python_docompile || die |
abi-${abi} python_docompile $@ || die |
121 |
done |
done |
122 |
SRCDIR="${saved_SRCDIR}" |
SRCDIR="${saved_SRCDIR}" |
123 |
} |
} |
124 |
|
|
125 |
|
python_src_check() |
126 |
|
{ |
127 |
|
return 0 |
128 |
|
} |
129 |
|
|
130 |
python_src_install() |
python_src_install() |
131 |
{ |
{ |
132 |
cd ${SRCDIR} |
cd ${SRCDIR} |
133 |
python_doinstall || die |
python_doinstall $@ || die |
134 |
|
|
135 |
local i |
local i |
136 |
for i in ABOUT-NLS AUTHORS BUGS CHANGES ChangeLog COPYING \ |
for i in ABOUT-NLS AUTHORS BUGS CHANGES ChangeLog COPYING \ |
152 |
do |
do |
153 |
SRCDIR="${saved_SRCDIR}-${abi}/${SRCSUBDIR}" |
SRCDIR="${saved_SRCDIR}-${abi}/${SRCSUBDIR}" |
154 |
cd ${SRCDIR} |
cd ${SRCDIR} |
155 |
abi-${abi} python_doinstall || die |
abi-${abi} python_doinstall $@ || die |
156 |
|
|
157 |
local i |
local i |
158 |
for i in ABOUT-NLS AUTHORS BUGS CHANGES ChangeLog COPYING \ |
for i in ABOUT-NLS AUTHORS BUGS CHANGES ChangeLog COPYING \ |
167 |
SRCDIR="${saved_SRCDIR}" |
SRCDIR="${saved_SRCDIR}" |
168 |
} |
} |
169 |
|
|
170 |
export_inherits python src_prepare |
export_inherits python src_prepare src_check |
171 |
if [[ ${MULTILIB_BUILD} = true ]] |
if [[ ${MULTILIB_BUILD} = true ]] |
172 |
then |
then |
173 |
export_inherits python_multilib src_compile src_install |
export_inherits python_multilib src_compile src_install |