Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move requirements into subpackages #230

Merged
merged 3 commits into from
Nov 23, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions recirq/fermi_hubbard/extra-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
openfermion
3 changes: 3 additions & 0 deletions recirq/hfvqe/extra-requirements.txt
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions recirq/optimize/extra-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
scikit-learn
1 change: 1 addition & 0 deletions recirq/otoc/extra-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Py-BOBYQA
1 change: 1 addition & 0 deletions recirq/qaoa/extra-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pytket-cirq~=0.16.0
23 changes: 1 addition & 22 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
29 changes: 24 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a good way to auto-detect this (or alternatively, for keeping this up to date if we add more experiments)?

Copy link
Collaborator Author

@mpharrigan mpharrigan Nov 12, 2021

Choose a reason for hiding this comment

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

Yes, I first wrote it to glob/regex for extra-requirements.txt and I could set it to that. However: for my next thing I want to add CI jobs that tests each subpackage in isolation. Autogenerating CI jobs would likely be more complicated than its worth. Especially since there will be an isolated "vanilla deps" build that will run all tests not in the named extra-requires subpackages which would fail if newly added experiments did indeed have extra requirements.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok, SGTM, I already approved this PR. Feel free to merge when ready.

]
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.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this link to a Github issue?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done, also see #231

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(),
Expand Down