python-xgboost-cpu-only

LOW
maintainer marco.righi 0 votes scanned 2026-10-28 09:50:05.638525
View on AUR
Why flagged

Uploaded within the last 14 days with 2 or fewer community votes — little peer review so far.

Triggered rules

Low Few votes, recently uploaded zero_votes_recent

Uploaded within the last 14 days with 2 or fewer community votes — little peer review so far.

PKGBUILD

1# Maintainer: Marco Righi <marco.righi@gmail.com>
2# XGBoost Python, CPU only: use upstream CPU variant metadata and build flags.
3
4pkgname=python-xgboost-cpu-only
5pkgver=3.4.1
6pkgrel=1
7pkgdesc='XGBoost Python bindings built from source for CPU/OpenMP, without CUDA or NCCL'
8arch=('x86_64')
9url='https://github.com/dmlc/xgboost'
10license=('Apache-2.0')
11depends=('python' 'python-numpy' 'python-scipy' 'gcc-libs' 'glibc')
12makedepends=('cmake' 'ninja' 'python-build' 'python-installer' 'python-scikit-build-core' 'python-packaging' 'binutils')
13optdepends=(
14 'python-pandas: pandas DataFrame support'
15 'python-scikit-learn: scikit-learn estimator interface'
16 'python-matplotlib: plotting utilities'
17 'python-graphviz: tree visualization'
18 'python-pyarrow: Arrow table input'
19 'python-dask: Dask integration'
20 'python-distributed: Dask cluster execution'
21 'python-packaging: optional Dask integration'
22)
23provides=("python-xgboost=${pkgver}" "python-xgboost-cpu=${pkgver}")
24conflicts=('python-xgboost' 'python-xgboost-cuda' 'python-xgboost-git' 'python-xgboost-cpu-nacci')
25source=("xgboost-src-${pkgver}.tar.gz::https://github.com/dmlc/xgboost/releases/download/v${pkgver}/xgboost-src-${pkgver}.tar.gz")
26sha256sums=('34a5cb99a67bb98b44f204767eeeae642b65a86b2ecfca60082e4d74fd4d169a')
27
28prepare() {
29 cd "${srcdir}/xgboost"
30 # Official upstream generator creates xgboost-cpu metadata and removes
31 # the dependency on NCCL from the Python distribution.
32 PYTHONPATH="${srcdir}/xgboost/ops/script" \
33 python ops/script/pypi_variants.py --use-suffix=cpu --require-nccl-dep=na
34 grep -q '^name = "xgboost-cpu"' python-package/pyproject.toml
35 if grep -q 'nvidia-nccl' python-package/pyproject.toml; then
36 echo 'Unexpected NCCL dependency in xgboost-cpu metadata' >&2
37 return 1
38 fi
39}
40
41build() {
42 # Prevent absolute private source paths in C/C++ __FILE__ and debug records.
43 # GCC's -ffile-prefix-map covers both macro and debug path remapping.
44 local prefix_map="-ffile-prefix-map=${srcdir}=/usr/src/${pkgname}-${pkgver}"
45 export CFLAGS="${CFLAGS:-} ${prefix_map}"
46 export CXXFLAGS="${CXXFLAGS:-} ${prefix_map}"
47 cd "${srcdir}/xgboost/python-package"
48 python -m build --wheel --no-isolation \
49 -Ccmake.define.USE_CUDA=OFF \
50 -Ccmake.define.USE_NCCL=OFF \
51 -Ccmake.define.PLUGIN_FEDERATED=OFF \
52 -Ccmake.define.USE_OPENMP=ON
53}
54
55check() {
56 local wheel_dir="${srcdir}/wheel-check-xgboost"
57 install -d "$wheel_dir"
58 python -m zipfile -e "${srcdir}/xgboost/python-package/dist/"*.whl "$wheel_dir"
59 PYTHONPATH="$wheel_dir" python - <<'PY'
60import os
61from pathlib import Path
62import numpy as np
63import xgboost as xgb
64
65root = Path(os.environ['PYTHONPATH']).resolve()
66assert Path(xgb.__file__).resolve().is_relative_to(root)
67assert xgb.__version__ == '3.4.1'
68X = np.array([[0,0], [1,0], [0,1], [1,1], [2,0], [0,2], [2,2], [3,3]], dtype=float)
69y = np.array([0, 0, 0, 1, 1, 1, 1, 1])
70model = xgb.train({'objective': 'binary:logistic', 'tree_method': 'hist',
71 'device': 'cpu', 'nthread': 1},
72 xgb.DMatrix(X, label=y), num_boost_round=3)
73assert np.isfinite(model.predict(xgb.DMatrix(X))).all()
74print('XGBoost CPU smoke test: PASS')
75PY
76 local shared_library
77 shared_library="$(find "$wheel_dir/xgboost" -name 'libxgboost.so' -print -quit)"
78 test -n "$shared_library"
79 if readelf -d "$shared_library" | grep -Ei '(NEEDED.*(cuda|cublas|nccl))'; then
80 echo 'Unexpected GPU dependency in CPU-only XGBoost build' >&2
81 return 1
82 fi
83}
84
85package() {
86 cd "${srcdir}/xgboost/python-package"
87 python -m installer --destdir="${pkgdir}" dist/*.whl
88 # Upstream's test suite is not part of the runtime Python library.
89 local site_packages
90 site_packages="$(python -c 'import sysconfig; print(sysconfig.get_path("purelib"))')"
91 if [[ -d "${pkgdir}${site_packages}/xgboost/testing" ]]; then
92 rm -r -- "${pkgdir}${site_packages}/xgboost/testing"
93 fi
94 # Apache-2.0 is a shared SPDX license, but retain upstream license text.
95 if [[ -f "${srcdir}/xgboost/LICENSE" ]]; then
96 install -Dm644 "${srcdir}/xgboost/LICENSE" \
97 "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
98 fi
99}
100

Scan history

Scanned at (UTC)SeverityRules
2026-10-28 09:50:05 Low 1

Report a package

Reports go to the AURWatch maintainer (one person) and are read by hand. No login required.

0 / 4000
Your suggestion