1 |
# $Id$ |
# $Id$ |
2 |
|
|
3 |
|
# simulate the old behavior |
4 |
|
if [[ -z ${MAGE_PYTHON_EXEC} ]] |
5 |
|
then |
6 |
|
MAGE_PYTHON_EXEC="python" |
7 |
|
|
8 |
|
SDEPEND="${SDEPEND} |
9 |
|
>= dev-lang/python-3" |
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 |
# PYVER="$(python -V 2>&1 | cut -d' ' -f2 | cut -d. -f1-2)" |
local pyver |
20 |
PYVER=$(python -c "import sys ; print sys.version[:3]") |
# pyver="$(${MAGE_PYTHON_EXEC} -V 2>&1 | cut -d' ' -f2 | cut -d. -f1-2)" |
21 |
[[ -z ${PYVER} ]] && return 1 |
pyver=$(${MAGE_PYTHON_EXEC} -c "import sys ; print (sys.version[:3])") |
22 |
echo "${PYVER}" |
[[ -z ${pyver} ]] && return 1 |
23 |
|
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 'import sysconfig; print (sysconfig.get_path("platlib"))') |
31 |
|
[[ -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 'import sysconfig; print (sysconfig.get_path("platinclude"))') |
40 |
|
[[ -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 |
66 |
|
|
67 |
python_docompile() |
python_docompile() |
68 |
{ |
{ |
69 |
if [[ -e setup.py ]] |
if [[ -e pyproject.toml ]] |
70 |
then |
then |
71 |
python setup.py build $@ || die |
TMPDIR=${BUILDDIR} ${MAGE_PYTHON_EXEC} \ |
72 |
|
-m pip wheel --wheel-dir dist --no-build-isolation --no-deps --disable-pip-version-check \ |
73 |
|
--no-cache-dir --use-pep517 --no-clean ${PWD} || die |
74 |
|
elif [[ -e setup.py ]] |
75 |
|
then |
76 |
|
${MAGE_PYTHON_EXEC} setup.py build $@ || die |
77 |
elif [[ -e waf ]] |
elif [[ -e waf ]] |
78 |
then |
then |
79 |
python waf configure --prefix=/usr --libdir=/usr/$(mlibdir) $@ || die |
${MAGE_PYTHON_EXEC} waf configure --prefix=/usr --libdir=/usr/$(mlibdir) $@ || die |
80 |
python waf build $@ || die |
${MAGE_PYTHON_EXEC} waf build $@ || die |
81 |
|
elif [[ -e meson.build ]] |
82 |
|
then |
83 |
|
# never run multilib builds here, multilib will be enabled by python_multilib_src_compile |
84 |
|
# this honors the logic of other build methods (python, waf, autotools) |
85 |
|
MULTILIB_BUILD=false meson_configure -D python=${MAGE_PYTHON_EXEC} || die |
86 |
|
MULTILIB_BUILD=false mninja || die |
87 |
elif [[ -e configure ]] |
elif [[ -e configure ]] |
88 |
then |
then |
89 |
mconfigure $@ || die |
if [[ ${MULTILIB_BUILD} = true ]] && [[ ! -z $(typeset -f oldmconfigure) ]] && [[ ! -z $(typeset -f oldmmake) ]] |
90 |
mmake || die |
then |
91 |
|
oldmconfigure $@ || die |
92 |
|
oldmmake || die |
93 |
|
else |
94 |
|
mconfigure $@ || die |
95 |
|
mmake || die |
96 |
|
fi |
97 |
elif [[ -e install.py ]] |
elif [[ -e install.py ]] |
98 |
then |
then |
99 |
echo "install.py found - nothing to compile here." |
echo "install.py found - nothing to compile here." |
104 |
|
|
105 |
python_doinstall() |
python_doinstall() |
106 |
{ |
{ |
107 |
if [[ -e setup.py ]] |
if [[ -e pyproject.toml ]] |
108 |
|
then |
109 |
|
TMPDIR=${BUILDDIR} ${MAGE_PYTHON_EXEC} \ |
110 |
|
-m pip install --root ${BINDIR} --no-index --no-deps --disable-pip-version-check \ |
111 |
|
--no-cache-dir --use-pep517 --ignore-installed --no-warn-script-location $(find dist -name \*.whl) || die |
112 |
|
elif [[ -e setup.py ]] |
113 |
then |
then |
114 |
python setup.py install --no-compile --root ${BINDIR} $@ || die |
${MAGE_PYTHON_EXEC} setup.py install --no-compile --root ${BINDIR} $@ || die |
115 |
elif [[ -e waf ]] |
elif [[ -e waf ]] |
116 |
then |
then |
117 |
python waf install --destdir=${BINDIR} $@ || die |
${MAGE_PYTHON_EXEC} waf install --destdir=${BINDIR} $@ || die |
118 |
|
elif [[ -e meson.build ]] |
119 |
|
then |
120 |
|
# never run multilib builds here, multilib will be enabled by python_multilib_src_compile |
121 |
|
# this honors the logic of other build methods (python, waf, autotools) |
122 |
|
MULTILIB=false DESTDIR=${BINDIR} mninja install || die |
123 |
elif [[ -e install.py ]] |
elif [[ -e install.py ]] |
124 |
then |
then |
125 |
python install.py --prefix=/usr --files-only --destdir=${BINDIR} $@ || die |
${MAGE_PYTHON_EXEC} install.py --prefix=/usr --files-only --destdir=${BINDIR} $@ || die |
126 |
else |
else |
127 |
mmake DESTDIR=${BINDIR} install || die |
if [[ ${MULTILIB_BUILD} = true ]] && [[ ! -z $(typeset -f oldmconfigure) ]] && [[ ! -z $(typeset -f oldmmake) ]] |
128 |
|
then |
129 |
|
oldmmake DESTDIR=${BINDIR} install || die |
130 |
|
else |
131 |
|
mmake DESTDIR=${BINDIR} install || die |
132 |
|
fi |
133 |
fi |
fi |
134 |
} |
} |
135 |
|
|
136 |
python_src_compile() |
python_src_compile() |
137 |
{ |
{ |
138 |
cd ${SRCDIR} |
cd ${SRCDIR} |
139 |
python_docompile || die |
python_docompile $@ || die |
140 |
|
} |
141 |
|
|
142 |
|
python_multilib_src_compile() |
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_docompile $@ || die |
152 |
|
done |
153 |
|
SRCDIR="${saved_SRCDIR}" |
154 |
|
} |
155 |
|
|
156 |
|
python_src_check() |
157 |
|
{ |
158 |
|
return 0 |
159 |
} |
} |
160 |
|
|
161 |
python_src_install() |
python_src_install() |
162 |
{ |
{ |
163 |
cd ${SRCDIR} |
cd ${SRCDIR} |
164 |
python_doinstall || die |
python_doinstall $@ || die |
165 |
|
|
166 |
local i |
local i |
167 |
for i in ABOUT-NLS AUTHORS BUGS CHANGES ChangeLog COPYING \ |
for i in ABOUT-NLS AUTHORS BUGS CHANGES ChangeLog COPYING \ |
168 |
FAQ LICENSE NEWS README TODO |
FAQ LICENSE NEWS README* TODO PKG-INFO |
169 |
do |
do |
170 |
if [ -f ${SRCDIR}/${i} ] |
if [ -f ${SRCDIR}/${i} ] |
171 |
then |
then |
174 |
done |
done |
175 |
} |
} |
176 |
|
|
177 |
export_inherits python src_prepare src_compile src_install |
python_multilib_src_install() |
178 |
|
{ |
179 |
|
local abi |
180 |
|
local saved_SRCDIR="${SRCDIR}" |
181 |
|
|
182 |
|
for abi in ${MULTILIB_ABIS} |
183 |
|
do |
184 |
|
SRCDIR="${saved_SRCDIR}-${abi}/${SRCSUBDIR}" |
185 |
|
cd ${SRCDIR} |
186 |
|
abi-${abi} python_doinstall $@ || die |
187 |
|
|
188 |
|
local i |
189 |
|
for i in ABOUT-NLS AUTHORS BUGS CHANGES ChangeLog COPYING \ |
190 |
|
FAQ LICENSE NEWS README* TODO PKG-INFO |
191 |
|
do |
192 |
|
if [ -f ${SRCDIR}/${i} ] |
193 |
|
then |
194 |
|
oldminstalldocs ${i} || die |
195 |
|
fi |
196 |
|
done |
197 |
|
done |
198 |
|
SRCDIR="${saved_SRCDIR}" |
199 |
|
} |
200 |
|
|
201 |
|
export_inherits python src_prepare src_check |
202 |
|
if [[ ${MULTILIB_BUILD} = true ]] |
203 |
|
then |
204 |
|
export_inherits python_multilib src_compile src_install |
205 |
|
else |
206 |
|
export_inherits python src_compile src_install |
207 |
|
fi |