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 |
|
|
12 |
|
# call meson include in the smage2, to prevent unnecessary dependencies |
13 |
|
#sminclude meson |
14 |
|
|
15 |
# get the major.minor current installed python version |
# get the major.minor current installed python version |
16 |
# -> ex 2.4 |
# -> ex 2.4 |
17 |
get_python_version() |
mget-python-version() |
18 |
{ |
{ |
19 |
local pyver |
local pyver |
20 |
# 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)" |
21 |
pyver=$(python -c "import sys ; print sys.version[:3]") |
pyver=$(${MAGE_PYTHON_EXEC} -c "import sys ; print (sys.version[:3])") |
22 |
[[ -z ${pyver} ]] && return 1 |
[[ -z ${pyver} ]] && return 1 |
23 |
echo "${pyver}" |
echo "${pyver}" |
24 |
return 0 |
return 0 |
25 |
} |
} |
26 |
|
|
27 |
get_python_libdir() |
mget-python-libdir() |
28 |
{ |
{ |
29 |
local pylib |
local pylib |
30 |
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())') |
31 |
[[ -z ${pylib} ]] && return 1 |
[[ -z ${pylib} ]] && return 1 |
32 |
echo "${pylib}" |
echo "${pylib}" |
33 |
return 0 |
return 0 |
34 |
} |
} |
35 |
|
|
36 |
get_python_includedir() |
mget-python-includedir() |
37 |
{ |
{ |
38 |
local pyinc |
local pyinc |
39 |
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())') |
40 |
[[ -z ${pyinc} ]] && return 1 |
[[ -z ${pyinc} ]] && return 1 |
41 |
echo "${pyinc}" |
echo "${pyinc}" |
42 |
return 0 |
return 0 |
43 |
} |
} |
44 |
|
|
45 |
|
# fallback functions to support old smage scripts, dropped in near future |
46 |
|
get_python_version() |
47 |
|
{ |
48 |
|
echo -e "${COLYELLOW}Warning: get_python_version() is depcrecated, please use mget-python-version() instead${COLDEFAULT}" >&2 |
49 |
|
mget-python-version |
50 |
|
} |
51 |
|
get_python_libdir() |
52 |
|
{ |
53 |
|
echo -e "${COLYELLOW}Warning: get_python_libdir() is depcrecated, please use mget-python-libdir() instead${COLDEFAULT}" >&2 |
54 |
|
mget-python-libdir |
55 |
|
} |
56 |
|
get_python_includedir() |
57 |
|
{ |
58 |
|
echo -e "${COLYELLOW}Warning: get_python_includedir() is depcrecated, please use mget-python-includedir() instead${COLDEFAULT}" >&2 |
59 |
|
mget-python-includedir |
60 |
|
} |
61 |
|
|
62 |
python_src_prepare() |
python_src_prepare() |
63 |
{ |
{ |
64 |
munpack ${SRCFILE} || die |
munpack ${SRCFILE} || die |
68 |
{ |
{ |
69 |
if [[ -e setup.py ]] |
if [[ -e setup.py ]] |
70 |
then |
then |
71 |
python setup.py build $@ || die |
${MAGE_PYTHON_EXEC} setup.py build $@ || die |
72 |
elif [[ -e waf ]] |
elif [[ -e waf ]] |
73 |
then |
then |
74 |
python waf configure --prefix=/usr --libdir=/usr/$(mlibdir) $@ || die |
${MAGE_PYTHON_EXEC} waf configure --prefix=/usr --libdir=/usr/$(mlibdir) $@ || die |
75 |
python waf build $@ || die |
${MAGE_PYTHON_EXEC} waf build $@ || die |
76 |
|
elif [[ -e meson.build ]] |
77 |
|
then |
78 |
|
# never run multilib builds here, multilib will be enabled by python_multilib_src_compile |
79 |
|
# this honors the logic of other build methods (python, waf, autotools) |
80 |
|
MULTILIB_BUILD=false meson_configure -D python=${MAGE_PYTHON_EXEC} || die |
81 |
|
MULTILIB_BUILD=false mninja || die |
82 |
elif [[ -e configure ]] |
elif [[ -e configure ]] |
83 |
then |
then |
84 |
mconfigure $@ || die |
if [[ ${MULTILIB_BUILD} = true ]] && [[ ! -z $(typeset -f oldmconfigure) ]] && [[ ! -z $(typeset -f oldmmake) ]] |
85 |
mmake || die |
then |
86 |
|
oldmconfigure $@ || die |
87 |
|
oldmmake || die |
88 |
|
else |
89 |
|
mconfigure $@ || die |
90 |
|
mmake || die |
91 |
|
fi |
92 |
elif [[ -e install.py ]] |
elif [[ -e install.py ]] |
93 |
then |
then |
94 |
echo "install.py found - nothing to compile here." |
echo "install.py found - nothing to compile here." |
101 |
{ |
{ |
102 |
if [[ -e setup.py ]] |
if [[ -e setup.py ]] |
103 |
then |
then |
104 |
python setup.py install --no-compile --root ${BINDIR} $@ || die |
${MAGE_PYTHON_EXEC} setup.py install --no-compile --root ${BINDIR} $@ || die |
105 |
elif [[ -e waf ]] |
elif [[ -e waf ]] |
106 |
then |
then |
107 |
python waf install --destdir=${BINDIR} $@ || die |
${MAGE_PYTHON_EXEC} waf install --destdir=${BINDIR} $@ || die |
108 |
|
elif [[ -e meson.build ]] |
109 |
|
then |
110 |
|
# never run multilib builds here, multilib will be enabled by python_multilib_src_compile |
111 |
|
# this honors the logic of other build methods (python, waf, autotools) |
112 |
|
MULTILIB=false DESTDIR=${BINDIR} mninja install || die |
113 |
elif [[ -e install.py ]] |
elif [[ -e install.py ]] |
114 |
then |
then |
115 |
python install.py --prefix=/usr --files-only --destdir=${BINDIR} $@ || die |
${MAGE_PYTHON_EXEC} install.py --prefix=/usr --files-only --destdir=${BINDIR} $@ || die |
116 |
else |
else |
117 |
mmake DESTDIR=${BINDIR} install || die |
if [[ ${MULTILIB_BUILD} = true ]] && [[ ! -z $(typeset -f oldmconfigure) ]] && [[ ! -z $(typeset -f oldmmake) ]] |
118 |
|
then |
119 |
|
oldmmake DESTDIR=${BINDIR} install || die |
120 |
|
else |
121 |
|
mmake DESTDIR=${BINDIR} install || die |
122 |
|
fi |
123 |
fi |
fi |
124 |
} |
} |
125 |
|
|
126 |
python_src_compile() |
python_src_compile() |
127 |
{ |
{ |
128 |
cd ${SRCDIR} |
cd ${SRCDIR} |
129 |
python_docompile || die |
python_docompile $@ || die |
130 |
} |
} |
131 |
|
|
132 |
python_multilib_src_compile() |
python_multilib_src_compile() |
138 |
do |
do |
139 |
SRCDIR="${saved_SRCDIR}-${abi}/${SRCSUBDIR}" |
SRCDIR="${saved_SRCDIR}-${abi}/${SRCSUBDIR}" |
140 |
cd ${SRCDIR} |
cd ${SRCDIR} |
141 |
abi-${abi} python_docompile || die |
abi-${abi} python_docompile $@ || die |
142 |
done |
done |
143 |
SRCDIR="${saved_SRCDIR}" |
SRCDIR="${saved_SRCDIR}" |
144 |
} |
} |
145 |
|
|
146 |
|
python_src_check() |
147 |
|
{ |
148 |
|
return 0 |
149 |
|
} |
150 |
|
|
151 |
python_src_install() |
python_src_install() |
152 |
{ |
{ |
153 |
cd ${SRCDIR} |
cd ${SRCDIR} |
154 |
python_doinstall || die |
python_doinstall $@ || die |
155 |
|
|
156 |
local i |
local i |
157 |
for i in ABOUT-NLS AUTHORS BUGS CHANGES ChangeLog COPYING \ |
for i in ABOUT-NLS AUTHORS BUGS CHANGES ChangeLog COPYING \ |
173 |
do |
do |
174 |
SRCDIR="${saved_SRCDIR}-${abi}/${SRCSUBDIR}" |
SRCDIR="${saved_SRCDIR}-${abi}/${SRCSUBDIR}" |
175 |
cd ${SRCDIR} |
cd ${SRCDIR} |
176 |
abi-${abi} python_doinstall || die |
abi-${abi} python_doinstall $@ || die |
177 |
|
|
178 |
local i |
local i |
179 |
for i in ABOUT-NLS AUTHORS BUGS CHANGES ChangeLog COPYING \ |
for i in ABOUT-NLS AUTHORS BUGS CHANGES ChangeLog COPYING \ |
188 |
SRCDIR="${saved_SRCDIR}" |
SRCDIR="${saved_SRCDIR}" |
189 |
} |
} |
190 |
|
|
191 |
export_inherits python src_prepare |
export_inherits python src_prepare src_check |
192 |
if [[ ${MULTILIB_BUILD} = true ]] |
if [[ ${MULTILIB_BUILD} = true ]] |
193 |
then |
then |
194 |
export_inherits python_multilib src_compile src_install |
export_inherits python_multilib src_compile src_install |