summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 061c15ad75160926feded12e74bdf7a53f9da992 (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
# -*- mode: shell-script -*-
# Maintainer: Dylon Edwards <deltaecho at archlinux dot us>

pkgbase='python-tensorly'
pkgname=(
    python{,2}-tensorly
)
pkgver=0.3.0
pkgrel=1
pkgdesc="Simple and Fast Tensor Learning in Python"
arch=('x86_64')
url="http://tensorly.org/stable/home.html"
license=('BSD')
depends=(
    python{,2}
)
checkdepends=(
    python{,2}-pytest
)
optdepends=(
    mxnet
    python{,2}-numpy
    python{,2}-pytorch{,-cuda}
)
changelog="${pkgbase}.changelog"
source=("tensorly-${pkgver}.tar.gz::https://github.com/tensorly/tensorly/archive/${pkgver}.tar.gz")
md5sums=('d2bb823c87246b4ff45a175f984beb3d')

function check() {
    cd "tensorly-${pkgver}"

    # ------- #
    # Python3 #
    # ------- #

    if pacman -Qsq '^python-numpy$' &>/dev/null; then
        echo "Testing against the numpy backend for Python3 ..."
        TENSORLY_BACKEND='numpy' pytest -v tensorly
    fi

    if pacman -Qsq '^python-pytorch(-cuda)?$' &>/dev/null; then
        echo "Testing against the pytorch backend for Python3 ..."
        TENSORLY_BACKEND='pytorch' pytest -v tensorly
    fi

    if pacman -Qsq '^mxnet$' &>/dev/null; then
        echo "Testing against the mxnet backend for Python3 ..."
        TENSORLY_BACKEND='mxnet' pytest -v tensorly
    fi

    # ------- #
    # Python2 #
    # ------- #

    if pacman -Qsq '^python2-numpy$' &>/dev/null; then
        echo "Testing against the numpy backend for Python2 ..."
        TENSORLY_BACKEND='numpy' pytest2 -v tensorly
    fi

    if pacman -Qsq '^python2-pytorch(-cuda)?$' &>/dev/null; then
        echo "Testing against the pytorch backend for Python2 ..."
        TENSORLY_BACKEND='pytorch' pytest2 -v tensorly
    fi
}

function package_python-tensorly() {
    depends=(
        python
    )
    optdepends=(
        mxnet
        python-numpy
        python-pytorch{,-cuda}
    )

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

function package_python2-tensorly() {
    depends=(
        python2
    )
    optdepends=(
        python2-numpy
        python2-pytorch{,-cuda}
    )

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