1{ lib
2, rustPlatform
3, python
4, fetchpatch
5, fetchFromGitHub
6, pipInstallHook
7, maturin
8, pip
9 # Check inputs
10, pytestCheckHook
11, numpy
12}:
13
14rustPlatform.buildRustPackage rec {
15 pname = "retworkx";
16 version = "0.4.0";
17
18 src = fetchFromGitHub {
19 owner = "Qiskit";
20 repo = "retworkx";
21 rev = version;
22 sha256 = "1xqp6d39apkjvd0ad9vw81cp2iqzhpagfa4p171xqm3bwfn2imdc";
23 };
24
25 cargoSha256 = "0bma0l14jv5qhcsxck7vw3ak1w3c8v84cq4hii86i4iqk523zns5";
26 cargoPatches = [
27 ( fetchpatch {
28 name = "retworkx-cargo-lock.patch";
29 url = "https://github.com/Qiskit/retworkx/commit/a02fd33d357a92dbe9530696a6d85aa59fe8a5b9.patch";
30 sha256 = "0gvxr1nqp9ll4skfks4p4d964pshal25kb1nbfzhpyipnzddizr5";
31 } )
32 ];
33
34 propagatedBuildInputs = [ python ];
35
36 nativeBuildInputs = [ pipInstallHook maturin pip ];
37
38 # Need to check AFTER python wheel is installed (b/c using Rust Build, not buildPythonPackage)
39 doCheck = false;
40 doInstallCheck = true;
41
42 buildPhase = ''
43 runHook preBuild
44 maturin build --release --manylinux off --strip --interpreter ${python.interpreter}
45 runHook postBuild
46 '';
47
48 installPhase = ''
49 install -Dm644 -t dist target/wheels/*.whl
50 pipInstallPhase
51 '';
52
53 installCheckInputs = [ pytestCheckHook numpy ];
54 preCheck = ''
55 export TESTDIR=$(mktemp -d)
56 cp -r $TMP/$sourceRoot/tests $TESTDIR
57 pushd $TESTDIR
58 '';
59 postCheck = "popd";
60
61 meta = with lib; {
62 description = "A python graph library implemented in Rust.";
63 homepage = "https://retworkx.readthedocs.io/en/latest/index.html";
64 downloadPage = "https://github.com/Qiskit/retworkx/releases";
65 changelog = "https://github.com/Qiskit/retworkx/releases/tag/${version}";
66 license = licenses.asl20;
67 maintainers = with maintainers; [ drewrisinger ];
68 };
69}