summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 93dcc21507c101bbe9c9776ee366345a9ee21629 (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
# Maintainer:
# Contributor: Matthew McGinn <mamcgi@gmail.com>
# Contributor: Sebastian Reuße <seb@wirrsal.net>

## useful links
# http://www.mypy-lang.org
# https://github.com/JukkaL/mypy

_pkgname="mypy"
pkgname="$_pkgname-git"
pkgver=1.10.0.r11.gba6febc
pkgrel=1
pkgdesc="Optional static typing for Python 2 and 3 (PEP484)"
url="https://github.com/JukkaL/mypy"
license=('MIT')
arch=("any")

depends=(
  'python-psutil'
  'python-mypy_extensions'
  'python-typing_extensions'
  'python-tomli'
)
makedepends=(
  'python-build'
  'python-installer'
  'python-setuptools'
  'python-wheel'
)

provides=("$_pkgname=${pkgver%%.r*}")
conflicts=("$_pkgname")

_pkgsrc="$_pkgname"
source=("$_pkgsrc"::"git+$url.git")
sha256sums=('SKIP')

pkgver() {
  local local _version _version_prefix _revision _hash

  cd "$_pkgsrc"
  _version=$(git tag | sed -E 's/^[^0-9]+//' | sort -rV | head -1)

  if git rev-list --count v${_version} > /dev/null 2>&1; then
    _version_prefix=v
  fi

  _revision=$(git rev-list --count --cherry-pick "${_version_prefix:-}${_version}"...HEAD)

  _hash=$(git rev-parse --short=7 HEAD)

  printf '%s.r%s.g%s' "${_version:?}" "${_revision:?}" "${_hash:?}"
}

prepare() {
  cd "$_pkgsrc"

  # remove unneeded build requirements as we are not compiling mypy: https://github.com/python/mypy/issues/14171
  sed -e '/typing_extensions/d;/mypy_extensions/d;/typed_ast/d;/tomli/d;/types-psutil/d;/types-setuptools/d;/types-typed-ast/d' -i pyproject.toml

  # -Werror, not even once
  sed -e '/Werror/d' -i mypyc/build.py
}

build() {
  cd "$_pkgsrc"
  python -m build --wheel --no-isolation --skip-dependency-check
}

package() {
  local _site_packages=$(python -c "import site; print(site.getsitepackages()[0])")

  cd "$_pkgsrc"
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -Dm644 LICENSE -t "$pkgdir/usr/share/licenses/$pkgname/"

  # remove tests
  rm -frv "$pkgdir/$_site_packages"/*/test*
}