summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: d4776f4f9a24324b68f4ea3a1f3bc97459c99385 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# Maintainer: Specter119 <spcter119 AT gmail.com>
# Maintainer: Blair Bonnett <blair.bonnett AT gmail.com>
# Contributor: gökçe aydos <aur-2023 aydos.de>

pkgname=jupyterlab_code_formatter
pkgver=3.0.2
pkgrel=1
pkgdesc='A universal code formatter for JupyterLab.'
arch=(any)
url=https://jupyterlab-code-formatter.readthedocs.io/
license=(MIT)
depends=(
    python
    jupyterlab
    jupyter-lsp

    # Additional optional deps from jsonschema probably due to https://github.com/jupyter/jupyter_events/blob/9b99f6718a3bb2686aab51e17f5c7ee276baf316/pyproject.toml#L31C4-L33C112
    python-fqdn
    python-rfc3986-validator
    python-rfc3339-validator
    python-webcolors
    python-uri-template
    python-jsonpointer
    python-isoduration

    python-types-python-dateutil
    python-terminado
    python-debugpy
)
makedepends=(
  python-build
  python-hatch-jupyter-builder
  python-hatch-nodejs-version
  python-installer
)
checkdepends=(
  python-black
  python-isort
  python-pytest
  python-pytest-jupyter
  yapf
)
optdepends=(
  'astyle: formatting of C, C++, C# and Java code'
  'autopep8: PEP8 compliant formatting of Python code using pycodestyle'
  'python-black: PEP8 compliant formatting of Python code with Black'
  'python-isort: sort imports in Python code'
  'python-ruff: Python formatting using Ruff'
  'r-formatr: automatic formatting of R code'
  'r-styler: R code formatting with Styler'
  'rust: formatting of Rust code'
  'scalafmt: Scala code formatting'
  'yapf: Python code formatting'
)

source=(https://files.pythonhosted.org/packages/source/${pkgname::1}/$pkgname/$pkgname-$pkgver.tar.gz)
sha256sums=('55adb8fa8b9bd58f0b39e7d3ead6c1e862e9ebc1444a66cdb4233d8dc6351d4b')

build() {
  cd $srcdir/$pkgname-$pkgver
  python -m build --wheel --no-isolation -x
}

check() {
  cd $srcdir/$pkgname-$pkgver

  # Build an array of tests to skip based on what the user has installed.
  local skip_tests=('test_can_apply_ruff_formatter')
  if ! pacman -Qqs python-ruff > /dev/null; then
    skip_tests+=('test_can_apply_ruff')
  fi
  if ! pacman -Qqs r-styler > /dev/null; then
    skip_tests+=('test_can_use_styler')
  fi

  # Generate a filter expression from the array.
  local karg=""
  for testname in "${skip_tests[@]}"; do
    karg="$karg and not $testname"
  done
  karg="${karg:5}"  # Trim the leading ' and '.

  # And run the tests.
  JUPYTER_PLATFORM_DIRS=1 python -m pytest -k "$karg"
}

package() {
  cd $srcdir/$pkgname-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
  mv "$pkgdir"/usr/etc "$pkgdir"
  install -Dm644 LICENSE $pkgdir/usr/share/licenses/$pkgname/LICENSE

  # Remove unit tests from the final package.
  rm -rf "$pkgdir/"usr/lib/python*/site-packages/jupyterlab_code_formatter/tests
}