From c66025c9188e2690c7d2793717364f8a0e106faa Mon Sep 17 00:00:00 2001 From: Matthew Harrigan Date: Fri, 12 Nov 2021 09:41:12 -0800 Subject: [PATCH 1/3] Split requirements Change-Id: I48b65062fbc2f1aa59749977bce54b5eec23a819 --- recirq/fermi_hubbard/extra-requirements.txt | 1 + recirq/hfvqe/extra-requirements.txt | 3 +++ recirq/optimize/extra-requirements.txt | 1 + recirq/otoc/extra-requirements.txt | 1 + recirq/qaoa/extra-requirements.txt | 1 + requirements.txt | 23 +--------------- setup.py | 29 +++++++++++++++++---- 7 files changed, 32 insertions(+), 27 deletions(-) create mode 100644 recirq/fermi_hubbard/extra-requirements.txt create mode 100644 recirq/hfvqe/extra-requirements.txt create mode 100644 recirq/optimize/extra-requirements.txt create mode 100644 recirq/otoc/extra-requirements.txt create mode 100644 recirq/qaoa/extra-requirements.txt diff --git a/recirq/fermi_hubbard/extra-requirements.txt b/recirq/fermi_hubbard/extra-requirements.txt new file mode 100644 index 00000000..3ad045dc --- /dev/null +++ b/recirq/fermi_hubbard/extra-requirements.txt @@ -0,0 +1 @@ +openfermion \ No newline at end of file diff --git a/recirq/hfvqe/extra-requirements.txt b/recirq/hfvqe/extra-requirements.txt new file mode 100644 index 00000000..680ae3c7 --- /dev/null +++ b/recirq/hfvqe/extra-requirements.txt @@ -0,0 +1,3 @@ +# fix bug with openfermionpyscf https://github.com/quantumlib/ReCirq/issues/200#issuecomment-923203883 +h5py~=3.2.1 +openfermion~=1.2.0 diff --git a/recirq/optimize/extra-requirements.txt b/recirq/optimize/extra-requirements.txt new file mode 100644 index 00000000..d5e06028 --- /dev/null +++ b/recirq/optimize/extra-requirements.txt @@ -0,0 +1 @@ +scikit-learn diff --git a/recirq/otoc/extra-requirements.txt b/recirq/otoc/extra-requirements.txt new file mode 100644 index 00000000..e000a66d --- /dev/null +++ b/recirq/otoc/extra-requirements.txt @@ -0,0 +1 @@ +Py-BOBYQA diff --git a/recirq/qaoa/extra-requirements.txt b/recirq/qaoa/extra-requirements.txt new file mode 100644 index 00000000..de9c8413 --- /dev/null +++ b/recirq/qaoa/extra-requirements.txt @@ -0,0 +1 @@ +pytket-cirq~=0.16.0 diff --git a/requirements.txt b/requirements.txt index 7fc8fd16..947c6874 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,25 +7,4 @@ cirq-google~=0.12.0 seaborn sphinx ipython -black - -# optimize -scikit-learn - -# qaoa -networkx -pytket-cirq~=0.16.0 - -# quantum chess, only needed for tests -scipy - -# hfvqe -openfermion~=1.2.0 -# fix bug with openfermionpyscf https://github.com/quantumlib/ReCirq/issues/200#issuecomment-923203883 -h5py~=3.2.1 - -# fermi_hubbard -tqdm # notebook progress bars - -# otoc -Py-BOBYQA +black \ No newline at end of file diff --git a/setup.py b/setup.py index 5e5bbfa5..3f8cb462 100644 --- a/setup.py +++ b/setup.py @@ -13,22 +13,41 @@ # limitations under the License. import pathlib +import functools +import operator + from setuptools import find_packages, setup __version__ = '' exec(open('recirq/_version.py').read()) assert __version__, 'Version string cannot be empty' -required_packages = pathlib.Path('requirements.txt').read_text().split('\n') -INSTALL_PACKAGES = [pkg for pkg in required_packages if pkg and not pkg.startswith('#')] + +def _parse_requirements(path: pathlib.Path): + lines = [line.strip() for line in path.read_text().splitlines() if line] + return [line for line in lines if not line.startswith('#')] + + +install_requires = _parse_requirements(pathlib.Path('requirements.txt')) +extras_require = [ + 'otoc', 'qaoa', 'optimize', 'hfvqe', 'fermi_hubbard' +] +extras_require = { + r: _parse_requirements(pathlib.Path(f'recirq/{r}/extra-requirements.txt')) + for r in extras_require +} + +# TODO: remove and require users to install via extras_require. +install_requires = functools.reduce(operator.add, extras_require.values(), install_requires) setup(name='recirq', version=__version__, - url='http://github.com/quantumlib/cirq', - author='The Cirq Developers', + url='http://github.com/quantumlib/recirq', + author='Quantum AI team and collaborators', author_email='cirq@googlegroups.com', python_requires='>=3.6.0', - install_requires=INSTALL_PACKAGES, + install_requires=install_requires, + extras_require=extras_require, license='Apache 2', description="", long_description=open('README.md', encoding='utf-8').read(), From 7e05de161cab85830539f722bff744efec3dd8c1 Mon Sep 17 00:00:00 2001 From: Matthew Harrigan Date: Fri, 12 Nov 2021 10:38:11 -0800 Subject: [PATCH 2/3] fix ci Change-Id: Ie8ab646e3fb2f4d668af7f1d404771a6ead88331 --- .github/workflows/pythonpackage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index fc7b29e6..4ff59c6d 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -38,7 +38,7 @@ jobs: run: | python -m pip install --upgrade pip pip install -r requirements.txt - pip install --no-deps -e . + pip install -e . - name: Lint with flake8 run: | From 13f3ce15b6ca035385306e20e94eac6484ebee6a Mon Sep 17 00:00:00 2001 From: Matthew Harrigan Date: Fri, 12 Nov 2021 15:04:37 -0800 Subject: [PATCH 3/3] add link to todo Change-Id: I1921c0a2e866679a96549aee2d868a1478a24020 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 3f8cb462..0a821c01 100644 --- a/setup.py +++ b/setup.py @@ -37,7 +37,7 @@ def _parse_requirements(path: pathlib.Path): for r in extras_require } -# TODO: remove and require users to install via extras_require. +# TODO(gh-231): remove and require users to install via extras_require. install_requires = functools.reduce(operator.add, extras_require.values(), install_requires) setup(name='recirq',