2014-01-07 16:29:49 +00:00
|
|
|
#
|
|
|
|
# This helper is for templates installing python modules.
|
|
|
|
#
|
|
|
|
|
|
|
|
do_build() {
|
2016-10-16 14:46:46 +00:00
|
|
|
: ${python_versions:="2.7 $py3_ver"}
|
2019-10-16 14:42:15 +00:00
|
|
|
local pyver= tmp_cflags="$CFLAGS" tmp_ldflags="$LDFLAGS"
|
2014-05-01 14:05:28 +00:00
|
|
|
|
2014-11-07 15:41:59 +00:00
|
|
|
for pyver in $python_versions; do
|
2014-05-01 14:05:28 +00:00
|
|
|
if [ -n "$CROSS_BUILD" ]; then
|
2019-01-31 00:51:19 +00:00
|
|
|
CFLAGS="$tmp_cflags"
|
|
|
|
LDFLAGS="$tmp_ldflags"
|
2019-12-23 16:14:02 +00:00
|
|
|
ADDENV=
|
2019-01-31 00:51:19 +00:00
|
|
|
|
2014-05-01 14:05:28 +00:00
|
|
|
PYPREFIX="$XBPS_CROSS_BASE"
|
2019-10-16 14:42:15 +00:00
|
|
|
CFLAGS+=" -I${XBPS_CROSS_BASE}/include/python${pyver} -I${XBPS_CROSS_BASE}/usr/include"
|
2014-11-07 15:41:59 +00:00
|
|
|
LDFLAGS+=" -L${XBPS_CROSS_BASE}/lib/python${pyver} -L${XBPS_CROSS_BASE}/usr/lib"
|
2014-05-01 14:05:28 +00:00
|
|
|
CC="${XBPS_CROSS_TRIPLET}-gcc -pthread $CFLAGS $LDFLAGS"
|
|
|
|
LDSHARED="${CC} -shared $LDFLAGS"
|
2019-12-23 16:14:02 +00:00
|
|
|
case $pyver in
|
|
|
|
3.*)
|
|
|
|
for f in ${XBPS_CROSS_BASE}/${py3_lib}/_sysconfigdata_*; do
|
|
|
|
f=${f##*/}
|
|
|
|
_PYTHON_SYSCONFIGDATA_NAME=${f%.py}
|
|
|
|
done
|
|
|
|
ADDENV+=" PYTHONPATH=${XBPS_CROSS_BASE}/${py3_lib}"
|
|
|
|
ADDENV+=" _PYTHON_SYSCONFIGDATA_NAME="$_PYTHON_SYSCONFIGDATA_NAME""
|
|
|
|
esac
|
|
|
|
env CC="$CC" LDSHARED="$LDSHARED" $ADDENV \
|
2014-05-01 14:05:28 +00:00
|
|
|
PYPREFIX="$PYPREFIX" CFLAGS="$CFLAGS" \
|
2014-11-07 15:41:59 +00:00
|
|
|
LDFLAGS="$LDFLAGS" python${pyver} setup.py \
|
2017-01-12 11:27:12 +00:00
|
|
|
build --build-base=build-${pyver} ${make_build_args}
|
2014-05-01 14:05:28 +00:00
|
|
|
else
|
2017-01-12 11:27:12 +00:00
|
|
|
python${pyver} setup.py build --build-base=build-${pyver} ${make_build_args}
|
2014-05-01 14:05:28 +00:00
|
|
|
fi
|
|
|
|
done
|
2014-01-07 16:29:49 +00:00
|
|
|
}
|
|
|
|
|
2019-03-20 23:19:40 +00:00
|
|
|
do_check() {
|
|
|
|
: ${python_versions:="2.7 $py3_ver"}
|
|
|
|
|
|
|
|
for pyver in $python_versions; do
|
|
|
|
ln -s build-${pyver} build
|
|
|
|
if [ -z "$make_check_target" ]; then
|
|
|
|
if ! python${pyver} setup.py --help test >/dev/null 2>&1; then
|
|
|
|
msg_warn "No command 'test' defined by setup.py for python${pyver}.\n"
|
|
|
|
rm build
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
python${pyver} setup.py ${make_check_target:-test} ${make_check_args}
|
|
|
|
rm build
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2014-01-07 16:29:49 +00:00
|
|
|
do_install() {
|
2016-10-16 14:46:46 +00:00
|
|
|
: ${python_versions:="2.7 $py3_ver"}
|
2019-10-16 14:42:15 +00:00
|
|
|
local pyver=
|
2014-05-01 14:05:28 +00:00
|
|
|
|
2014-11-07 15:41:59 +00:00
|
|
|
for pyver in $python_versions; do
|
2014-05-01 14:05:28 +00:00
|
|
|
if [ -n "$CROSS_BUILD" ]; then
|
2019-12-23 16:14:02 +00:00
|
|
|
ADDENV=
|
2014-05-01 14:05:28 +00:00
|
|
|
PYPREFIX="$XBPS_CROSS_BASE"
|
2019-10-16 14:42:15 +00:00
|
|
|
CFLAGS+=" -I${XBPS_CROSS_BASE}/include/python${pyver} -I${XBPS_CROSS_BASE}/usr/include"
|
2014-11-07 15:41:59 +00:00
|
|
|
LDFLAGS+=" -L${XBPS_CROSS_BASE}/lib/python${pyver} -L${XBPS_CROSS_BASE}/usr/lib"
|
2014-05-01 14:05:28 +00:00
|
|
|
CC="${XBPS_CROSS_TRIPLET}-gcc -pthread $CFLAGS $LDFLAGS"
|
|
|
|
LDSHARED="${CC} -shared $LDFLAGS"
|
2019-12-23 16:14:02 +00:00
|
|
|
case $pyver in
|
|
|
|
3.*)
|
|
|
|
for f in ${XBPS_CROSS_BASE}/${py3_lib}/_sysconfigdata_*; do
|
|
|
|
f=${f##*/}
|
|
|
|
_PYTHON_SYSCONFIGDATA_NAME=${f%.py}
|
|
|
|
done
|
|
|
|
ADDENV+=" PYTHONPATH=${XBPS_CROSS_BASE}/${py3_lib}"
|
|
|
|
ADDENV+=" _PYTHON_SYSCONFIGDATA_NAME="$_PYTHON_SYSCONFIGDATA_NAME""
|
|
|
|
esac
|
|
|
|
env CC="$CC" LDSHARED="$LDSHARED" $ADDENV \
|
2014-05-01 14:05:28 +00:00
|
|
|
PYPREFIX="$PYPREFIX" CFLAGS="$CFLAGS" \
|
2014-11-07 15:41:59 +00:00
|
|
|
LDFLAGS="$LDFLAGS" python${pyver} setup.py \
|
2017-01-12 11:27:12 +00:00
|
|
|
build --build-base=build-${pyver} \
|
2015-02-21 18:21:21 +00:00
|
|
|
install --prefix=/usr --root=${DESTDIR} ${make_install_args}
|
2014-05-01 14:05:28 +00:00
|
|
|
else
|
2017-01-12 11:27:12 +00:00
|
|
|
python${pyver} setup.py build --build-base=build-${pyver} \
|
2015-02-21 18:21:21 +00:00
|
|
|
install --prefix=/usr --root=${DESTDIR} ${make_install_args}
|
2014-05-01 14:05:28 +00:00
|
|
|
fi
|
2016-04-24 23:25:25 +00:00
|
|
|
|
|
|
|
# Rename unversioned scripts to avoid name conflicts.
|
2016-10-16 14:46:46 +00:00
|
|
|
if [ -d ${DESTDIR}/usr/bin ]; then
|
|
|
|
find ${DESTDIR}/usr/bin -type f ! -name "*[[:digit:]]" | while IFS= read -r f _; do
|
|
|
|
mv "${f}" "${f}${pyver%.*}"
|
|
|
|
echo "[python-module] Unversioned script renamed to '${f#$DESTDIR}${pyver%.*}'"
|
|
|
|
done
|
2016-04-24 23:25:25 +00:00
|
|
|
fi
|
2014-05-01 14:05:28 +00:00
|
|
|
done
|
2014-01-07 16:29:49 +00:00
|
|
|
}
|