# Maintainer: Maxim Baz <$pkgname at maximbaz dot com> # Maintainer: Daniel M. Capella # Contributor: James Zhu pkgname=python-black pkgver=23.3.0 pkgrel=4 pkgdesc='Uncompromising Python code formatter' arch=('any') url=https://github.com/psf/black license=('MIT') depends=('python' 'python-click' 'python-mypy_extensions' 'python-packaging' 'python-pathspec' 'python-platformdirs') makedepends=('python-build' 'python-hatch-fancy-pypi-readme' 'python-hatch-vcs' 'python-hatchling' 'python-installer') checkdepends=('ipython' 'python-aiohttp' 'python-parameterized' 'python-pytest' 'python-typed-ast' 'python-tokenize-rt') optdepends=('ipython: for Jupyter notebook support' 'python-tokenize-rt: for Jupyter notebook support' 'python-aiohttp: for the blackd HTTP server' 'python-colorama: for colored diffs') source=("https://files.pythonhosted.org/packages/source/b/black/black-$pkgver.tar.gz") sha256sums=('1c7b8d606e728a41ea1ccbd7264677e494e87cf630e399262ced92d4a8dac940') b2sums=('01ed5443e1bb251d46618a5b61bbfcc2dc0b41c0bef7d4315fb704a2ac0fd51eb4fe268838b8be6195630f21e6f7b3a5bfca124a7bd60dbef95a02714924327b') build() { cd "black-$pkgver" python -m build --wheel --skip-dependency-check --no-isolation } check() { cd "black-$pkgver" python -m venv --system-site-packages test-env test-env/bin/python -m installer dist/*.whl # https://github.com/psf/black/issues/3251#issuecomment-1236413890 ulimit -n 2048 PATH="$PWD/test-env/bin:$PATH" test-env/bin/python -m pytest } package() { cd "black-$pkgver" python -m installer --destdir="$pkgdir" dist/*.whl # Symlink license file local site_packages=$(python -c "import site; print(site.getsitepackages()[0])") install -d "$pkgdir"/usr/share/licenses/$pkgname ln -s "$site_packages"/black-$pkgver.dist-info/licenses/LICENSE \ "$pkgdir"/usr/share/licenses/$pkgname/LICENSE # Completions install -vd \ "$pkgdir/usr/share/"{bash-completion/completions,fish/vendor_completions.d,zsh/site-functions} _BLACK_COMPLETE=bash_source test-env/bin/black > \ "$pkgdir/usr/share/bash-completion/completions/black" _BLACK_COMPLETE=fish_source test-env/bin/black > \ "$pkgdir/usr/share/fish/vendor_completions.d/black.fish" _BLACK_COMPLETE=zsh_source test-env/bin/black > \ "$pkgdir/usr/share/zsh/site-functions/_black" _BLACKD_COMPLETE=bash_source test-env/bin/blackd > \ "$pkgdir/usr/share/bash-completion/completions/blackd" _BLACKD_COMPLETE=fish_source test-env/bin/blackd > \ "$pkgdir/usr/share/fish/vendor_completions.d/blackd.fish" _BLACKD_COMPLETE=zsh_source test-env/bin/blackd > \ "$pkgdir/usr/share/zsh/site-functions/_blackd" # Vim plugin install -Dm644 -t "$pkgdir/usr/share/vim/vimfiles/plugin" plugin/black.vim install -Dm644 -t "$pkgdir/usr/share/vim/vimfiles/autoload" autoload/black.vim } # vim:set ts=2 sw=2 et: