2020-01-20 23:56:43 +00:00
|
|
|
{ lib
|
|
|
|
, pythonOlder
|
|
|
|
, buildPythonPackage
|
|
|
|
, fetchFromGitHub
|
2020-04-10 14:09:27 +01:00
|
|
|
# Python requirements
|
2020-01-20 23:56:43 +00:00
|
|
|
, cython
|
|
|
|
, dill
|
|
|
|
, numpy
|
|
|
|
, networkx
|
|
|
|
, ply
|
|
|
|
, psutil
|
2020-04-10 14:09:27 +01:00
|
|
|
, python-constraint
|
2020-08-10 23:37:07 +01:00
|
|
|
, python-dateutil
|
2020-04-10 14:09:27 +01:00
|
|
|
, retworkx
|
2020-01-20 23:56:43 +00:00
|
|
|
, scipy
|
2021-11-12 01:01:16 +00:00
|
|
|
, scikit-quant ? null
|
2022-01-12 19:59:37 +00:00
|
|
|
, stevedore
|
2021-11-12 01:01:16 +00:00
|
|
|
, symengine
|
2020-01-20 23:56:43 +00:00
|
|
|
, sympy
|
2021-11-12 01:01:16 +00:00
|
|
|
, tweedledum
|
2020-10-08 06:12:41 +01:00
|
|
|
, withVisualization ? false
|
|
|
|
# Python visualization requirements, optional
|
2020-04-10 14:09:27 +01:00
|
|
|
, ipywidgets
|
|
|
|
, matplotlib
|
|
|
|
, pillow
|
|
|
|
, pydot
|
|
|
|
, pygments
|
|
|
|
, pylatexenc
|
|
|
|
, seaborn
|
2020-10-08 06:12:41 +01:00
|
|
|
# Crosstalk-adaptive layout pass
|
|
|
|
, withCrosstalkPass ? false
|
|
|
|
, z3
|
2020-01-20 23:56:43 +00:00
|
|
|
# test requirements
|
|
|
|
, ddt
|
|
|
|
, hypothesis
|
|
|
|
, nbformat
|
|
|
|
, nbconvert
|
|
|
|
, pytestCheckHook
|
2020-04-10 14:09:27 +01:00
|
|
|
, python
|
2020-01-20 23:56:43 +00:00
|
|
|
}:
|
|
|
|
|
2020-10-08 06:12:41 +01:00
|
|
|
let
|
|
|
|
visualizationPackages = [
|
|
|
|
ipywidgets
|
|
|
|
matplotlib
|
|
|
|
pillow
|
|
|
|
pydot
|
|
|
|
pygments
|
|
|
|
pylatexenc
|
|
|
|
seaborn
|
|
|
|
];
|
|
|
|
crosstalkPackages = [ z3 ];
|
|
|
|
in
|
|
|
|
|
2020-01-20 23:56:43 +00:00
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "qiskit-terra";
|
2022-02-11 18:01:18 +00:00
|
|
|
version = "0.19.2";
|
2020-01-20 23:56:43 +00:00
|
|
|
|
2020-10-08 06:11:35 +01:00
|
|
|
disabled = pythonOlder "3.6";
|
2020-01-20 23:56:43 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
2022-01-12 19:59:37 +00:00
|
|
|
owner = "qiskit";
|
2020-01-20 23:56:43 +00:00
|
|
|
repo = pname;
|
|
|
|
rev = version;
|
2022-02-11 18:01:18 +00:00
|
|
|
sha256 = "sha256-P2QTdt1H9I5T/ONNoo7XEVnoHweOdq3p2NH3l3/yAn4=";
|
2020-01-20 23:56:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [ cython ];
|
|
|
|
|
|
|
|
propagatedBuildInputs = [
|
|
|
|
dill
|
|
|
|
numpy
|
|
|
|
networkx
|
|
|
|
ply
|
|
|
|
psutil
|
2020-04-10 14:09:27 +01:00
|
|
|
python-constraint
|
2020-08-10 23:37:07 +01:00
|
|
|
python-dateutil
|
2020-04-10 14:09:27 +01:00
|
|
|
retworkx
|
2020-01-20 23:56:43 +00:00
|
|
|
scipy
|
2021-11-12 01:01:16 +00:00
|
|
|
scikit-quant
|
2022-01-12 19:59:37 +00:00
|
|
|
stevedore
|
2021-11-12 01:01:16 +00:00
|
|
|
symengine
|
2020-01-20 23:56:43 +00:00
|
|
|
sympy
|
2021-11-12 01:01:16 +00:00
|
|
|
tweedledum
|
2020-10-08 06:12:41 +01:00
|
|
|
] ++ lib.optionals withVisualization visualizationPackages
|
2021-11-12 01:01:16 +00:00
|
|
|
++ lib.optionals withCrosstalkPass crosstalkPackages;
|
2020-01-20 23:56:43 +00:00
|
|
|
|
|
|
|
# *** Tests ***
|
|
|
|
checkInputs = [
|
2020-10-08 06:12:41 +01:00
|
|
|
pytestCheckHook
|
2020-01-20 23:56:43 +00:00
|
|
|
ddt
|
|
|
|
hypothesis
|
|
|
|
nbformat
|
|
|
|
nbconvert
|
2020-10-08 06:12:41 +01:00
|
|
|
] ++ lib.optionals (!withVisualization) visualizationPackages;
|
2020-01-20 23:56:43 +00:00
|
|
|
|
|
|
|
pythonImportsCheck = [
|
|
|
|
"qiskit"
|
|
|
|
"qiskit.transpiler.passes.routing.cython.stochastic_swap.swap_trial"
|
|
|
|
];
|
|
|
|
|
2021-04-06 16:09:12 +01:00
|
|
|
disabledTestPaths = [
|
|
|
|
"test/randomized/test_transpiler_equivalence.py" # collection requires qiskit-aer, which would cause circular dependency
|
2021-11-12 01:01:16 +00:00
|
|
|
# These tests are nondeterministic and can randomly fail.
|
|
|
|
# We ignore them here for deterministic building.
|
|
|
|
"test/randomized/"
|
|
|
|
# These tests consistently fail on GitHub Actions build
|
|
|
|
"test/python/quantum_info/operators/test_random.py"
|
2020-01-20 23:56:43 +00:00
|
|
|
];
|
2021-11-12 01:01:16 +00:00
|
|
|
pytestFlagsArray = [ "--durations=10" ];
|
2020-11-04 17:27:06 +00:00
|
|
|
disabledTests = [
|
2022-01-12 19:59:37 +00:00
|
|
|
"TestUnitarySynthesisPlugin" # uses unittest mocks for transpiler.run(), seems incompatible somehow w/ pytest infrastructure
|
|
|
|
"test_copy" # assertNotIn doesn't seem to work as expected w/ pytest vs unittest
|
|
|
|
|
2020-11-04 17:27:06 +00:00
|
|
|
# Flaky tests
|
2021-11-12 01:01:16 +00:00
|
|
|
"test_pulse_limits" # Fails on GitHub Actions, probably due to minor floating point arithmetic error.
|
|
|
|
"test_cx_equivalence" # Fails due to flaky test
|
|
|
|
"test_two_qubit_synthesis_not_pulse_optimal" # test of random circuit, seems to randomly fail depending on seed
|
|
|
|
"test_qv_natural" # fails due to sign error. Not sure why
|
|
|
|
] ++ lib.optionals (lib.versionAtLeast matplotlib.version "3.4.0") [
|
|
|
|
"test_plot_circuit_layout"
|
2020-11-04 17:27:06 +00:00
|
|
|
]
|
|
|
|
# Disabling slow tests for build constraints
|
|
|
|
++ [
|
|
|
|
"test_all_examples"
|
|
|
|
"test_controlled_random_unitary"
|
|
|
|
"test_controlled_standard_gates_1"
|
|
|
|
"test_jupyter_jobs_pbars"
|
|
|
|
"test_lookahead_swap_higher_depth_width_is_better"
|
|
|
|
"test_move_measurements"
|
|
|
|
"test_job_monitor"
|
|
|
|
"test_wait_for_final_state"
|
|
|
|
"test_multi_controlled_y_rotation_matrix_basic_mode"
|
|
|
|
"test_two_qubit_weyl_decomposition_abc"
|
|
|
|
"test_isometry"
|
|
|
|
"test_parallel"
|
|
|
|
"test_random_state"
|
|
|
|
"test_random_clifford_valid"
|
|
|
|
"test_to_matrix"
|
|
|
|
"test_block_collection_reduces_1q_gate"
|
|
|
|
"test_multi_controlled_rotation_gate_matrices"
|
|
|
|
"test_block_collection_runs_for_non_cx_bases"
|
2021-04-06 16:09:12 +01:00
|
|
|
"test_with_two_qubit_reduction"
|
|
|
|
"test_basic_aer_qasm"
|
|
|
|
"test_hhl"
|
|
|
|
"test_H2_hamiltonian"
|
|
|
|
"test_max_evals_grouped_2"
|
|
|
|
"test_qaoa_qc_mixer_4"
|
|
|
|
"test_abelian_grouper_random_2"
|
|
|
|
"test_pauli_two_design"
|
2021-11-12 01:01:16 +00:00
|
|
|
"test_shor_factoring"
|
|
|
|
"test_sample_counts_memory_ghz"
|
|
|
|
"test_two_qubit_weyl_decomposition_ab0"
|
|
|
|
"test_sample_counts_memory_superposition"
|
|
|
|
"test_piecewise_polynomial_function"
|
|
|
|
"test_vqe_qasm"
|
2022-01-12 19:59:37 +00:00
|
|
|
"test_piecewise_chebyshev_mutability"
|
|
|
|
"test_bit_conditional_no_cregbundle"
|
|
|
|
"test_gradient_wrapper2"
|
|
|
|
"test_two_qubit_weyl_decomposition_abmb"
|
|
|
|
"test_two_qubit_weyl_decomposition_abb"
|
|
|
|
"test_two_qubit_weyl_decomposition_aac"
|
|
|
|
"test_aqc"
|
|
|
|
"test_gradient"
|
|
|
|
"test_piecewise_polynomial_rotations_mutability"
|
|
|
|
"test_confidence_intervals_1"
|
|
|
|
"test_trotter_from_bound"
|
2020-11-04 17:27:06 +00:00
|
|
|
];
|
2020-01-20 23:56:43 +00:00
|
|
|
|
|
|
|
# Moves tests to $PACKAGEDIR/test. They can't be run from /build because of finding
|
|
|
|
# cythonized modules and expecting to find some resource files in the test directory.
|
|
|
|
preCheck = ''
|
|
|
|
export PACKAGEDIR=$out/${python.sitePackages}
|
|
|
|
echo "Moving Qiskit test files to package directory"
|
2020-08-10 23:37:07 +01:00
|
|
|
cp -r $TMP/$sourceRoot/test $PACKAGEDIR
|
|
|
|
cp -r $TMP/$sourceRoot/examples $PACKAGEDIR
|
2020-01-20 23:56:43 +00:00
|
|
|
|
|
|
|
# run pytest from Nix's $out path
|
|
|
|
pushd $PACKAGEDIR
|
|
|
|
'';
|
|
|
|
postCheck = ''
|
2021-04-27 19:21:34 +01:00
|
|
|
rm -r test
|
|
|
|
rm -r examples
|
2020-01-20 23:56:43 +00:00
|
|
|
popd
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "Provides the foundations for Qiskit.";
|
|
|
|
longDescription = ''
|
|
|
|
Allows the user to write quantum circuits easily, and takes care of the constraints of real hardware.
|
|
|
|
'';
|
2020-04-10 14:09:27 +01:00
|
|
|
homepage = "https://qiskit.org/terra";
|
|
|
|
downloadPage = "https://github.com/QISKit/qiskit-terra/releases";
|
2020-08-10 23:37:07 +01:00
|
|
|
changelog = "https://qiskit.org/documentation/release_notes.html";
|
2020-01-20 23:56:43 +00:00
|
|
|
license = licenses.asl20;
|
|
|
|
maintainers = with maintainers; [ drewrisinger ];
|
|
|
|
};
|
|
|
|
}
|