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-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 |
mget-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 |
27 |
mget-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 |
[[ -z ${pylib} ]] && return 1 |
32 |
echo "${pylib}" |
echo "${pylib}" |
33 |
return 0 |
return 0 |
36 |
mget-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 |
[[ -z ${pyinc} ]] && return 1 |
41 |
echo "${pyinc}" |
echo "${pyinc}" |
42 |
return 0 |
return 0 |
64 |
munpack ${SRCFILE} || die |
munpack ${SRCFILE} || die |
65 |
} |
} |
66 |
|
|
67 |
|
python_multilib_src_prepare() |
68 |
|
{ |
69 |
|
munpack ${SRCFILE} || die |
70 |
|
} |
71 |
|
|
72 |
python_docompile() |
python_docompile() |
73 |
{ |
{ |
74 |
if [[ -e setup.py ]] |
if [[ -e pyproject.toml ]] |
75 |
|
then |
76 |
|
TMPDIR=${BUILDDIR} ${MAGE_PYTHON_EXEC} \ |
77 |
|
-m pip wheel --wheel-dir dist --no-build-isolation --no-deps --disable-pip-version-check \ |
78 |
|
--no-cache-dir --use-pep517 --no-clean ${PWD} || die |
79 |
|
elif [[ -e setup.py ]] |
80 |
then |
then |
81 |
python setup.py build $@ || die |
${MAGE_PYTHON_EXEC} setup.py build $@ || die |
82 |
elif [[ -e waf ]] |
elif [[ -e waf ]] |
83 |
then |
then |
84 |
python waf configure --prefix=/usr --libdir=/usr/$(mlibdir) $@ || die |
${MAGE_PYTHON_EXEC} waf configure --prefix=/usr --libdir=/usr/$(mlibdir) $@ || die |
85 |
python waf build $@ || die |
${MAGE_PYTHON_EXEC} waf build $@ || die |
86 |
|
elif [[ -e meson.build ]] |
87 |
|
then |
88 |
|
# never run multilib builds here, multilib will be enabled by python_multilib_src_compile |
89 |
|
# this honors the logic of other build methods (python, waf, autotools) |
90 |
|
MULTILIB_BUILD=false meson_configure -D python=${MAGE_PYTHON_EXEC} || die |
91 |
|
MULTILIB_BUILD=false mninja || die |
92 |
elif [[ -e configure ]] |
elif [[ -e configure ]] |
93 |
then |
then |
94 |
mconfigure $@ || die |
if [[ ${MULTILIB_BUILD} = true ]] && [[ ! -z $(typeset -f oldmconfigure) ]] && [[ ! -z $(typeset -f oldmmake) ]] |
95 |
mmake || die |
then |
96 |
|
oldmconfigure $@ || die |
97 |
|
oldmmake || die |
98 |
|
else |
99 |
|
mconfigure $@ || die |
100 |
|
mmake || die |
101 |
|
fi |
102 |
elif [[ -e install.py ]] |
elif [[ -e install.py ]] |
103 |
then |
then |
104 |
echo "install.py found - nothing to compile here." |
echo "install.py found - nothing to compile here." |
109 |
|
|
110 |
python_doinstall() |
python_doinstall() |
111 |
{ |
{ |
112 |
if [[ -e setup.py ]] |
if [[ -e pyproject.toml ]] |
113 |
|
then |
114 |
|
TMPDIR=${BUILDDIR} ${MAGE_PYTHON_EXEC} \ |
115 |
|
-m pip install --root ${BINDIR} --no-index --no-deps --disable-pip-version-check \ |
116 |
|
--no-cache-dir --use-pep517 --ignore-installed --no-warn-script-location $(find dist -name \*.whl) || die |
117 |
|
elif [[ -e setup.py ]] |
118 |
then |
then |
119 |
python setup.py install --no-compile --root ${BINDIR} $@ || die |
${MAGE_PYTHON_EXEC} setup.py install --no-compile --root ${BINDIR} $@ || die |
120 |
elif [[ -e waf ]] |
elif [[ -e waf ]] |
121 |
then |
then |
122 |
python waf install --destdir=${BINDIR} $@ || die |
${MAGE_PYTHON_EXEC} waf install --destdir=${BINDIR} $@ || die |
123 |
|
elif [[ -e meson.build ]] |
124 |
|
then |
125 |
|
# never run multilib builds here, multilib will be enabled by python_multilib_src_compile |
126 |
|
# this honors the logic of other build methods (python, waf, autotools) |
127 |
|
MULTILIB=false DESTDIR=${BINDIR} mninja install || die |
128 |
elif [[ -e install.py ]] |
elif [[ -e install.py ]] |
129 |
then |
then |
130 |
python install.py --prefix=/usr --files-only --destdir=${BINDIR} $@ || die |
${MAGE_PYTHON_EXEC} install.py --prefix=/usr --files-only --destdir=${BINDIR} $@ || die |
131 |
else |
else |
132 |
mmake DESTDIR=${BINDIR} install || die |
if [[ ${MULTILIB_BUILD} = true ]] && [[ ! -z $(typeset -f oldmconfigure) ]] && [[ ! -z $(typeset -f oldmmake) ]] |
133 |
|
then |
134 |
|
oldmmake DESTDIR=${BINDIR} install || die |
135 |
|
else |
136 |
|
mmake DESTDIR=${BINDIR} install || die |
137 |
|
fi |
138 |
fi |
fi |
139 |
} |
} |
140 |
|
|
141 |
python_src_compile() |
python_src_compile() |
142 |
{ |
{ |
143 |
cd ${SRCDIR} |
cd ${SRCDIR} |
144 |
python_docompile || die |
python_docompile $@ || die |
145 |
} |
} |
146 |
|
|
147 |
python_multilib_src_compile() |
python_multilib_src_compile() |
153 |
do |
do |
154 |
SRCDIR="${saved_SRCDIR}-${abi}/${SRCSUBDIR}" |
SRCDIR="${saved_SRCDIR}-${abi}/${SRCSUBDIR}" |
155 |
cd ${SRCDIR} |
cd ${SRCDIR} |
156 |
abi-${abi} python_docompile || die |
abi-${abi} python_docompile $@ || die |
157 |
done |
done |
158 |
SRCDIR="${saved_SRCDIR}" |
SRCDIR="${saved_SRCDIR}" |
159 |
} |
} |
166 |
python_src_install() |
python_src_install() |
167 |
{ |
{ |
168 |
cd ${SRCDIR} |
cd ${SRCDIR} |
169 |
python_doinstall || die |
python_doinstall $@ || die |
170 |
|
|
171 |
local i |
local i |
172 |
for i in ABOUT-NLS AUTHORS BUGS CHANGES ChangeLog COPYING \ |
for i in ABOUT-NLS AUTHORS BUGS CHANGES ChangeLog COPYING \ |
173 |
FAQ LICENSE NEWS README TODO |
FAQ LICENSE NEWS README* TODO PKG-INFO |
174 |
do |
do |
175 |
if [ -f ${SRCDIR}/${i} ] |
if [ -f ${SRCDIR}/${i} ] |
176 |
then |
then |
188 |
do |
do |
189 |
SRCDIR="${saved_SRCDIR}-${abi}/${SRCSUBDIR}" |
SRCDIR="${saved_SRCDIR}-${abi}/${SRCSUBDIR}" |
190 |
cd ${SRCDIR} |
cd ${SRCDIR} |
191 |
abi-${abi} python_doinstall || die |
abi-${abi} python_doinstall $@ || die |
192 |
|
|
193 |
local i |
local i |
194 |
for i in ABOUT-NLS AUTHORS BUGS CHANGES ChangeLog COPYING \ |
for i in ABOUT-NLS AUTHORS BUGS CHANGES ChangeLog COPYING \ |
195 |
FAQ LICENSE NEWS README TODO |
FAQ LICENSE NEWS README* TODO PKG-INFO |
196 |
do |
do |
197 |
if [ -f ${SRCDIR}/${i} ] |
if [ -f ${SRCDIR}/${i} ] |
198 |
then |
then |