summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: f335f4e8b50c39d83f988b3982d73737c82cb538 (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
# Maintainer:  jyantis <yantis@yantis.net>

pkgbase=python-ratelim-git
pkgname=('python-ratelim-git' 'python2-ratelim-git')
pkgver=0.1.6.r15.e75c81c
pkgrel=2
arch=('any')
url='https://github.com/themiurgo/ratelim'
license=('MIT')
source=('git+https://github.com/themiurgo/ratelim.git')
sha256sums=('SKIP')
makedepends=('git'
             'python-setuptools'
             'python2-setuptools'
             'python'
             'python2'
             'python-decorator'
             'python2-decorator')

pkgver() {
  cd ratelim
  set -o pipefail
  _gitversion=$( git describe --long | sed -r 's/([^-]*-g)/r\1/;s/-/./g' ||
  printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)" )

  # If there is a setup.py then pull the version tag from the file
  if [ -f "setup.py" ]; then
    if grep --quiet "version = " setup.py; then
      printf "%s.%s" "$(grep -R "version = " setup.py | awk -F\' '{print $2}')" $_gitversion | sed 's/-/./g'
    elif grep --quiet "version=" setup.py; then
      printf "%s.%s" "$(grep -R "version=" setup.py | awk -F\' '{print $2}')" $_gitversion | sed 's/-/./g'
    else
      printf "%s" $_gitversion
    fi
  else
    printf "%s" $_gitversion
  fi
}

package_python-ratelim-git() {
  pkgdesc='Ratelim is a simple Python 3 library that limits the number of times a function can be called during a time interval. It is particularly useful when using online APIs, which commonly enforce rate limits.'
  depends=('python' 'python-decorator')
  provides=('python-ratelim')
  conflicts=('python-ratelim')

  cd ratelim

  # We don't need anything related to git in the package
  rm -rf .git*

  python setup.py install --root="${pkgdir}" --optimize=1

  # Install License
  install -D -m644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"

  # Install Documentation
  install -D -m644 README.rst "${pkgdir}/usr/share/doc/${pkgname}/README.rst"
}

package_python2-ratelim-git() {
  pkgdesc='Ratelim is a simple Python 2 library that limits the number of times a function can be called during a time interval. It is particularly useful when using online APIs, which commonly enforce rate limits.'
  depends=('python2' 'python2-decorator')
  provides=('python2-ratelim')
  conflicts=('python2-ratelim')

  cd ratelim

  # Patch any #!/usr/bin/python to #!/usr/bin/python2
  for file in $(find . -name '*.py' -print); do
    sed -r -i 's_^#!.*/usr/bin/python(\s|$)_#!/usr/bin/python2_' $file
    sed -r -i 's_^#!.*/usr/bin/env(\s)*python(\s|$)_#!/usr/bin/env python2_' $file
  done

  # We don't need anything related to git in the package
  rm -rf .git*

  python2 setup.py install --root="${pkgdir}" --optimize=1

  # Install License
  install -D -m644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"

  # Install Documentation
  install -D -m644 README.rst "${pkgdir}/usr/share/doc/${pkgname}/README.rst"
}


# vim:set ts=2 sw=2 et: