# Maintainer: Andrew Crerar <crerar@archlinux.org>
# Maintainer: Morten Linderud <foxboron@archlinux.org>
# Contributor: Felix Yan <felixonmars@archlinux.org>
# Contributor: Hideaki Takahashi <mymelo+aur@gmail.com>
# Contributor: Vincent Demeester <vincent@sbr.io>
# Contributor: Josh VanderLinden <arch@cloudlery.com>

pkgname=python-docker
pkgver=7.0.0
pkgrel=1
pkgdesc="A Python library for the Docker Engine API"
arch=('any')
url="https://github.com/docker/docker-py"
license=("Apache")
depends=('python-packaging' 'python-requests' 'python-urllib3' 'python-websocket-client')
makedepends=('python-build' 'python-installer' 'python-setuptools' 'python-setuptools-scm' 'python-wheel')
checkdepends=('flake8' 'python-coverage' 'python-paramiko' 'python-pytest'
'python-pytest-cov' 'python-pytest-timeout')
optdepends=('python-paramiko: for connections using the SSH protocol')
provides=('python-docker-py')
conflicts=('python-docker-py')
replaces=('python-docker-py')
source=("$pkgname-$pkgver.tar.gz::https://github.com/docker/docker-py/archive/$pkgver.tar.gz")
b2sums=('64df988c8ece4fc0199731206b7f85554841e4c60ea10f1044c1d5f0dc52286e9da36280bfc468933bbae1f8efaa0fd44afaedf732001cd3d7a2c05879d6a467')

prepare() {
  sed -i 's/==.*$//' docker-py-"$pkgver"/{,test-}requirements.txt
}

build() {
  cd docker-py-"$pkgver"
  export SETUPTOOLS_SCM_PRETEND_VERSION=$pkgver
  python -m build --wheel --no-isolation
}

check() {
  cd docker-py-"$pkgver"
  py.test --cov=docker tests/unit
}

package() {
  cd docker-py-"$pkgver"
  python -m installer --destdir="$pkgdir" dist/*.whl
}
