Unverified Commit 8acff4c2 authored by Sandro Jäckel's avatar Sandro Jäckel Committed by GitHub
Browse files

python3Packages.qiskit*: update qiskit and remove deprecated packages (#357208)

parents 6cf25e0f cf8099f7
Loading
Loading
Loading
Loading
+37 −106
Original line number Diff line number Diff line
{
  lib,
  pythonOlder,
  stdenv,
  buildPythonPackage,
  fetchFromGitHub,
  # C Inputs
  blas,
  catch2,
  cmake,
  cython,
  fmt,
  muparserx,
  ninja,
  nlohmann_json,
  spdlog,
  # Python Inputs
  cvxpy,
  numpy,
  pybind11,
  scikit-build,
  # Check Inputs
  pytestCheckHook,
  ddt,
  fixtures,
  pytest-timeout,
  qiskit-terra,
  testtools,
  qiskit,
  psutil,
  scipy,
  python-dateutil,
}:

buildPythonPackage rec {
  pname = "qiskit-aer";
  version = "0.17.1";
  format = "pyproject";

  disabled = pythonOlder "3.6";
  version = "0.17.2";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "Qiskit";
    repo = "qiskit-aer";
    tag = version;
    hash = "sha256-jvapuARJUHgAKFUzGb5MUft01LNefVIXtStJqFnCo90=";
    hash = "sha256-aVmGoLMnDjV3iB9s4tvcL62zKvH/p70mqeGsxHzi3nc=";
  };

  dontUseCmakeConfigure = true;

  # build fails even if setting DISABLE_CONAN flag
  postPatch = ''
    substituteInPlace setup.py \
      --replace "'cmake!=3.17,!=3.17.0'," "" \
      --replace "'pybind11', min_version='2.6'" "'pybind11'" \
      --replace "pybind11>=2.6" "pybind11" \
      --replace "scikit-build>=0.11.0" "scikit-build" \
      --replace "min_version='0.11.0'" ""
    sed -i -e '/conan/d' pyproject.toml
  '';

  nativeBuildInputs = [
    cmake
    ninja
  ];

  build-system = [
    pybind11
    scikit-build
  ];

  dependencies = [
    scipy
    numpy
    psutil
    python-dateutil
    qiskit
  ];

  buildInputs = [
    blas
    catch2
    nlohmann_json
    fmt
    muparserx
    spdlog
  ];

  propagatedBuildInputs = [
    cvxpy
    cython # generates some cython files at runtime that need to be cython-ized
    numpy
    pybind11
  ];

  preBuild = ''
    export DISABLE_CONAN=1
    export DISABLE_CONAN=ON
  '';

  dontUseCmakeConfigure = true;

  # *** Testing ***
  pythonImportsCheck = [
    "qiskit.providers.aer"
    "qiskit.providers.aer.backends.qasm_simulator"
    "qiskit.providers.aer.backends.controller_wrappers" # Checks C++ files built correctly. Only exists if built & moved to output
    "qiskit_aer"
    "qiskit_aer.primitives"
    "qiskit_aer.noise"
    "qiskit_aer.library"
    "qiskit_aer.backends.controller_wrappers"
  ];

  disabledTests = [
    # these tests don't work with cvxpy >= 1.1.15
    "test_clifford"
    "test_approx_random"
    "test_snapshot" # TODO: these ~30 tests fail on setup due to pytest fixture issues?
    "test_initialize_2" # TODO: simulations appear incorrect, off by >10%.
    "test_pauli_error_2q_gate_from_string_1qonly"

    # these fail for some builds. Haven't been able to reproduce error locally.
    "test_kraus_gate_noise"
    "test_backend_method_clifford_circuits_and_kraus_noise"
    "test_backend_method_nonclifford_circuit_and_kraus_noise"
    "test_kraus_noise_fusion"

    # Slow tests
    "test_paulis_1_and_2_qubits"
    "test_3d_oscillator"
    "_057"
    "_136"
    "_137"
    "_139"
    "_138"
    "_140"
    "_141"
    "_143"
    "_144"
    "test_sparse_output_probabilities"
    "test_reset_2_qubit"

    # Fails with 0.10.4
    "test_extended_stabilizer_sparse_output_probs"
  ];

  nativeCheckInputs = [
    pytestCheckHook
    ddt
    fixtures
    pytest-timeout
    qiskit-terra
    testtools
  ];

  pytestFlags = [
    "--timeout=30"
    "--durations=10"
  ];

  preCheck = ''
    # Tests include a compiled "circuit" which is auto-built in $HOME
    export HOME=$(mktemp -d)
    # move tests b/c by default try to find (missing) cython-ized code in /build/source dir
    cp -r $TMP/$sourceRoot/test $HOME

    # Add qiskit-aer compiled files to cython include search
    pushd $HOME
  '';

  postCheck = "popd";
  doCheck = false;

  meta = with lib; {
    broken = true;
  meta = {
    description = "High performance simulators for Qiskit";
    homepage = "https://qiskit.org/aer";
    # broken on darwin for unknown reasons
    broken = stdenv.isDarwin;
    homepage = "https://qiskit.github.io/qiskit-aer/";
    downloadPage = "https://github.com/QISKit/qiskit-aer/releases";
    changelog = "https://qiskit.org/documentation/release_notes.html";
    license = licenses.asl20;
    changelog = "https://qiskit.github.io/qiskit-aer/release_notes.html";
    license = lib.licenses.asl20;
    maintainers = [ ];
  };
}
+4 −2
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@
  numpy,
  pandas,
  psutil,
  qiskit-terra,
  qiskit,
  qiskit-optimization,
  scikit-learn,
  scipy,
@@ -50,7 +50,7 @@ buildPythonPackage rec {
    numpy
    pandas
    psutil
    qiskit-terra
    qiskit
    qiskit-optimization
    quandl
    scikit-learn
@@ -78,6 +78,8 @@ buildPythonPackage rec {
  pytestFlags = [ "--durations=10" ];

  meta = with lib; {
    # broken because it depends on qiskit-algorithms which is not yet packaged in nixpkgs
    broken = true;
    description = "Software for developing quantum computing programs";
    homepage = "https://qiskit.org";
    downloadPage = "https://github.com/QISKit/qiskit-optimization/releases";
+0 −109
Original line number Diff line number Diff line
{
  lib,
  pythonOlder,
  buildPythonPackage,
  fetchFromGitHub,
  arrow,
  nest-asyncio,
  qiskit-terra,
  requests,
  requests-ntlm,
  websocket-client,
  # Visualization inputs
  withVisualization ? true,
  ipython,
  ipyvuetify,
  ipywidgets,
  matplotlib,
  plotly,
  pyperclip,
  seaborn,
  # check inputs
  pytestCheckHook,
  nbconvert,
  nbformat,
  pproxy,
  qiskit-aer,
  websockets,
  vcrpy,
}:

let
  visualizationPackages = [
    ipython
    ipyvuetify
    ipywidgets
    matplotlib
    plotly
    pyperclip
    seaborn
  ];
in
buildPythonPackage rec {
  pname = "qiskit-ibmq-provider";
  version = "0.20.2";
  format = "setuptools";

  disabled = pythonOlder "3.6";

  src = fetchFromGitHub {
    owner = "Qiskit";
    repo = pname;
    rev = "refs/tags/${version}";
    hash = "sha256-7dIspeJpukLDfICoBPPZZWdzkVumtvh+NRxvtmnvWH0=";
  };

  propagatedBuildInputs = [
    arrow
    nest-asyncio
    qiskit-terra
    requests
    requests-ntlm
    websocket-client
    websockets
  ]
  ++ lib.optionals withVisualization visualizationPackages;

  postPatch = ''
    substituteInPlace setup.py --replace "websocket-client>=1.0.1" "websocket-client"
  '';

  # Most tests require credentials to run on IBMQ
  nativeCheckInputs = [
    pytestCheckHook
    nbconvert
    nbformat
    pproxy
    qiskit-aer
    vcrpy
  ]
  ++ lib.optionals (!withVisualization) visualizationPackages;

  pythonImportsCheck = [ "qiskit.providers.ibmq" ];
  disabledTests = [
    "test_coder_operators" # fails for some reason on nixos-21.05+
    # These disabled tests require internet connection, aren't skipped elsewhere
    "test_old_api_url"
    "test_non_auth_url"
    "test_non_auth_url_with_hub"
    "test_coder_optimizers" # TODO: reenable when package scikit-quant is packaged, either in NUR or nixpkgs

    # slow tests
    "test_websocket_retry_failure"
    "test_invalid_url"
  ];

  # Skip tests that rely on internet access (mostly to IBM Quantum Experience cloud).
  # Options defined in qiskit.terra.test.testing_options.py::get_test_options
  preCheck = ''
    export QISKIT_TESTS=skip_online
  '';

  meta = with lib; {
    description = "Qiskit provider for accessing the quantum devices and simulators at IBMQ";
    homepage = "https://github.com/Qiskit/qiskit-ibmq-provider";
    changelog = "https://qiskit.org/documentation/release_notes.html";
    license = licenses.asl20;
    maintainers = [ ];
  };
}
+0 −76
Original line number Diff line number Diff line
{
  lib,
  stdenv,
  pythonOlder,
  buildPythonPackage,
  fetchFromGitHub,
  numpy,
  qiskit-terra,
  scikit-learn,
  scipy,
  # Optional package inputs
  withVisualization ? false,
  matplotlib,
  withCvx ? false,
  cvxpy,
  withJit ? false,
  numba,
  # Check Inputs
  pytestCheckHook,
  ddt,
  pyfakefs,
  qiskit-aer,
}:

buildPythonPackage rec {
  pname = "qiskit-ignis";
  version = "0.7.1";
  format = "setuptools";

  disabled = pythonOlder "3.6";

  # Pypi's tarball doesn't contain tests
  src = fetchFromGitHub {
    owner = "Qiskit";
    repo = "qiskit-ignis";
    rev = "refs/tags/${version}";
    hash = "sha256-WyLNtZhtuGzqCJdOBvtBjZZiGFQihpeSjJQtP7lI248=";
  };

  propagatedBuildInputs = [
    numpy
    qiskit-terra
    scikit-learn
    scipy
  ]
  ++ lib.optionals withCvx [ cvxpy ]
  ++ lib.optionals withVisualization [ matplotlib ]
  ++ lib.optionals withJit [ numba ];

  # Tests
  pythonImportsCheck = [ "qiskit.ignis" ];
  preCheck = ''
    export HOME=$TMPDIR
  '';
  nativeCheckInputs = [
    pytestCheckHook
    ddt
    pyfakefs
    qiskit-aer
  ];
  disabledTests = [
    "test_tensored_meas_cal_on_circuit" # Flaky test, occasionally returns result outside bounds
  ]
  ++ lib.optionals stdenv.hostPlatform.isAarch64 [
    "test_fitters" # Fails check that arrays are close. Might be due to aarch64 math issues.
  ];

  meta = with lib; {
    description = "Qiskit tools for quantum hardware verification, noise characterization, and error correction";
    homepage = "https://qiskit.org/ignis";
    downloadPage = "https://github.com/QISKit/qiskit-ignis/releases";
    changelog = "https://qiskit.org/documentation/release_notes.html";
    license = licenses.asl20;
    maintainers = [ ];
  };
}
+3 −2
Original line number Diff line number Diff line
@@ -11,7 +11,7 @@
  fastdtw,
  numpy,
  psutil,
  qiskit-terra,
  qiskit,
  scikit-learn,
  sparse,
  torch,
@@ -43,7 +43,7 @@ buildPythonPackage rec {
    numpy
    psutil
    torch
    qiskit-terra
    qiskit
    scikit-learn
    sparse
  ];
@@ -84,6 +84,7 @@ buildPythonPackage rec {
  ];

  meta = with lib; {
    broken = true; # incompatible with qiskit >= 2.0 (see https://github.com/Qiskit/qiskit-machine-learning/issues/934)
    description = "Software for developing quantum computing programs";
    homepage = "https://qiskit.org";
    downloadPage = "https://github.com/QISKit/qiskit-optimization/releases";
Loading