2020-04-24 23:36:52 +00:00
|
|
|
{ lib
|
2021-06-04 09:07:49 +00:00
|
|
|
, stdenv
|
2020-04-24 23:36:52 +00:00
|
|
|
, pythonOlder
|
|
|
|
, buildPythonPackage
|
|
|
|
, fetchFromGitHub
|
|
|
|
# Python requirements
|
|
|
|
, cython
|
|
|
|
, dill
|
|
|
|
, fastjsonschema
|
|
|
|
, jsonschema
|
|
|
|
, numpy
|
|
|
|
, networkx
|
|
|
|
, ply
|
|
|
|
, psutil
|
|
|
|
, python-constraint
|
2020-09-25 04:45:31 +00:00
|
|
|
, python-dateutil
|
2020-04-24 23:36:52 +00:00
|
|
|
, retworkx
|
|
|
|
, scipy
|
|
|
|
, sympy
|
2020-12-03 08:41:04 +00:00
|
|
|
, withVisualization ? false
|
|
|
|
# Python visualization requirements, optional
|
2020-04-24 23:36:52 +00:00
|
|
|
, ipywidgets
|
|
|
|
, matplotlib
|
|
|
|
, pillow
|
|
|
|
, pydot
|
|
|
|
, pygments
|
|
|
|
, pylatexenc
|
|
|
|
, seaborn
|
2020-12-03 08:41:04 +00:00
|
|
|
# Crosstalk-adaptive layout pass
|
|
|
|
, withCrosstalkPass ? false
|
|
|
|
, z3
|
|
|
|
# Classical function -> Quantum Circuit compiler
|
2021-04-13 19:44:15 +00:00
|
|
|
, withClassicalFunctionCompiler ? true
|
|
|
|
, tweedledum
|
2020-04-24 23:36:52 +00:00
|
|
|
# test requirements
|
|
|
|
, ddt
|
|
|
|
, hypothesis
|
|
|
|
, nbformat
|
|
|
|
, nbconvert
|
|
|
|
, pytestCheckHook
|
|
|
|
, python
|
|
|
|
}:
|
|
|
|
|
2020-12-03 08:41:04 +00:00
|
|
|
let
|
|
|
|
visualizationPackages = [
|
|
|
|
ipywidgets
|
|
|
|
matplotlib
|
|
|
|
pillow
|
|
|
|
pydot
|
|
|
|
pygments
|
|
|
|
pylatexenc
|
|
|
|
seaborn
|
|
|
|
];
|
|
|
|
crosstalkPackages = [ z3 ];
|
|
|
|
classicalCompilerPackages = [ tweedledum ];
|
|
|
|
in
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "qiskit-terra";
|
2021-06-04 09:07:49 +00:00
|
|
|
version = "0.17.4";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-12-03 08:41:04 +00:00
|
|
|
disabled = pythonOlder "3.6";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "Qiskit";
|
|
|
|
repo = pname;
|
|
|
|
rev = version;
|
2021-06-04 09:07:49 +00:00
|
|
|
hash = "sha256-JyNuke+XPqjLVZbvPud9Y7k0+EmvETVKcOYcDldBiVo=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [ cython ];
|
|
|
|
|
|
|
|
propagatedBuildInputs = [
|
|
|
|
dill
|
|
|
|
fastjsonschema
|
|
|
|
jsonschema
|
|
|
|
numpy
|
|
|
|
networkx
|
|
|
|
ply
|
|
|
|
psutil
|
|
|
|
python-constraint
|
2020-09-25 04:45:31 +00:00
|
|
|
python-dateutil
|
2020-04-24 23:36:52 +00:00
|
|
|
retworkx
|
|
|
|
scipy
|
|
|
|
sympy
|
2020-12-03 08:41:04 +00:00
|
|
|
] ++ lib.optionals withVisualization visualizationPackages
|
|
|
|
++ lib.optionals withCrosstalkPass crosstalkPackages
|
|
|
|
++ lib.optionals withClassicalFunctionCompiler classicalCompilerPackages;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# *** Tests ***
|
|
|
|
checkInputs = [
|
2020-12-03 08:41:04 +00:00
|
|
|
pytestCheckHook
|
2020-04-24 23:36:52 +00:00
|
|
|
ddt
|
|
|
|
hypothesis
|
|
|
|
nbformat
|
|
|
|
nbconvert
|
2020-12-03 08:41:04 +00:00
|
|
|
] ++ lib.optionals (!withVisualization) visualizationPackages;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
pythonImportsCheck = [
|
|
|
|
"qiskit"
|
|
|
|
"qiskit.transpiler.passes.routing.cython.stochastic_swap.swap_trial"
|
|
|
|
];
|
|
|
|
|
2021-04-13 19:44:15 +00:00
|
|
|
disabledTestPaths = [
|
|
|
|
"test/randomized/test_transpiler_equivalence.py" # collection requires qiskit-aer, which would cause circular dependency
|
|
|
|
] ++ lib.optionals (!withClassicalFunctionCompiler) [
|
|
|
|
"test/python/classical_function_compiler/"
|
2020-12-03 08:41:04 +00:00
|
|
|
];
|
|
|
|
disabledTests = [
|
2021-06-04 09:07:49 +00:00
|
|
|
# Not working on matplotlib >= 3.4.0, checks images match.
|
|
|
|
"test_plot_circuit_layout"
|
|
|
|
|
2020-12-03 08:41:04 +00:00
|
|
|
# Flaky tests
|
|
|
|
"test_cx_equivalence"
|
|
|
|
"test_pulse_limits"
|
2021-06-04 09:07:49 +00:00
|
|
|
"test_1q_random"
|
2021-04-13 19:44:15 +00:00
|
|
|
] ++ lib.optionals (!withClassicalFunctionCompiler) [
|
|
|
|
"TestPhaseOracle"
|
2021-06-04 09:07:49 +00:00
|
|
|
] ++ lib.optionals stdenv.isAarch64 [
|
|
|
|
"test_circuit_init" # failed on aarch64, https://gist.github.com/r-rmcgibbo/c2e173d43ced4f6954811004f6b5b842
|
2020-12-03 08:41:04 +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-13 19:44:15 +00: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"
|
2020-04-24 23:36:52 +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-09-25 04:45:31 +00:00
|
|
|
cp -r $TMP/$sourceRoot/test $PACKAGEDIR
|
|
|
|
cp -r $TMP/$sourceRoot/examples $PACKAGEDIR
|
|
|
|
cp -r $TMP/$sourceRoot/qiskit/schemas/examples $PACKAGEDIR/qiskit/schemas/
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# run pytest from Nix's $out path
|
|
|
|
pushd $PACKAGEDIR
|
|
|
|
'';
|
|
|
|
postCheck = ''
|
2021-06-04 09:07:49 +00:00
|
|
|
rm -r test
|
|
|
|
rm -r examples
|
2020-04-24 23:36:52 +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.
|
|
|
|
'';
|
|
|
|
homepage = "https://qiskit.org/terra";
|
|
|
|
downloadPage = "https://github.com/QISKit/qiskit-terra/releases";
|
2020-09-25 04:45:31 +00:00
|
|
|
changelog = "https://qiskit.org/documentation/release_notes.html";
|
2020-04-24 23:36:52 +00:00
|
|
|
license = licenses.asl20;
|
|
|
|
maintainers = with maintainers; [ drewrisinger ];
|
|
|
|
};
|
|
|
|
}
|