summaryrefslogtreecommitdiff
path: root/community/python-pymongo/PKGBUILD
blob: 4a850e45ee162ef6a1ef27c47968867b8820a1a0 (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
# $Id: PKGBUILD 111775 2014-05-24 05:26:09Z fyan $
# Maintainer: Alexander Rødseth <rodseth@gmail.com>
# Maintainer: Felix Yan <felixonmars@gmail.com>
# Contributor: Thomas S Hatch <thatch45@gmail.com>
# Contributor: Jelle van der Waa <jelle@vdwaa.nl>

pkgbase=python-pymongo
pkgname=('python-pymongo' 'python2-pymongo')
pkgver=2.7.1
pkgrel=1
pkgdesc='Python module for using MongoDB'
arch=('x86_64' 'i686')
license=('APACHE')
url='http://pypi.python.org/pypi/pymongo/'
makedepends=('python-setuptools' 'python2-setuptools')
checkdepends=('python-nose' 'python2-nose' 'python2-gevent' 'mongodb' 'perl')
optdepends=('mongodb: High-performance schema-free document-oriented database')
source=("http://pypi.python.org/packages/source/p/pymongo/pymongo-$pkgver.tar.gz")
sha256sums=('4810d302b8e132b99bfb6eeabcc71490cfc9d4064d84df593feb305121ed3535')

prepare() {
  cp -a "pymongo-$pkgver" "pymongo2-$pkgver"
}

build() {
  cd "$srcdir/pymongo-$pkgver"
  python setup.py build

  cd "$srcdir/pymongo2-$pkgver"
  python2 setup.py build
}

check() {
  MONGO_TMP_PORT=$(perl -MSocket -le 'socket S, PF_INET, SOCK_STREAM,getprotobyname("tcp");
    $port = 50000;
    ++$port until bind S, sockaddr_in($port,inet_aton("127.1"));
    print $port')
  echo "Picked port $MONGO_TMP_PORT to run tests with."

  # Start a mongod instance for test
  rm -rf "$srcdir/mongo_tmp"
  mkdir "$srcdir/mongo_tmp"
  rm -f "$srcdir/mongo_tmp.pid"
  mongod --bind_ip localhost --port $MONGO_TMP_PORT --dbpath "$srcdir/mongo_tmp" --nojournal \
         --nohttpinterface --noauth --smallfiles --nssize 1 --fork --pidfilepath "$srcdir/mongo_tmp.pid" --logpath "$srcdir/mongo_tmp.log"

  cd "$srcdir/pymongo-$pkgver"
  DB_PORT=$MONGO_TMP_PORT python setup.py test

  cd "$srcdir/pymongo2-$pkgver"
  DB_PORT=$MONGO_TMP_PORT python2 setup.py test

  kill $(cat "$srcdir/mongo_tmp.pid")
}

package_python2-pymongo() {
  depends=('python2')

  cd "pymongo2-$pkgver"
  python2 setup.py install --root="$pkgdir" --skip-build --optimize=1
}

package_python-pymongo() {
  depends=('python')

  cd "pymongo-$pkgver"
  python setup.py install --root="$pkgdir" --skip-build --optimize=1

  # Remove conflicting test folder
  rm -r "$pkgdir/usr/lib/python3.4/site-packages/test"

  # Remove malformed egg-info folder
  rm -r "$pkgdir/usr/lib/python3.4/site-packages/pymongo.egg-info/"
}

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