python-cmd2: port to python-build

This commit is contained in:
Biswapriyo Nath
2025-01-02 07:47:14 +00:00
parent 3c24e0b061
commit 2df1de4140

View File

@@ -8,7 +8,8 @@ pkgrel=1
pkgdesc="Extra features for standard library's cmd module (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://github.com/python-cmd2/cmd2'
msys2_repository_url='https://github.com/python-cmd2/cmd2/'
url='https://cmd2.readthedocs.io/'
msys2_references=(
'pypi: cmd2'
)
@@ -16,59 +17,33 @@ license=('spdx:MIT')
depends=("${MINGW_PACKAGE_PREFIX}-python-pyperclip"
"${MINGW_PACKAGE_PREFIX}-python-pyreadline3"
"${MINGW_PACKAGE_PREFIX}-python-wcwidth")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools"
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
"${MINGW_PACKAGE_PREFIX}-python-installer"
"${MINGW_PACKAGE_PREFIX}-python-setuptools"
"${MINGW_PACKAGE_PREFIX}-python-setuptools-scm")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python-pytest-xdist"
"${MINGW_PACKAGE_PREFIX}-python-cov"
checkdepends=("${MINGW_PACKAGE_PREFIX}-python-pytest"
"${MINGW_PACKAGE_PREFIX}-python-pytest-cov"
"${MINGW_PACKAGE_PREFIX}-python-mock")
source=("${_realname}-${pkgver}.tar.gz::https://github.com/python-cmd2/cmd2/archive/${pkgver}.tar.gz")
sha512sums=('07c67ef66861ec3cdf697405d9cf53fc0b530b65d1933224063c3aed2a881978673a5065bd089b51ca07d63414d849a33a8b9e2d963be25d023b1eadda29b803')
# Helper macros to help make tasks easier #
apply_patch_with_msg() {
for _patch in "$@"
do
msg2 "Applying $_patch"
patch -Nbp1 -i "${srcdir}/${_patch}"
done
}
del_file_exists() {
for _fname in "$@"
do
if [ -f $_fname ]; then
rm -rf $_fname
fi
done
}
# =========================================== #
prepare() {
cd "${srcdir}"
rm -rf python-build-${MSYSTEM} || true
cp -r "${_realname}-${pkgver}" "python-build-${MSYSTEM}"
# Set version for setuptools_scm
export SETUPTOOLS_SCM_PRETEND_VERSION=${pkgver}
export PBR_VERSION=${pkgver}
}
source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname}-${pkgver}.tar.gz")
sha512sums=('ce19006dff46279f14ac7d23ab4177b7926b061565ceff054291a508773ed0c037bdd20ffc72ecc99d44bcbc3751a486a14dd9d1d43c2e61a7ebd45cf967f06c')
build() {
msg "Python build for ${MSYSTEM}"
cd "${srcdir}/python-build-${MSYSTEM}"
${MINGW_PREFIX}/bin/python setup.py build
export SETUPTOOLS_SCM_PRETEND_VERSION="${pkgver}"
cp -r "${_realname}-${pkgver}" "python-build-${MSYSTEM}" && cd "python-build-${MSYSTEM}"
python -m build --wheel --skip-dependency-check --no-isolation
}
check() {
msg "Python test for ${MSYSTEM}"
cd "${srcdir}/python-build-${MSYSTEM}"
${MINGW_PREFIX}/bin/python -m pytest || true
cd "python-build-${MSYSTEM}"
python -m pytest || warning "Tests failed"
}
package() {
cd "${srcdir}/python-build-${MSYSTEM}"
MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} \
--root="${pkgdir}" --optimize=1 --skip-build
cd "python-build-${MSYSTEM}"
MSYS2_ARG_CONV_EXCL="--prefix=" \
python -m installer --prefix=${MINGW_PREFIX} \
--destdir="${pkgdir}" dist/*.whl
install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}