121 lines
4.5 KiB
Bash
121 lines
4.5 KiB
Bash
# Maintainer: Alexey Pavlov <alexpux@gmail.com>
|
|
# Contributor: Ray Donnelly <mingw.android@gmail.com>
|
|
|
|
_realname=docutils
|
|
pkgbase=mingw-w64-python-${_realname}
|
|
pkgname=("${MINGW_PACKAGE_PREFIX}-python2-${_realname}" "${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
|
|
pkgver=0.15.2
|
|
pkgrel=2
|
|
pkgdesc="Set of tools for processing plaintext docs into formats such as HTML, XML, or LaTeX (mingw-w64)"
|
|
arch=('any')
|
|
license=('custom')
|
|
url="https://docutils.sourceforge.io/"
|
|
makedepends=("${MINGW_PACKAGE_PREFIX}-python2" "${MINGW_PACKAGE_PREFIX}-python3")
|
|
source=(https://files.pythonhosted.org/packages/93/22/953e071b589b0b1fee420ab06a0d15e5aa0c7470eb9966d60393ce58ad61/${_realname}-${pkgver}.tar.gz)
|
|
sha256sums=('a2aeea129088da402665e92e0b25b04b073c04b2dce4ab65caaa38b7ce2e1a99')
|
|
noextract=(${_realname}-${pkgver}.tar.gz)
|
|
|
|
prepare() {
|
|
[[ -d ${srcdir}/${_realname}-${pkgver} ]] && rm -rf ${srcdir}/${_realname}-${pkgver}
|
|
tar -xzf ${srcdir}/${_realname}-${pkgver}.tar.gz -C ${srcdir} || true
|
|
|
|
for builddir in python{2,3}-build-${CARCH}; do
|
|
rm -rf ${builddir} | true
|
|
cp -r "${_realname}-${pkgver}" "${builddir}"
|
|
done
|
|
}
|
|
|
|
build() {
|
|
for pver in {2,3}; do
|
|
msg "Python ${pver} build for ${CARCH}"
|
|
cd "${srcdir}/python${pver}-build-${CARCH}"
|
|
MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
|
|
${MINGW_PREFIX}/bin/python${pver} setup.py build --build-lib=build/python${pver}
|
|
find build/python${pver} -type f -exec \
|
|
sed -i "1s,^#! \?/usr/bin/\(env \|\)python$,#!/usr/bin/python${pver}," {} \;
|
|
done
|
|
}
|
|
|
|
check() {
|
|
export LANG=en_US.UTF-8
|
|
for pver in {2,3}; do
|
|
msg "Python ${pver} test for ${CARCH}"
|
|
cd "${srcdir}/python${pver}-build-${CARCH}"
|
|
MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
|
|
PYTHONPATH="$PWD/build/python${pver}/" ${MINGW_PREFIX}/bin/python${pver} test/alltests.py
|
|
done
|
|
}
|
|
|
|
package_python3-docutils() {
|
|
depends=("${MINGW_PACKAGE_PREFIX}-python3")
|
|
|
|
cd "${srcdir}/python3-build-${CARCH}"
|
|
MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
|
|
${MINGW_PREFIX}/bin/python3 setup.py build --build-lib=build/python3 \
|
|
install --prefix=${MINGW_PREFIX} --root="${pkgdir}" --optimize=1
|
|
|
|
local _mingw_prefix=$(cygpath -am ${MINGW_PREFIX})
|
|
|
|
for _f in "${pkgdir}${MINGW_PREFIX}"/bin/*.py; do
|
|
sed -e "s|${_mingw_prefix}/bin/|/usr/bin/env |g" -i ${_f}
|
|
done
|
|
|
|
# symlink without .py
|
|
for f in "${pkgdir}${MINGW_PREFIX}"/bin/*.py; do
|
|
ln -s "$(basename $f)" "${pkgdir}${MINGW_PREFIX}/bin/$(basename $f .py)"
|
|
# fix so the file is a script that can run with no issues on the command-line w/o
|
|
# specifying an interpreter
|
|
sed -e "s|/usr/bin/env python3.exe|${MINGW_PREFIX}/bin/python3.exe|g" -i "${pkgdir}${MINGW_PREFIX}/bin/$(basename $f .py)"
|
|
done
|
|
|
|
# setup license
|
|
install -D -m644 COPYING.txt "${pkgdir}${MINGW_PREFIX}/share/licenses/python3-${_realname}/COPYING.txt"
|
|
install -D -m644 licenses/python* "${pkgdir}${MINGW_PREFIX}/share/licenses/python3-${_realname}/"
|
|
}
|
|
|
|
package_python2-docutils() {
|
|
depends=("${MINGW_PACKAGE_PREFIX}-python2")
|
|
provides=("${MINGW_PACKAGE_PREFIX}-docutils=${pkgver}")
|
|
replaces=("${MINGW_PACKAGE_PREFIX}-docutils")
|
|
|
|
cd "${srcdir}/python2-build-${CARCH}"
|
|
MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
|
|
${MINGW_PREFIX}/bin/python2 setup.py build --build-lib=build/python2 \
|
|
install --prefix=${MINGW_PREFIX} --root="${pkgdir}" --optimize=1
|
|
|
|
local _mingw_prefix=$(cygpath -am ${MINGW_PREFIX})
|
|
|
|
# fix python command in files
|
|
for _f in "${pkgdir}${MINGW_PREFIX}"/bin/*.py; do
|
|
sed -e "s|${_mingw_prefix}/bin/|/usr/bin/env |g" -i ${_f}
|
|
mv -v "$_f" "${_f%.py}2.py"
|
|
done
|
|
|
|
# symlink without .py
|
|
for _f in "${pkgdir}${MINGW_PREFIX}"/bin/*.py; do
|
|
ln -s "$(basename $_f)" "${pkgdir}${MINGW_PREFIX}/bin/$(basename $_f .py)"
|
|
# fix so the file is a script that can run with no issues on the command-line w/o
|
|
# specifying an interpreter
|
|
sed -e "s|/usr/bin/env python2.exe|${MINGW_PREFIX}/bin/python2.exe|g" -i "${pkgdir}${MINGW_PREFIX}/bin/$(basename $_f .py)"
|
|
done
|
|
# setup license
|
|
install -D -m644 COPYING.txt "${pkgdir}${MINGW_PREFIX}/share/licenses/python2-${_realname}/COPYING.txt"
|
|
install -D -m644 licenses/python* "${pkgdir}${MINGW_PREFIX}/share/licenses/python2-${_realname}/"
|
|
}
|
|
|
|
package_mingw-w64-i686-python2-docutils() {
|
|
package_python2-docutils
|
|
}
|
|
|
|
package_mingw-w64-i686-python3-docutils() {
|
|
package_python3-docutils
|
|
}
|
|
|
|
package_mingw-w64-x86_64-python2-docutils() {
|
|
package_python2-docutils
|
|
}
|
|
|
|
package_mingw-w64-x86_64-python3-docutils() {
|
|
package_python3-docutils
|
|
}
|