Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pkgs/development/python-modules/qiskit-aer/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,9 @@ buildPythonPackage rec {
homepage = "https://github.com/QISKit/qiskit-aer";
license = licenses.asl20;
maintainers = with maintainers; [ drewrisinger ];
# Doesn't build on aarch64 (libmuparserx issue).
# Can fix by building muparserx from source (https://github.com/beltoforion/muparserx)
# or in future updates (e.g. Raspberry Pi enabled via https://github.com/Qiskit/qiskit-aer/pull/651 & https://github.com/Qiskit/qiskit-aer/pull/660)
platforms = platforms.x86_64;
};
}
117 changes: 117 additions & 0 deletions pkgs/development/python-modules/qiskit-aqua/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
{ lib
, pythonOlder
, buildPythonPackage
, fetchFromGitHub
, cvxopt
, dlx
, docplex
, fastdtw
, h5py
, networkx
, numpy
, psutil
, qiskit-ignis
, qiskit-terra
, quandl
, scikitlearn
# Check Inputs
, parameterized
, pytestCheckHook
, qiskit-aer
}:

buildPythonPackage rec {
pname = "qiskit-aqua";
version = "0.6.5";

disabled = pythonOlder "3.5";

# Pypi's tarball doesn't contain tests
src = fetchFromGitHub {
owner = "Qiskit";
repo = "qiskit-aqua";
rev = version;
sha256 = "03c0gl2qxyngf3cccjghjb0bhp0w78sdbvhim08cimf3cd577ldz";
};

# Optional packages: pyscf (see below NOTE) & pytorch. Can install via pip/nix if needed.
propagatedBuildInputs = [
cvxopt
docplex
dlx # Python Dancing Links package
fastdtw
h5py
networkx
numpy
psutil
qiskit-terra
qiskit-ignis
quandl
scikitlearn
];

# *** NOTE ***
# We make pyscf optional in this package, due to difficulties packaging it in Nix (test failures, complicated flags, etc).
# See nixpkgs#78772, nixpkgs#83447. You are welcome to try to package it yourself,
# or use the Nix User Repository version (https://github.com/drewrisinger/nur-packages).
# It can also be installed at runtime from the pip wheel.
# We disable appropriate tests below to allow building without pyscf installed

postPatch = ''
substituteInPlace setup.py \
--replace "pyscf; sys_platform == 'linux' or (python_version < '3.8' and sys_platform != 'win32')" ""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How will that work at runtime? Imagine you're a user that just installed this package from nixpkgs and expects it to work. Will there be unexpected crashes? If so, we should patch in a proper error message explaining the situation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I'd be fine adding error message on import. Will try to patch in.


# Add ImportWarning when running qiskit.chemistry (pyscf is a chemistry package) that pyscf is not included
echo -e "\nimport warnings\ntry: import pyscf;\nexcept:\n " \
"warnings.warn('pyscf is not supported on Nixpkgs so some qiskit features will fail." \
"You must install it yourself via pip or add it to your environment from the Nix User Repository." \
"See https://github.com/NixOS/nixpkgs/pull/83447 for details', ImportWarning)\n" \
>> qiskit/chemistry/__init__.py
'';

checkInputs = [ parameterized qiskit-aer pytestCheckHook ];
dontUseSetuptoolsCheck = true;
pythonImportsCheck = [
"qiskit.aqua"
"qiskit.aqua.algorithms"
"qiskit.chemistry"
"qiskit.finance"
"qiskit.ml"
"qiskit.optimization"
];
pytestFlagsArray = [
# Disabled b/c missing pyscf
"--ignore=test/chemistry/test_qeom_ee.py"
"--ignore=test/chemistry/test_qeom_vqe.py"
"--ignore=test/chemistry/test_vqe_uccsd_adapt.py"

# following tend to be slow tests, all pass
"--ignore-glob=*vqc.py"
"--ignore-glob=*hhl.py"
"--ignore-glob=*qgan.py"
];
disabledTests = [
# Disabled due to missing pyscf
Copy link
Member

@bcdarwin bcdarwin Apr 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If pyscf can't be added to checkInputs for some reason, probably worth noting. (Indeed, consider adding a comment explaining why it's removed from the dependencies?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried packaging pyscf in #78872, and myself & jonringer ended up deciding that it's being too difficult/ugly to package (issue mostly coming down to pyscf tests being very slow, failures difficult to diagnose, and long list of disabled tests that is hard to maintain). I can add note to that effect in code.

"test_validate" # test/chemistry/test_inputparser.py

# Disabling slow tests > 1 min
"test_qsvm_multiclass_error_correcting_code"
"test_vqe_qasm"
"test_qgan_training"
"test_qgan_training_run_algo_numpy"
"test_shor_factoring_0"
"test_lookup_rotation_4"
"test_lookup_rotation_neg_4"
"test_mcrz_11"
"test_evolve_1_suzuki"
"test_mct_with_dirty_ancillae_15"
"test_vqc_with_raw_feature_vector_on_wine"
];

meta = with lib; {
description = "An extensible library of quantum computing algorithms";
homepage = "https://github.com/QISKit/qiskit-aqua";
license = licenses.asl20;
maintainers = with maintainers; [ drewrisinger ];
};
}
2 changes: 2 additions & 0 deletions pkgs/top-level/python-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7113,6 +7113,8 @@ in {

qiskit-aer = callPackage ../development/python-modules/qiskit-aer { };

qiskit-aqua = callPackage ../development/python-modules/qiskit-aqua { };

qiskit-ibmq-provider = callPackage ../development/python-modules/qiskit-ibmq-provider { };

qiskit-ignis = callPackage ../development/python-modules/qiskit-ignis { };
Expand Down