1{
2 lib,
3 fetchFromGitHub,
4 buildPythonPackage,
5 pytestCheckHook,
6 stdenv,
7 pythonOlder,
8 setuptools,
9 cmake,
10 ninja,
11 wheel,
12 matio,
13 eigen,
14 gtest,
15 cpu_features,
16 pybind11,
17 python,
18 numpy,
19 scipy,
20}:
21buildPythonPackage rec {
22 pname = "piqp";
23 version = "0.4.2";
24 pyproject = true;
25
26 disabled = pythonOlder "3.7";
27
28 src = fetchFromGitHub {
29 owner = "PREDICT-EPFL";
30 repo = "piqp";
31 tag = "v${version}";
32 hash = "sha256-/lADjg4NyDdV9yeYBW2gbPydY8TfV247B/dI/ViRVlI=";
33 };
34
35 postPatch =
36 let
37 # E.g. 3.11.2 -> "311"
38 pythonVersionMajorMinor =
39 with lib.versions;
40 "${major python.pythonVersion}${minor python.pythonVersion}";
41
42 # E.g. "linux-aarch64"
43 platform =
44 with stdenv.hostPlatform;
45 (lib.optionalString (!isDarwin) "${parsed.kernel.name}-${parsed.cpu.name}")
46 + (lib.optionalString isDarwin "macosx-${darwinMinVersion}-${darwinArch}");
47 in
48 ''
49 build="build/temp.${platform}-cpython-${pythonVersionMajorMinor}/${pname}.${pname}"
50 mkdir -p $build/_deps
51 ln -s ${cpu_features.src} $build/_deps/cpu_features-src
52 '';
53
54 patches = [ ./use-nix-packages.patch ];
55
56 build-system = [
57 setuptools
58 cmake
59 ninja
60 wheel
61 ];
62
63 buildInputs = [
64 matio
65 eigen
66 gtest
67 pybind11
68 ];
69
70 dontUseCmakeConfigure = true;
71
72 pythonImportsCheck = [ "piqp" ];
73
74 nativeCheckInputs = [
75 pytestCheckHook
76 numpy
77 scipy
78 ];
79
80 meta = with lib; {
81 description = "A Proximal Interior Point Quadratic Programming solver";
82 homepage = "https://github.com/PREDICT-EPFL/piqp";
83 license = licenses.bsd2;
84 maintainers = with maintainers; [ renesat ];
85 };
86}