# pyopencl -- Python wrapper for OpenCL; BabelBrain's compute backend on Linux # without CUDA (pocl gives it a CPU device). # # CLASS 2 (compatible update) under docs/PACKAGING-POLICY.md. Fedora's # python3-pyopencl 2025.2.6 cannot be imported on f44, f45 or rawhide, for two # independent reasons, both verified 2026-10-11 against the published rpm: # 1. its %%prep seds the declared `pytools>=2025.1.6` down to `pytools`, so it # installs against Fedora's pytools 2024.1.3 and dies with # ImportError: cannot import name 'Hash' from 'pytools' (Bugzilla 2432626); # 2. the rpm contains no pyopencl/compyte/ at all (0 files), although the # sdist has it, so after (1) the next failure is # ModuleNotFoundError: No module named 'pyopencl.compyte'. # This package follows Fedora's spec otherwise, keeps the pytools floor (met by # python-pytools in this Copr), asserts in %%check that compyte is packaged and # that a kernel runs on pocl, and should be dropped when Fedora's works. The # fix belongs in dist-git; Morgan files it (bug 2432626 is the place). # 2026.1.2 is the newest release that builds with nanobind 2.x; 2026.1.3+ # require nanobind >= 3.0 and Fedora ships 2.11 (f44) / 2.12 (f45, rawhide). %global srcname pyopencl Name: python-%{srcname} Version: 2026.1.2 Release: 1%{?dist} Summary: Python wrapper for OpenCL # MIT (pyopencl), with bundled OpenCL sources: Boost (pyopencl-bessel-*.cl, # pyopencl-eval-tbl.cl), cephes under GPLv2 (pyopencl-airy.cl, parts of the # bessel/eval-tbl files), Apache-2.0 (scan.py), BSD-3-Clause (random123, # bitonic_sort*). Same set as Fedora's spec, in SPDX form. License: MIT AND BSL-1.0 AND GPL-2.0-only AND Apache-2.0 AND BSD-3-Clause URL: https://mathema.tician.de/software/pyopencl Source0: %{pypi_source} # pyopencl/cl/pyopencl-bessel-[j,y].cl and pyopencl-eval-tbl.cl contain code # from boost and cephes; pyopencl-airy.cl from cephes. Provides: bundled(boost-math) Provides: bundled(cephes) = 2.8 # pyopencl/cl/pyopencl-random123/ Provides: bundled(random123) # pyopencl/compyte/ (a git submodule upstream) Provides: bundled(compyte) BuildRequires: gcc-c++ BuildRequires: boost-devel BuildRequires: opencl-headers BuildRequires: ocl-icd-devel BuildRequires: pkgconfig(libffi) BuildRequires: pkgconfig(gl) BuildRequires: python3-devel BuildRequires: python3-nanobind BuildRequires: python3-pytools >= 2025.1.6 # %%check compiles and runs a kernel on pocl's CPU device; algorithm, scan and # bitonic_sort import mako (upstream recommends it). BuildRequires: pocl BuildRequires: python3-mako %description PyOpenCL makes it possible to access GPUs and other massively parallel compute devices from Python. Specifically, PyOpenCL provides Pythonic access to the OpenCL parallel computation API in a manner similar to the sister project PyCUDA. %package -n python3-%{srcname} Summary: Python 3 wrapper for OpenCL Requires: python3-pytools >= 2025.1.6 Recommends: python3dist(mako) %description -n python3-%{srcname} Python 3 version of python-pyopencl. %prep %autosetup -n %{srcname}-%{version} -p1 rm -vrf *.egg-info rm -vf examples/download-examples-from-wiki.py test -f pyopencl/compyte/dtypes.py %generate_buildrequires %pyproject_buildrequires -p %build export PYOPENCL_ENABLE_GL=ON PYOPENCL_PRETEND_CL_VERSION=1.2 %pyproject_wheel -Ccmake.build-type="RelWithDebInfo" %install %pyproject_install %pyproject_save_files %{srcname} find %{buildroot}%{python3_sitearch}/%{srcname} -name '*.so' -exec chmod 755 {} \+ # Fedora's 2025.2.6 rpm shipped no compyte; make sure this one does. test -f %{buildroot}%{python3_sitearch}/%{srcname}/compyte/dtypes.py %check %pyproject_check_import -e pyopencl.ipython_ext -e 'pyopencl.compyte.ndarray*' cd / # The two imports that fail with Fedora's package, then a kernel on pocl. PYTHONPATH=%{buildroot}%{python3_sitearch} %{python3} -c ' import pyopencl as cl import pyopencl.compyte.dtypes import numpy as np devs = [d for p in cl.get_platforms() for d in p.get_devices()] print("devices:", [(d.platform.name, d.name) for d in devs]) assert devs, "no OpenCL device: is pocl installed and its ICD registered?" ctx = cl.Context([devs[0]]) q = cl.CommandQueue(ctx) a = np.arange(1024, dtype=np.float32) buf = cl.Buffer(ctx, cl.mem_flags.READ_WRITE | cl.mem_flags.COPY_HOST_PTR, hostbuf=a) prg = cl.Program(ctx, "__kernel void twice(__global float *a) { int i = get_global_id(0); a[i] = 2.0f * a[i]; }").build() prg.twice(q, a.shape, None, buf) out = np.empty_like(a); cl.enqueue_copy(q, out, buf); q.finish() assert np.array_equal(out, 2 * a), out[:8] print("kernel ran on", devs[0].name)' %files -n python3-%{srcname} -f %{pyproject_files} %license LICENSE %doc examples %changelog * Sun Oct 11 2026 Morgan Hough - 2026.1.2-1 - Carry pyopencl 2026.1.2 (the last release building with nanobind 2.x) because Fedora's 2025.2.6 cannot be imported: it drops the pytools >= 2025.1.6 floor (Bugzilla 2432626) and ships no pyopencl/compyte. Class-2 compatible update per docs/PACKAGING-POLICY.md, to be dropped when Fedora's package imports. %%check asserts compyte is packaged and runs a kernel on pocl. Needed for babelbrain's OpenCL backend.