summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 3eb93c4e44b6105e5fae04709170dbea199c45ac (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
# Maintainer: Blair Bonnett <blair dot bonnett at gmail dot com>
# Contributor: Sebastiaan Lokhorst <sebastiaanlokhorst@gmail.com>
# Contributor: Tommy Li <ttoo74@gmail.com>
# Contributor: Mark Lee <mark at markelee dot com>

pkgname=jupyterhub
pkgver=1.4.0
pkgrel=1
pkgdesc="Multi-user server for Jupyter notebooks "
url="https://jupyter.org/hub"
arch=(any)
license=('BSD')
depends=(
  'ipython' 'nodejs-configurable-http-proxy' 'python-alembic'
  'python-async_generator' 'python-certipy' 'python-entrypoints' 'python-jinja'
  'python-jsonschema' 'python-jupyter_telemetry' 'python-oauthlib'
  'python-pamela' 'python-prometheus_client' 'python-requests'
  'python-sqlalchemy' 'python-tornado'
)
makedepends=(
  'npm' 'python-setuptools'
)
checkdepends=(
  'jupyter-notebook' 'python-beautifulsoup4' 'python-pytest'
  'python-pytest-asyncio' 'python-requests-mock'
)
optdepends=(
  'jupyter-notebook: standard notebook server'
  'jupyterlab: to use the JupyterLab interface'
)
install=jupyterhub.install
backup=(
  'etc/jupyterhub/jupyterhub_config.py'
)
source=(
  "jupyterhub-${pkgver}.tar.gz::https://github.com/jupyterhub/jupyterhub/archive/${pkgver}.tar.gz"
  'jupyterhub.service'
)
sha256sums=(
  'fc1f52d7073e65cf7e93caff87ebc3eeff65cd18e0aaa734ffaa0c00cbe6a352'
  'adb4c09c668c35605d9cddc4a4171dd64ed6e74ab82da97f19b3437d26b052b9'
)

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

  # Generate the default configuration. The value of data_files_path is set
  # based on the directory containing the loaded code, so we need to replace
  # it with the final installed destination.
  cd build/lib
  python -m jupyterhub --generate-config -f "$srcdir/default_config.py" -y=true
  _srcdir_esc="${srcdir////\\/}"
  sed -i -e "s/${_srcdir_esc}\/jupyterhub-$pkgver/\/usr/" "$srcdir/default_config.py"
}

check() {
  cd "${srcdir}/jupyterhub-$pkgver"

  # Run the tests we can. The DB upgrade tests always fail for me (it looks
  # like the virtual environment they set up is not complete) and the others
  # intermittently fail. We'll have to trust the upstream CI on those.
  PYTHONPATH="$PWD/build/lib" pytest -v jupyterhub/tests \
    --ignore=jupyterhub/tests/test_db.py \
    -k "not test_external_service and not test_single_user_spawner"
}

package() {
  cd "${srcdir}/jupyterhub-$pkgver"
  install -Dm644 COPYING.md "${pkgdir}"/usr/share/licenses/$pkgname/COPYING.md

  # Something in the test suite writes byte code with $srcdir references, even
  # if we set PYTHONDONTWRITEBYTECODE=1. Just remove the caches. This also
  # covers anything written when generating the default config.
  find . -name "*.pyc" -delete
  find . -type d -name __pycache__ -delete

  # Install the package.
  python setup.py install --root="${pkgdir}" --prefix=/usr --skip-build --optimize=1

  # Remove $srcdir references from (1) npm metadata and (2) Python egg metadata.
  find "$pkgdir" -name package.json -print0 | xargs -r -0 sed -i '/_where/d'
  _srcdir_esc="${srcdir////\\/}"
  find "$pkgdir" -name SOURCES.txt -exec sed -i "/${_srcdir_esc}/d" {} \;

  # systemd service and default configuration.
  install -Dm644 "$srcdir/jupyterhub.service" "$pkgdir/usr/lib/systemd/system/jupyterhub.service"
  install -Dm644 "$srcdir/default_config.py" "$pkgdir/etc/jupyterhub/jupyterhub_config.py"
}