python-lightgbm-cpu-only
LOW
maintainer marco.righi
0 votes
scanned 2026-10-28 09:50:05.638525
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
# CPU-only build of the upstream LightGBM Python distribution.
3
4
pkgname=python-lightgbm-cpu-only
5
pkgver=4.7.0
6
pkgrel=1
7
pkgdesc='LightGBM Python bindings with CPU/OpenMP support, without GPU or CUDA'
8
arch=('x86_64')
9
url='https://github.com/lightgbm-org/LightGBM'
10
license=('MIT')
11
depends=('python' 'python-numpy' 'python-scipy' 'python-narwhals' 'gcc-libs' 'glibc')
12
makedepends=('cmake' 'ninja' 'python-build' 'python-installer' 'python-scikit-build-core' 'binutils')
13
optdepends=(
14
'python-scikit-learn: scikit-learn estimator interface'
15
'python-pandas: pandas DataFrame support'
16
'python-matplotlib: plotting utilities'
17
'python-graphviz: tree visualization'
18
'python-dask: distributed data interfaces'
19
'python-distributed: Dask distributed execution'
20
'python-joblib: optional parallelism helpers'
21
'python-psutil: optional system resource queries'
22
)
23
provides=("python-lightgbm=${pkgver}")
24
conflicts=('python-lightgbm' 'python-lightgbm-cl' 'python-lightgbm-cuda' 'python-lightgbm-nacci')
25
source=("https://files.pythonhosted.org/packages/source/l/lightgbm/lightgbm-${pkgver}.tar.gz")
26
sha256sums=('f8e20f682c9aabd000bcf4a7ed8aa6f473c1adfecccae34ec24e823d156f4af0')
27
28
build() {
29
# Prevent absolute private source paths in C/C++ __FILE__ and debug records.
30
# GCC's -ffile-prefix-map covers both macro and debug path remapping.
31
local prefix_map="-ffile-prefix-map=${srcdir}=/usr/src/${pkgname}-${pkgver}"
32
export CFLAGS="${CFLAGS:-} ${prefix_map}"
33
export CXXFLAGS="${CXXFLAGS:-} ${prefix_map}"
34
cd "${srcdir}/lightgbm-${pkgver}"
35
python -m build --wheel --no-isolation \
36
-Ccmake.define.USE_CUDA=OFF \
37
-Ccmake.define.USE_GPU=OFF \
38
-Ccmake.define.USE_OPENMP=ON
39
}
40
41
check() {
42
local wheel_dir="${srcdir}/wheel-check-lightgbm"
43
install -d "$wheel_dir"
44
python -m zipfile -e "${srcdir}/lightgbm-${pkgver}/dist/"*.whl "$wheel_dir"
45
PYTHONPATH="$wheel_dir" python - <<'PY'
46
import os
47
from pathlib import Path
48
import numpy as np
49
import lightgbm as lgb
50
51
root = Path(os.environ['PYTHONPATH']).resolve()
52
assert Path(lgb.__file__).resolve().is_relative_to(root)
53
assert lgb.__version__ == '4.7.0'
54
X = np.array([[0, 0], [1, 0], [0, 1], [1, 1], [2, 0], [0, 2], [2, 2], [3, 3]], dtype=float)
55
y = np.array([0, 0, 0, 1, 1, 1, 1, 1])
56
train = lgb.Dataset(X, label=y)
57
model = lgb.train({'objective': 'binary', 'verbosity': -1, 'num_threads': 1,
58
'min_data_in_leaf': 1}, train, num_boost_round=3)
59
assert np.isfinite(model.predict(X)).all()
60
print('LightGBM CPU smoke test: PASS')
61
PY
62
local shared_library
63
shared_library="$(find "$wheel_dir/lightgbm" -name 'lib_lightgbm.so' -print -quit)"
64
test -n "$shared_library"
65
if readelf -d "$shared_library" | grep -Ei '(NEEDED.*(cuda|cublas|nccl|OpenCL))'; then
66
echo 'Unexpected GPU dependency in CPU-only LightGBM build' >&2
67
return 1
68
fi
69
}
70
71
package() {
72
cd "${srcdir}/lightgbm-${pkgver}"
73
python -m installer --destdir="${pkgdir}" dist/*.whl
74
# LightGBM uses MIT: Arch requires the actual license text in the package.
75
# Prefer the distribution's own LICENSE; fall back to wheel-installed metadata.
76
local license_src=""
77
local candidate
78
for candidate in \
79
"${srcdir}/lightgbm-${pkgver}/LICENSE" \
80
"${srcdir}/lightgbm-${pkgver}/python-package/LICENSE" \
81
"${srcdir}/lightgbm-${pkgver}/lightgbm/LICENSE"; do
82
if [[ -f "$candidate" ]]; then
83
license_src="$candidate"
84
break
85
fi
86
done
87
if [[ -z "$license_src" ]]; then
88
license_src="$(find "${pkgdir}/usr/lib" -type f \
89
-path '*/lightgbm-*.dist-info/licenses/LICENSE' -print -quit)"
90
fi
91
if [[ -z "$license_src" || ! -f "$license_src" ]]; then
92
echo 'ERROR: LightGBM MIT LICENSE not found in distribution; refusing incomplete package' >&2
93
return 1
94
fi
95
install -Dm644 "$license_src" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
96
}
97
Scan history
| Scanned at (UTC) | Severity | Rules |
|---|---|---|
| 2026-10-28 09:50:05 | Low | 1 |