From 5c7446c668a98486848bf324b546369b835940b8 Mon Sep 17 00:00:00 2001 From: Matthew Treinish Date: Fri, 24 Jul 2020 12:14:53 -0400 Subject: [PATCH 1/9] Make pyscf an optional dependency pyscf doesn't package precompiled binaries for windows, older versions of macOS or 32bit linux and this has been a constant source of pain for users trying to install the qiskit meta-package. The windows case was already being handled so pyscf isn't a hard requirement for aqua. This commit removes pyscf from the requirements list and makes it an optional dependency for all environments. Fixes Qiskit/qiskit#696 --- requirements-dev.txt | 1 + setup.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index 6dc6033fef..9f486530bd 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -16,3 +16,4 @@ torch; sys_platform == 'linux' or (python_version < '3.8' and sys_platform != 'w qiskit-aer mypy>=0.780 mypy-extensions>=0.4.3 +pyscf diff --git a/setup.py b/setup.py index 8fde42bc7d..9167104916 100644 --- a/setup.py +++ b/setup.py @@ -39,7 +39,6 @@ "setuptools>=40.1.0", "h5py", "networkx>=2.2", - "pyscf; sys_platform != 'win32'", "pandas", "quandl", "yfinance", @@ -88,6 +87,7 @@ 'torch': ["torch; sys_platform == 'linux' or (python_version < '3.8' and sys_platform != 'win32')"], 'cplex': ["cplex; python_version >= '3.6' and python_version < '3.8'"], 'cvx': ['cvxpy>1.0.0,<1.1.0'], + 'pyscf': ['pyscf'], }, zip_safe=False ) From d6085c6d19ff87515a30029076cb14b6b617072b Mon Sep 17 00:00:00 2001 From: Manoel Marques Date: Fri, 24 Jul 2020 12:54:04 -0400 Subject: [PATCH 2/9] Optional pyscf install only for non windows --- requirements-dev.txt | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index 9f486530bd..6a73a76f24 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -16,4 +16,4 @@ torch; sys_platform == 'linux' or (python_version < '3.8' and sys_platform != 'w qiskit-aer mypy>=0.780 mypy-extensions>=0.4.3 -pyscf +pyscf; sys_platform != 'win32' diff --git a/setup.py b/setup.py index 9167104916..7d7ddd476c 100644 --- a/setup.py +++ b/setup.py @@ -87,7 +87,7 @@ 'torch': ["torch; sys_platform == 'linux' or (python_version < '3.8' and sys_platform != 'win32')"], 'cplex': ["cplex; python_version >= '3.6' and python_version < '3.8'"], 'cvx': ['cvxpy>1.0.0,<1.1.0'], - 'pyscf': ['pyscf'], + 'pyscf': ["pyscf; sys_platform != 'win32'"], }, zip_safe=False ) From f5596336419210e872f4642f60569372a9418372 Mon Sep 17 00:00:00 2001 From: Manoel Marques Date: Fri, 24 Jul 2020 12:55:30 -0400 Subject: [PATCH 3/9] Optional pyscf install only for non windows --- requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index b0f3da39ce..50798af7c4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,7 +11,6 @@ fastdtw setuptools>=40.1.0 h5py networkx>=2.2 -pyscf; sys_platform != 'win32' pandas quandl yfinance From d0d837f959f2deff42102bcf2b0b7c15926868ae Mon Sep 17 00:00:00 2001 From: Manoel Marques Date: Fri, 24 Jul 2020 13:30:53 -0400 Subject: [PATCH 4/9] fix docs --- README.md | 4 ---- qiskit/chemistry/drivers/__init__.py | 3 --- qiskit/chemistry/drivers/pyscfd/__init__.py | 4 ---- requirements-dev.txt | 1 - setup.py | 1 - 5 files changed, 13 deletions(-) diff --git a/README.md b/README.md index e9ee8b8532..8375cb1f7f 100644 --- a/README.md +++ b/README.md @@ -161,10 +161,6 @@ Several, as listed below, are supported, and while logic to interface these prog the chemistry module via the above pip installation, the dependent programs/libraries themselves need to be installed separately. -Note: As `PySCF` can be installed via pip the installation of Qiskit (Aqua) will install PySCF -where it's supported (MacOS and Linux x86). For other platforms see the PySCF information as to -whether this might be possible manually. - 1. [Gaussian 16™](https://qiskit.org/documentation/apidoc/qiskit.chemistry.drivers.gaussiand.html), a commercial chemistry program 2. [PSI4](https://qiskit.org/documentation/apidoc/qiskit.chemistry.drivers.psi4d.html), a chemistry program that exposes a Python interface allowing for accessing internal objects 3. [PySCF](https://qiskit.org/documentation/apidoc/qiskit.chemistry.drivers.pyscfd.html), an open-source Python chemistry program diff --git a/qiskit/chemistry/drivers/__init__.py b/qiskit/chemistry/drivers/__init__.py index a0de442ed6..86e7d7a239 100644 --- a/qiskit/chemistry/drivers/__init__.py +++ b/qiskit/chemistry/drivers/__init__.py @@ -74,9 +74,6 @@ the relevant installation instructions below for your program/library that you intend to use. -Note: `PySCF` is automatically installed for `macOS` and `Linux` platforms when Qiskit -is installed. For other platforms again consult the relevant installation instructions below. - .. toctree:: :maxdepth: 1 diff --git a/qiskit/chemistry/drivers/pyscfd/__init__.py b/qiskit/chemistry/drivers/pyscfd/__init__.py index 9bced21601..5b3fcb76e5 100644 --- a/qiskit/chemistry/drivers/pyscfd/__init__.py +++ b/qiskit/chemistry/drivers/pyscfd/__init__.py @@ -23,10 +23,6 @@ the preferred installation method is via the pip package management system. Doing so, while in the Python virtual environment where Qiskit's chemistry module is also installed, will automatically make PySCF available to Qiskit at run time. - -Note: `PySCF` is automatically installed for `macOS` and `Linux` platforms when Qiskit is -installed via the pip package management system. - """ from .pyscfdriver import PySCFDriver, InitialGuess diff --git a/requirements-dev.txt b/requirements-dev.txt index 6a73a76f24..6dc6033fef 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -16,4 +16,3 @@ torch; sys_platform == 'linux' or (python_version < '3.8' and sys_platform != 'w qiskit-aer mypy>=0.780 mypy-extensions>=0.4.3 -pyscf; sys_platform != 'win32' diff --git a/setup.py b/setup.py index 7d7ddd476c..48679d7838 100644 --- a/setup.py +++ b/setup.py @@ -87,7 +87,6 @@ 'torch': ["torch; sys_platform == 'linux' or (python_version < '3.8' and sys_platform != 'win32')"], 'cplex': ["cplex; python_version >= '3.6' and python_version < '3.8'"], 'cvx': ['cvxpy>1.0.0,<1.1.0'], - 'pyscf': ["pyscf; sys_platform != 'win32'"], }, zip_safe=False ) From f491e449e4057a9d3605a2760a00e6faef44ab57 Mon Sep 17 00:00:00 2001 From: Manoel Marques Date: Fri, 24 Jul 2020 14:12:01 -0400 Subject: [PATCH 5/9] change readme --- README.md | 2 +- setup.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8375cb1f7f..46635cf87b 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,7 @@ these on a quantum backend, whether a real device or simulator. * **IBM CPLEX** may be [installed](https://qiskit.org/documentation/apidoc/qiskit.aqua.algorithms.minimum_eigen_solvers.cplex.html) to allow use of the `ClassicalCPLEX` classical solver algorithm. `pip install cplex` may be used as an alternative. -* **PyTorch**, may be installed either using command `pip install qiskit-aqua[torch]` to install the +* **PyTorch**, may be installed either using command `pip install torch` to install the package or refer to PyTorch [getting started](https://pytorch.org/get-started/locally/). PyTorch being installed will enable the neural networks `PyTorchDiscriminator` component to be used with the QGAN algorithm. diff --git a/setup.py b/setup.py index 48679d7838..7d7ddd476c 100644 --- a/setup.py +++ b/setup.py @@ -87,6 +87,7 @@ 'torch': ["torch; sys_platform == 'linux' or (python_version < '3.8' and sys_platform != 'win32')"], 'cplex': ["cplex; python_version >= '3.6' and python_version < '3.8'"], 'cvx': ['cvxpy>1.0.0,<1.1.0'], + 'pyscf': ["pyscf; sys_platform != 'win32'"], }, zip_safe=False ) From c206c42ea10a2d251f2ce46a065ebbabb4cbbb48 Mon Sep 17 00:00:00 2001 From: Manoel Marques Date: Fri, 24 Jul 2020 14:14:58 -0400 Subject: [PATCH 6/9] trigger travis From a0205f824e19bfeaad1372859bd04f70066622d9 Mon Sep 17 00:00:00 2001 From: Manoel Marques Date: Fri, 24 Jul 2020 14:49:39 -0400 Subject: [PATCH 7/9] fix unit test case --- test/chemistry/test_driver_fcidump_dumper.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/test/chemistry/test_driver_fcidump_dumper.py b/test/chemistry/test_driver_fcidump_dumper.py index 6bf75ff126..16fcc6cc7b 100644 --- a/test/chemistry/test_driver_fcidump_dumper.py +++ b/test/chemistry/test_driver_fcidump_dumper.py @@ -115,18 +115,19 @@ def setUp(self): charge=0, spin=0, basis='sto3g') - except QiskitChemistryError: - self.skipTest('PYSCF driver does not appear to be installed') - - qmolecule = driver.run() + qmolecule = driver.run() - dump = tempfile.NamedTemporaryFile() - FCIDumpDriver.dump(qmolecule, dump.name) + dump = tempfile.NamedTemporaryFile() + FCIDumpDriver.dump(qmolecule, dump.name) - from pyscf.tools import fcidump as pyscf_fcidump # pylint: disable=import-outside-toplevel - self.dumped = pyscf_fcidump.read(dump.name) + from pyscf.tools import fcidump as pyscf_fcidump # pylint: disable=import-outside-toplevel + self.dumped = pyscf_fcidump.read(dump.name) - dump.close() + dump.close() + except QiskitChemistryError: + self.skipTest('PYSCF driver does not appear to be installed.') + except ImportError: + self.skipTest('PYSCF driver does not appear to be installed.') if __name__ == '__main__': From b8a133386d128039cd0d7696c548090721a1cb52 Mon Sep 17 00:00:00 2001 From: Manoel Marques Date: Fri, 24 Jul 2020 14:51:28 -0400 Subject: [PATCH 8/9] fix style --- test/chemistry/test_driver_fcidump_dumper.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/chemistry/test_driver_fcidump_dumper.py b/test/chemistry/test_driver_fcidump_dumper.py index 16fcc6cc7b..ec2e9318ec 100644 --- a/test/chemistry/test_driver_fcidump_dumper.py +++ b/test/chemistry/test_driver_fcidump_dumper.py @@ -120,7 +120,8 @@ def setUp(self): dump = tempfile.NamedTemporaryFile() FCIDumpDriver.dump(qmolecule, dump.name) - from pyscf.tools import fcidump as pyscf_fcidump # pylint: disable=import-outside-toplevel + # pylint: disable=import-outside-toplevel + from pyscf.tools import fcidump as pyscf_fcidump self.dumped = pyscf_fcidump.read(dump.name) dump.close() From 4954acd3dd6727dce61d9c4f9a18295bc02ed97a Mon Sep 17 00:00:00 2001 From: Manoel Marques Date: Fri, 24 Jul 2020 15:08:36 -0400 Subject: [PATCH 9/9] install pyscf on travis chemistry --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index bbddec7cb1..ee47ac2229 100644 --- a/.travis.yml +++ b/.travis.yml @@ -243,7 +243,7 @@ jobs: - sudo apt-get -y install libgfortran5 # Installing pyquante2 master branch... - pip install https://github.com/rpmuller/pyquante2/archive/master.zip --progress-bar off - - pip install cplex + - pip install cplex pyscf before_script: - export PYTHON="coverage3 run --source qiskit/aqua,qiskit/chemistry,qiskit/finance,qiskit/ml,qiskit/optimization --omit */gauopen/* --parallel-mode" script: @@ -266,6 +266,7 @@ jobs: - sudo apt-get -y install libgfortran5 # Installing pyquante2 master branch... - pip install https://github.com/rpmuller/pyquante2/archive/master.zip --progress-bar off + - pip install pyscf script: - stestr --test-path test/chemistry run 2> >(tee /dev/stderr out.txt > /dev/null) - python tools/extract_deprecation.py -file out.txt -output chemistry38.dep