1{ lib
2, pythonOlder
3, buildPythonPackage
4, fetchFromGitHub
5 # Python requirements
6, cython
7, dill
8, fastjsonschema
9, jsonschema
10, numpy
11, networkx
12, ply
13, psutil
14, python-constraint
15, python-dateutil
16, retworkx
17, scipy
18, sympy
19 # Python visualization requirements, semi-optional
20, ipywidgets
21, matplotlib
22, pillow
23, pydot
24, pygments
25, pylatexenc
26, seaborn
27 # test requirements
28, ddt
29, hypothesis
30, nbformat
31, nbconvert
32, pytestCheckHook
33, python
34}:
35
36buildPythonPackage rec {
37 pname = "qiskit-terra";
38 version = "0.15.1";
39
40 disabled = pythonOlder "3.5";
41
42 src = fetchFromGitHub {
43 owner = "Qiskit";
44 repo = pname;
45 rev = version;
46 sha256 = "1p7y36gj3675dmp05nwi0m9nc7h0bwyimir3ncf9wbkx3crrh99c";
47 };
48
49 nativeBuildInputs = [ cython ];
50
51 propagatedBuildInputs = [
52 dill
53 fastjsonschema
54 jsonschema
55 numpy
56 matplotlib
57 networkx
58 ply
59 psutil
60 python-constraint
61 python-dateutil
62 retworkx
63 scipy
64 sympy
65 # Optional/visualization inputs
66 ipywidgets
67 matplotlib
68 pillow
69 pydot
70 pygments
71 pylatexenc
72 seaborn
73 ];
74
75
76 # *** Tests ***
77 checkInputs = [
78 ddt
79 hypothesis
80 nbformat
81 nbconvert
82 pytestCheckHook
83 ];
84 dontUseSetuptoolsCheck = true; # can't find setup.py, so fails. tested by pytest
85
86 pythonImportsCheck = [
87 "qiskit"
88 "qiskit.transpiler.passes.routing.cython.stochastic_swap.swap_trial"
89 ];
90
91 pytestFlagsArray = [
92 "--ignore=test/randomized/test_transpiler_equivalence.py" # collection requires qiskit-aer, which would cause circular dependency
93 ];
94
95 # Moves tests to $PACKAGEDIR/test. They can't be run from /build because of finding
96 # cythonized modules and expecting to find some resource files in the test directory.
97 preCheck = ''
98 export PACKAGEDIR=$out/${python.sitePackages}
99 echo "Moving Qiskit test files to package directory"
100 cp -r $TMP/$sourceRoot/test $PACKAGEDIR
101 cp -r $TMP/$sourceRoot/examples $PACKAGEDIR
102 cp -r $TMP/$sourceRoot/qiskit/schemas/examples $PACKAGEDIR/qiskit/schemas/
103
104 # run pytest from Nix's $out path
105 pushd $PACKAGEDIR
106 '';
107 postCheck = ''
108 rm -rf test
109 rm -rf examples
110 popd
111 '';
112
113
114 meta = with lib; {
115 description = "Provides the foundations for Qiskit.";
116 longDescription = ''
117 Allows the user to write quantum circuits easily, and takes care of the constraints of real hardware.
118 '';
119 homepage = "https://qiskit.org/terra";
120 downloadPage = "https://github.com/QISKit/qiskit-terra/releases";
121 changelog = "https://qiskit.org/documentation/release_notes.html";
122 license = licenses.asl20;
123 maintainers = with maintainers; [ drewrisinger ];
124 };
125}