|
| 1 | +# Maintainer: Claudia Pellegrino <aur ät cpellegrino.de> |
| 2 | + |
| 3 | +pkgname=python-jschon |
| 4 | +_gitpkgname=jschon |
| 5 | +pkgver=0.11.1 |
| 6 | +pkgrel=2 |
| 7 | +pkgdesc='Object-oriented JSON Schema implementation for Python' |
| 8 | +arch=('any') |
| 9 | +url='https://github.com/marksparkza/jschon' |
| 10 | +license=('MIT') |
| 11 | +depends=( |
| 12 | + 'python' |
| 13 | + 'python-requests' |
| 14 | + 'python-rfc3986' |
| 15 | +) |
| 16 | +makedepends=( |
| 17 | + 'python-build' |
| 18 | + 'python-installer' |
| 19 | + 'python-setuptools' |
| 20 | + 'python-sphinx' |
| 21 | + 'python-sphinx_rtd_theme' |
| 22 | + 'python-wheel' |
| 23 | + 'stylelint' |
| 24 | +) |
| 25 | +checkdepends=( |
| 26 | + 'python-hypothesis' |
| 27 | + 'python-pytest' |
| 28 | + 'python-pytest-httpserver' |
| 29 | +) |
| 30 | + |
| 31 | +source=( |
| 32 | + "${_gitpkgname}-${pkgver}.tar.gz::https://github.com/marksparkza/jschon/archive/v${pkgver}.tar.gz" |
| 33 | +) |
| 34 | + |
| 35 | +sha512sums=( |
| 36 | + 'a4b3c559501189efcfdd5a3dfca96594c7d5bbea0e7343524c2cea6bb661790704956401ea3901ff13d5bf15d15843ee2724c14061a3f1ee47a08dbbb0c9c2ab' |
| 37 | +) |
| 38 | + |
| 39 | +prepare() { |
| 40 | + local _schemas_basedir |
| 41 | + |
| 42 | + cd "${_gitpkgname}-${pkgver}" |
| 43 | + |
| 44 | + echo >&2 'Linking stable JSON schema specs' |
| 45 | + _schemas_basedir='/usr/lib/node_modules/stylelint/node_modules/table/node_modules/ajv/dist/refs' |
| 46 | + rmdir -v jschon/catalog/json-schema-{2019-09,2020-12} |
| 47 | + ln -nsv "${_schemas_basedir}"/json-schema-{2019-09,2020-12} jschon/catalog/ |
| 48 | + |
| 49 | + echo >&2 'Disabling verification for unstable, unversioned schema specs' |
| 50 | + # shellcheck disable=SC2016 # Not meant to be expanded |
| 51 | + sed -i -e 's/, ``next``//' -e 's/, _next//' -e '/_next\.initialize/d' jschon/__init__.py |
| 52 | + sed -i -e "s/, 'next'//" tests/{conftest,test_catalog,test_metaschema}.py |
| 53 | +} |
| 54 | + |
| 55 | +build() { |
| 56 | + local _site_packages |
| 57 | + cd "${_gitpkgname}-${pkgver}" |
| 58 | + |
| 59 | + echo >&2 'Building wheel' |
| 60 | + python -m build --wheel --no-isolation |
| 61 | + |
| 62 | + echo >&2 'Generating HTML documentation' |
| 63 | + _site_packages="$(python -c 'import site; print(site.getsitepackages()[0])')" |
| 64 | + python -m installer --destdir=tmp_install dist/*.whl |
| 65 | + PYTHONPATH="${PWD}/tmp_install/${_site_packages}" \ |
| 66 | + make -C docs singlehtml |
| 67 | +} |
| 68 | + |
| 69 | +check() { |
| 70 | + cd "${_gitpkgname}-${pkgver}" |
| 71 | + |
| 72 | + echo >&2 'Running unit tests' |
| 73 | + # Excluding `next` tests due to missing unstable schema |
| 74 | + # Excluding benchmark tests, which are not relevant for system packaging |
| 75 | + # Excluding test_hierarchical_output: missing validation output schema |
| 76 | + pytest -k 'not [next] and not test_benchmarks and not test_hierarchical_output' |
| 77 | +} |
| 78 | + |
| 79 | +package() { |
| 80 | + cd "${_gitpkgname}-${pkgver}" |
| 81 | + |
| 82 | + echo >&2 'Packaging the wheel' |
| 83 | + python -I -m installer --destdir="${pkgdir}" dist/*.whl |
| 84 | + |
| 85 | + echo >&2 'Packaging the documentation' |
| 86 | + install -D -m 644 -t "${pkgdir}/usr/share/doc/${pkgname}" \ |
| 87 | + README.rst |
| 88 | + cp -R --preserve=mode -t "${pkgdir}/usr/share/doc/${pkgname}" \ |
| 89 | + docs/_build/singlehtml/{index.html,_static} |
| 90 | + |
| 91 | + echo >&2 'Packaging the license' |
| 92 | + install -D -m 644 -t "${pkgdir}/usr/share/licenses/${pkgname}" \ |
| 93 | + LICENSE |
| 94 | +} |
0 commit comments