summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: c55cfab5c91366b309eff0efe75dcf03a09d3035 (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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# Maintainer: Konstantin Gizdov <arch at kge dot pw>
# Contributor: Astro Benzene <universebenzene at sina dot com>
_pkgname=iminuit
pkgbase="python-${_pkgname}"
pkgname=("python-${_pkgname}" "python-${_pkgname}-docs")
pkgver=2.32.0
pkgrel=1
pkgdesc="Python interface for MINUIT, a physics analysis tool for function minimization."
arch=('x86_64')
url="https://iminuit.readthedocs.io"
license=('MIT AND LGPL-2.1-or-later')
makedepends=(
  'git'
  'cmake'
  'pandoc'
  'pybind11'
  'python-boost-histogram'
  'python-build'
  'python-installer'
  'python-ipykernel'
  'python-ipywidgets'
  'python-joblib'
  'python-matplotlib'
  'python-nbsphinx'
  'python-numba'
  'python-numpy'
  'python-pillow'
  'python-sphinx_rtd_theme'
  'python-scikit-build-core'
)
checkdepends=('python-pytest' 'python-scipy' 'python-tabulate')
options=(!emptydirs)
source=(
  "${pkgbase}::git+https://github.com/scikit-hep/iminuit#tag=v$pkgver"
  "${pkgbase}-root::git+https://github.com/root-project/root.git"
)
sha256sums=('efd123f3c0a8ab6eb515e0b40dc766d16a0e8e74b10bf0e1889a70d23b4698df'
            'SKIP')

_get_pyver () {
    python -c 'import sys; print(str(sys.version_info[0]) + "." + str(sys.version_info[1]))'
}

_get_cpyver () {
    python -c 'import sys; print(str(sys.version_info[0]) + str(sys.version_info[1]))'
}

prepare() {
  cd "${pkgbase}"
  git submodule init

  git config submodule."extern/root".url "${srcdir}/${pkgname}"-root

  # root submodule reference is broken, fix it
  git -c protocol.file.allow=always submodule update --init --recursive

  # python-cmake is not needed
  sed -i '/cmake/d' pyproject.toml
}

build() {
  cd "${pkgbase}"

  # build against system pybind11
  export CMAKE_ARGS='-DIMINUIT_EXTERNAL_PYBIND11=ON'
  python -m build --wheel --no-isolation

  # NOTE: building docs is broken because numba* is not compatible with Python 3.11 and fails to install/build in a venv
  # # build docs
  # python -m venv --system-site-packages test-env
  # test-env/bin/python -m pip install numba-stats resample
  # echo 'nbsphinx_allow_errors = True' >> doc/conf.py
  # PYTHONPATH="${PWD}/test-env/lib/python$(_get_pyver)/site-packages:${PWD}/build/lib.linux-${CARCH}-cpython-$(_get_cpyver)" make build/html/done

  # NOTE: this is an attempt at building it with system dependencies, unfortunately there are issues with importing nbconvert.RSTExporter() for some reason...
  # local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")
  # python -m installer --destdir=test_dir dist/*.whl
  # export PYTHONPATH="test_dir/$site_packages:$PYTHONPATH"
  # sphinx-build -v -W -b html -d build/doctrees doc build/html
}

check() {
  local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")

  cd $pkgbase
  # install to temporary location, as importlib is used
  python -m installer --destdir=test_dir dist/*.whl
  export PYTHONPATH="test_dir/$site_packages:$PYTHONPATH"
  pytest -vv
}

package_python-iminuit() {
  depends=(
    'gcc-libs'
    'glibc'
    'python'
    'python-numpy'
  )
  optdepends=(
    'python-iminuit-docs: Documentation for python-iminuit'
    'python-ipython: for plotting'
    'python-ipywidgets: for plotting'
    'python-matplotlib: for drawing operations'
    'python-progressbar: for progressbar support'
    'python-scipy: for scipy minimizers'
  )

  cd "${pkgname}"

  install -D -m644 LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}"
  install -D -m644 README.rst -t "${pkgdir}/usr/share/doc/${pkgname}"
  python -m installer --destdir="${pkgdir}" dist/*.whl
}

package_python-iminuit-docs() {
  cd "${pkgbase}"

  install -d -m755 "${pkgdir}/usr/share/doc/${pkgname}"
  # NOTE: there's currently nothing to install... consider dropping as online documentation exists
  # cp -a build/html "${pkgdir}/usr/share/doc/${pkgname}"
  install -Dm644 -t "${pkgdir}/usr/share/licenses/${pkgname}" LICENSE
}