Add python-tomli

install via the wheel since it will be part of the bootstrap chain
like the mingw package and we can't use any build tools there.

Required for newer pytest
This commit is contained in:
Christoph Reiter 2022-07-03 09:20:21 +02:00
parent d1ec3a1561
commit febb4b4bb0
2 changed files with 61 additions and 0 deletions

28
python-tomli/PKGBUILD Normal file
View File

@ -0,0 +1,28 @@
pkgname=python-tomli
pkgver=2.0.1
pkgrel=1
pkgdesc="A lil' TOML parser"
url="https://github.com/hukkin/tomli"
license=('spdx:MIT')
arch=('any')
depends=('python')
source=("https://pypi.debian.net/tomli/tomli-$pkgver-py3-none-any.whl"
"install_wheel.py")
sha256sums=('939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc'
'668e64f912d6360330c403edb6100b21f6aa6dd6a7803d342fab8c35d8176ad9')
build() {
mkdir dist
cp "tomli-$pkgver-py3-none-any.whl" dist
}
package() {
_pythonpath=`python -c "import sysconfig; print(sysconfig.get_path('platlib'))"`
_site_packages="${pkgdir}${_pythonpath}"
mkdir -p "$_site_packages"
python "${srcdir}/install_wheel.py" -i"${_site_packages}" dist/*.whl
python -m compileall \
-o 0 -o 1 -q -s"${pkgdir}" -p"/" "${_site_packages}"
install -Dm644 tomli*.dist-info/LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname/
}

View File

@ -0,0 +1,33 @@
import argparse
import sys
import sysconfig
from pathlib import Path
from zipfile import ZipFile
def extract_wheel(whl_path, dest):
print("Installing to", dest)
with ZipFile(whl_path) as zf:
zf.extractall(dest)
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument(
'wheel',
type=Path,
help=f'wheel to install (.whl file)',
)
purelib = Path(sysconfig.get_path('purelib')).resolve()
parser.add_argument(
'--installdir',
'-i',
type=Path,
default=purelib,
help=f'installdir directory (defaults to {purelib})',
)
args = parser.parse_args()
if not args.installdir.is_dir():
sys.exit(f"{args.installdir} is not a directory")
extract_wheel(args.wheel, args.installdir)