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