1{ lib
2, pythonOlder
3, buildPythonPackage
4, fetchFromGitHub
5, cvxpy
6, dlx
7, docplex
8, fastdtw
9, h5py
10, networkx
11, numpy
12, psutil
13, python
14, qiskit-ignis
15, qiskit-terra
16, quandl
17, scikit-learn
18, yfinance
19 # Optional inputs
20, withTorch ? false
21, pytorch
22, withPyscf ? false
23, pyscf ? null
24, withScikitQuant ? false
25, scikit-quant ? null
26, withCplex ? false
27, cplex ? null
28 # Check Inputs
29, ddt
30, pytestCheckHook
31, pytest-timeout
32, qiskit-aer
33}:
34
35buildPythonPackage rec {
36 pname = "qiskit-aqua";
37 version = "0.9.0";
38
39 disabled = pythonOlder "3.6";
40
41 # Pypi's tarball doesn't contain tests
42 src = fetchFromGitHub {
43 owner = "Qiskit";
44 repo = "qiskit-aqua";
45 rev = version;
46 hash = "sha256-knue9uJih72UQHsvfXZ9AA94mol4ERa9Lo/GMcp+2hA=";
47 };
48
49 # Optional packages: pyscf (see below NOTE) & pytorch. Can install via pip/nix if needed.
50 propagatedBuildInputs = [
51 cvxpy
52 docplex
53 dlx # Python Dancing Links package
54 fastdtw
55 h5py
56 networkx
57 numpy
58 psutil
59 qiskit-terra
60 qiskit-ignis
61 quandl
62 scikit-learn
63 yfinance
64 ] ++ lib.optionals (withTorch) [ pytorch ]
65 ++ lib.optionals (withPyscf) [ pyscf ]
66 ++ lib.optionals (withScikitQuant) [ scikit-quant ]
67 ++ lib.optionals (withCplex) [ cplex ];
68
69 # *** NOTE ***
70 # We make pyscf optional in this package, due to difficulties packaging it in Nix (test failures, complicated flags, etc).
71 # See nixpkgs#78772, nixpkgs#83447. You are welcome to try to package it yourself,
72 # or use the Nix User Repository version (https://github.com/drewrisinger/nur-packages).
73 # It can also be installed at runtime from the pip wheel.
74 # We disable appropriate tests below to allow building without pyscf installed
75
76 postPatch = ''
77 # Because this is a legacy/final release, the maintainers restricted the maximum
78 # versions of all dependencies to the latest current version. That will not
79 # work with nixpkgs' rolling release/update system.
80 # Unlock all versions for compatibility
81 substituteInPlace setup.py --replace "<=" ">="
82 sed -i 's/\(\w\+-*\w*\).*/\1/' requirements.txt
83 substituteInPlace requirements.txt --replace "dataclasses" ""
84
85 # Add ImportWarning when running qiskit.chemistry (pyscf is a chemistry package) that pyscf is not included
86 echo -e "\nimport warnings\ntry: import pyscf;\nexcept ImportError:\n " \
87 "warnings.warn('pyscf is not supported on Nixpkgs so some qiskit features will fail." \
88 "You must install it yourself via pip or add it to your environment from the Nix User Repository." \
89 "See https://github.com/NixOS/nixpkgs/pull/83447 for details', ImportWarning)\n" \
90 >> qiskit/chemistry/__init__.py
91
92 # Add ImportWarning when running qiskit.optimization that cplex (optimization package) is not included
93 echo -e "\nimport warnings\ntry: import cplex;\nexcept ImportError:\n " \
94 "warnings.warn('cplex is not supported on Nixpkgs so some qiskit features will fail." \
95 "You must install it yourself via pip or add it to your environment from the Nix User Repository." \
96 "', ImportWarning)\n" \
97 >> qiskit/optimization/__init__.py
98 '';
99
100 postInstall = "rm -rf $out/${python.sitePackages}/docs"; # Remove docs dir b/c it can cause conflicts.
101
102 checkInputs = [
103 pytestCheckHook
104 ddt
105 pytest-timeout
106 qiskit-aer
107 ];
108 pythonImportsCheck = [
109 "qiskit.aqua"
110 "qiskit.aqua.algorithms"
111 "qiskit.chemistry"
112 "qiskit.finance"
113 "qiskit.ml"
114 "qiskit.optimization"
115 ];
116 pytestFlagsArray = [
117 "--timeout=30"
118 "--durations=10"
119 ] ++ lib.optionals (!withPyscf) [
120 "--ignore=test/chemistry/test_qeom_ee.py"
121 "--ignore=test/chemistry/test_qeom_vqe.py"
122 "--ignore=test/chemistry/test_vqe_uccsd_adapt.py"
123 "--ignore=test/chemistry/test_bopes_sampler.py"
124 ];
125 disabledTests = [
126 # Disabled due to missing pyscf
127 "test_validate" # test/chemistry/test_inputparser.py
128
129 # Online tests
130 "test_exchangedata"
131 "test_yahoo"
132
133 # Disabling slow tests > 10 seconds
134 "TestVQE"
135 "TestOOVQE"
136 "TestVQC"
137 "TestQSVM"
138 "TestOptimizerAQGD"
139 "test_graph_partition_vqe"
140 "TestLookupRotation"
141 "_vqe"
142 "TestHHL"
143 "TestQGAN"
144 "test_evaluate_qasm_mode"
145 "test_measurement_error_mitigation_auto_refresh"
146 "test_wikipedia"
147 "test_shor_factoring_1__15___qasm_simulator____3__5__"
148 "test_readme_sample"
149 "test_ecev"
150 "test_expected_value"
151 "test_qubo_gas_int_paper_example"
152 "test_shor_no_factors_1_5"
153 "test_shor_no_factors_2_7"
154 "test_evolve_2___suzuki___1__3_"
155 "test_delta"
156 "test_swaprz"
157 "test_deprecated_algo_result"
158 "test_unsorted_grouping"
159 "test_ad_hoc_data"
160 "test_nft"
161 "test_oh"
162 "test_confidence_intervals_00001"
163 "test_eoh"
164 "test_qasm_5"
165 "test_uccsd_hf"
166 ];
167
168 meta = with lib; {
169 description = "An extensible library of quantum computing algorithms";
170 homepage = "https://github.com/QISKit/qiskit-aqua";
171 changelog = "https://qiskit.org/documentation/release_notes.html";
172 license = licenses.asl20;
173 maintainers = with maintainers; [ drewrisinger ];
174 };
175}