1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 buildPythonPackage,
6
7 # build-system
8 cmake,
9 nanobind,
10 ninja,
11 numpy,
12 scikit-build-core,
13
14 # buildInputs
15 opencl-headers,
16 pybind11,
17 ocl-icd,
18
19 # dependencies
20 platformdirs,
21 pytools,
22
23 # tests
24 pytestCheckHook,
25 writableTmpDirAsHomeHook,
26 mako,
27 pocl,
28}:
29
30buildPythonPackage rec {
31 pname = "pyopencl";
32 version = "2025.1";
33 pyproject = true;
34
35 src = fetchFromGitHub {
36 owner = "inducer";
37 repo = "pyopencl";
38 tag = "v${version}";
39 fetchSubmodules = true;
40 hash = "sha256-wAZBDPMJbTmujP1j7LjK28ZozZaUwKPDPZLZbFFTeAs=";
41 };
42
43 build-system = [
44 cmake
45 nanobind
46 ninja
47 numpy
48 scikit-build-core
49 ];
50
51 dontUseCmakeConfigure = true;
52
53 buildInputs = [
54 opencl-headers
55 ocl-icd
56 pybind11
57 ];
58
59 dependencies = [
60 numpy
61 platformdirs
62 pytools
63 ];
64
65 nativeCheckInputs = [
66 pocl
67 mako
68 pytestCheckHook
69 writableTmpDirAsHomeHook
70 ] ++ pytools.optional-dependencies.siphash;
71
72 env = {
73 CL_INC_DIR = "${opencl-headers}/include";
74 CL_LIB_DIR = "${ocl-icd}/lib";
75 CL_LIBNAME = "${ocl-icd}/lib/libOpenCL${stdenv.hostPlatform.extensions.sharedLibrary}";
76 };
77
78 preCheck = ''
79 rm -rf pyopencl
80 '';
81
82 pythonImportsCheck = [
83 "pyopencl"
84 "pyopencl.array"
85 "pyopencl.cltypes"
86 "pyopencl.compyte"
87 "pyopencl.elementwise"
88 "pyopencl.tools"
89 ];
90
91 meta = {
92 description = "Python wrapper for OpenCL";
93 homepage = "https://github.com/pyopencl/pyopencl";
94 changelog = "https://github.com/inducer/pyopencl/releases/tag/v${version}";
95 license = lib.licenses.mit;
96 maintainers = with lib.maintainers; [ GaetanLepage ];
97 };
98}