Files
haikuports/dev-python/argparse-manpage/argparse_manpage-4.6.recipe
Joachim Mairböck 2c4d17266d argparse_manpage: add missing dependency
it was only added implicitly before
2024-08-24 21:39:34 +02:00

111 lines
2.9 KiB
Bash

SUMMARY="Automatically build man-pages for your Python project"
DESCRIPTION="Avoid documenting your Python script arguments on two places! This is typically done \
in an argparse.ArgumentParser help configuration (help=, description=, etc.), and also in a \
manually crafted manual page.
The good thing about an ArgumentParser objects is that it actually provides a traversable \
\"tree-like\" structure, with all the necessary info needed to automatically generate \
documentation, for example in a groff typesetting system (manual pages). And this is where this \
project can help.
There are two supported ways to generate the manual, either script it using the installed command \
argparse-manpage, or via setup.py build automation (with a slight bonus of automatic manual page \
installation with setup.py install)."
HOMEPAGE="https://github.com/praiskup/argparse-manpage"
COPYRIGHT="Gabriele Giammatteo
Pavel Raiskup"
LICENSE="Apache v2"
REVISION="1"
SOURCE_URI="https://github.com/praiskup/argparse-manpage/releases/download/v$portVersion/argparse-manpage-$portVersion.tar.gz"
CHECKSUM_SHA256="0b659d70fd142876da41c2918bd6de4d027875720b0e4672d6443b51198dbb62"
SOURCE_DIR="argparse-manpage-$portVersion"
ARCHITECTURES="any"
PROVIDES="
$portName = $portVersion
"
REQUIRES="
haiku
"
BUILD_REQUIRES="
haiku_devel
"
PYTHON_VERSIONS=(3.10)
defaultVersion=3.10
for i in "${!PYTHON_VERSIONS[@]}"; do
pythonVersion=${PYTHON_VERSIONS[$i]}
pythonPackage=python${pythonVersion//.}
eval "PROVIDES_$pythonPackage=\"
${portName}_$pythonPackage = $portVersion
cmd:argparse_manpage_$pythonVersion = $portVersion
\""
if [ $pythonVersion = $defaultVersion ]; then
eval "PROVIDES_$pythonPackage+=\"
cmd:argparse_manpage = $portVersion
\""
fi
eval "REQUIRES_$pythonPackage=\"
haiku
cmd:python$pythonVersion
tomli_$pythonPackage
\""
BUILD_REQUIRES+="
build_$pythonPackage
installer_$pythonPackage
setuptools_$pythonPackage
tomli_$pythonPackage # only needed for python < 3.11
wheel_$pythonPackage
"
BUILD_PREREQUIRES+="
cmd:python$pythonVersion
"
done
PATCH()
{
sed -i "s,share/man,$relativeManDir,g" build_manpages/build_manpages.py
}
INSTALL()
{
for i in "${!PYTHON_VERSIONS[@]}"; do
pythonVersion=${PYTHON_VERSIONS[$i]}
pythonPackage=python${pythonVersion//.}
python=python$pythonVersion
$python -m build --wheel --skip-dependency-check --no-isolation
$python -m installer -p $prefix dist/*.whl
# Version suffix all the scripts and man pages
for f in $binDir/*; do
mv $f $f-$pythonVersion
done
for f in $manDir/man1/*; do
mv $f ${f%.1}-$pythonVersion.1
done
# And provide suffix-less symlinks for the default version
if [ $pythonVersion = $defaultVersion ]; then
for f in $binDir/*; do
ln -sr $f ${f%-$pythonVersion}
done
for f in $manDir/man1/*; do
ln -sr $f ${f%-$pythonVersion.1}.1
done
fi
packageEntries $pythonPackage \
$prefix/lib/python* \
$binDir \
$manDir
done
}