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, qiskit-ignis 14, qiskit-terra 15, quandl 16, scikit-learn 17, yfinance 18 # Optional inputs 19, withTorch ? false 20, pytorch 21, withPyscf ? false 22, pyscf 23, withScikitQuant ? false 24, scikit-quant ? null 25, withCplex ? false 26, cplex ? null 27 # Check Inputs 28, ddt 29, pytestCheckHook 30, pytest-timeout 31, qiskit-aer 32}: 33 34buildPythonPackage rec { 35 pname = "qiskit-aqua"; 36 version = "0.9.5"; 37 38 disabled = pythonOlder "3.6"; 39 40 # Pypi's tarball doesn't contain tests 41 src = fetchFromGitHub { 42 owner = "Qiskit"; 43 repo = "qiskit-aqua"; 44 rev = version; 45 sha256 = "sha256-7QmRwlbAVAR5KfM7tuObkb6+UgiuIm82iGWBuqfve08="; 46 }; 47 48 # Optional packages: pyscf (see below NOTE) & pytorch. Can install via pip/nix if needed. 49 propagatedBuildInputs = [ 50 cvxpy 51 docplex 52 dlx # Python Dancing Links package 53 fastdtw 54 h5py 55 networkx 56 numpy 57 psutil 58 qiskit-terra 59 qiskit-ignis 60 quandl 61 scikit-learn 62 yfinance 63 ] ++ lib.optionals (withTorch) [ pytorch ] 64 ++ lib.optionals (withPyscf) [ pyscf ] 65 ++ lib.optionals (withScikitQuant) [ scikit-quant ] 66 ++ lib.optionals (withCplex) [ cplex ]; 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 postPatch = '' 76 # Because this is a legacy/final release, the maintainers restricted the maximum 77 # versions of all dependencies to the latest current version. That will not 78 # work with nixpkgs' rolling release/update system. 79 # Unlock all versions for compatibility 80 substituteInPlace setup.py --replace "<=" ">=" 81 sed -i 's/\(\w\+-*\w*\).*/\1/' requirements.txt 82 substituteInPlace requirements.txt --replace "dataclasses" "" 83 84 # Add ImportWarning when running qiskit.chemistry (pyscf is a chemistry package) that pyscf is not included 85 echo -e "\nimport warnings\ntry: import pyscf;\nexcept ImportError:\n " \ 86 "warnings.warn('pyscf is not supported on Nixpkgs so some qiskit features will fail." \ 87 "You must install it yourself via pip or add it to your environment from the Nix User Repository." \ 88 "See https://github.com/NixOS/nixpkgs/pull/83447 for details', ImportWarning)\n" \ 89 >> qiskit/chemistry/__init__.py 90 91 # Add ImportWarning when running qiskit.optimization that cplex (optimization package) is not included 92 echo -e "\nimport warnings\ntry: import cplex;\nexcept ImportError:\n " \ 93 "warnings.warn('cplex is not supported on Nixpkgs so some qiskit features will fail." \ 94 "You must install it yourself via pip or add it to your environment from the Nix User Repository." \ 95 "', ImportWarning)\n" \ 96 >> qiskit/optimization/__init__.py 97 ''; 98 99 checkInputs = [ 100 pytestCheckHook 101 ddt 102 pytest-timeout 103 qiskit-aer 104 ]; 105 pythonImportsCheck = [ 106 "qiskit.aqua" 107 "qiskit.aqua.algorithms" 108 "qiskit.chemistry" 109 "qiskit.finance" 110 "qiskit.ml" 111 "qiskit.optimization" 112 ]; 113 pytestFlagsArray = [ 114 "--timeout=30" 115 "--durations=10" 116 ]; 117 disabledTestPaths = lib.optionals (!withPyscf) [ 118 "test/chemistry/test_qeom_ee.py" 119 "test/chemistry/test_qeom_vqe.py" 120 "test/chemistry/test_vqe_uccsd_adapt.py" 121 "test/chemistry/test_bopes_sampler.py" 122 ]; 123 disabledTests = [ 124 # TODO: figure out why failing, only fail with upgrade to qiskit-terra > 0.16.1 & qiskit-aer > 0.7.2 125 # In test.aqua.test_amplitude_estimation.TestSineIntegral 126 "test_confidence_intervals_1" 127 "test_statevector_1" 128 129 # fails due to approximation error with latest qiskit-aer? 130 "test_application" 131 132 # Fail on CI for some reason, not locally 133 "test_binary" 134 135 # Online tests 136 "test_exchangedata" 137 "test_yahoo" 138 139 # Disabling slow tests > 10 seconds 140 "TestVQE" 141 "TestOOVQE" 142 "TestVQC" 143 "TestQSVM" 144 "TestOptimizerAQGD" 145 "test_graph_partition_vqe" 146 "TestLookupRotation" 147 "_vqe" 148 "TestHHL" 149 "TestQGAN" 150 "test_evaluate_qasm_mode" 151 "test_measurement_error_mitigation_auto_refresh" 152 "test_wikipedia" 153 "test_shor_factoring_1__15___qasm_simulator____3__5__" 154 "test_readme_sample" 155 "test_ecev" 156 "test_expected_value" 157 "test_qubo_gas_int_paper_example" 158 "test_shor_no_factors_1_5" 159 "test_shor_no_factors_2_7" 160 "test_evolve_2___suzuki___1__3_" 161 "test_delta" 162 "test_swaprz" 163 "test_deprecated_algo_result" 164 "test_unsorted_grouping" 165 "test_ad_hoc_data" 166 "test_nft" 167 "test_oh" 168 "test_confidence_intervals_00001" 169 "test_eoh" 170 "test_qasm_5" 171 "test_uccsd_hf" 172 ] ++ lib.optionals (!withPyscf) [ 173 "test_validate" # test/chemistry/test_inputparser.py 174 ]; 175 176 meta = with lib; { 177 description = "An extensible library of quantum computing algorithms"; 178 homepage = "https://github.com/QISKit/qiskit-aqua"; 179 changelog = "https://qiskit.org/documentation/release_notes.html"; 180 license = licenses.asl20; 181 maintainers = with maintainers; [ drewrisinger ]; 182 }; 183}