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