From 765df8c469695ae32c10f65d3061d1198bb5ac40 Mon Sep 17 00:00:00 2001 From: Fionn Malone Date: Thu, 19 Oct 2023 19:19:04 +0000 Subject: [PATCH 1/6] Add resource estimates requirements as extras_require. --- setup.py | 56 +++++++++++++++++++++++++++++++------------------------- 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/setup.py b/setup.py index 6bb072219..dc318e0b9 100755 --- a/setup.py +++ b/setup.py @@ -12,53 +12,59 @@ import io import os -from setuptools import setup, find_packages - +from setuptools import find_packages, setup # This reads the __version__ variable from openfermion/_version.py -__version__ = '' -exec(open('src/openfermion/_version.py').read()) +__version__ = "" +exec(open("src/openfermion/_version.py").read()) # Readme file as long_description: -long_description = ('===========\n' + - 'OpenFermion\n' + - '===========\n') -stream = io.open('README.rst', encoding='utf-8') +long_description = "===========\n" + "OpenFermion\n" + "===========\n" +stream = io.open("README.rst", encoding="utf-8") stream.readline() long_description += stream.read() # Read in package requirements.txt -requirements = open('dev_tools/requirements/deps/runtime.txt').readlines() +requirements = open("dev_tools/requirements/deps/runtime.txt").readlines() requirements = [r.strip() for r in requirements] -requirements = [r for r in requirements if not r.startswith('#')] +requirements = [r for r in requirements if not r.startswith("#")] +# Resource estimates requirements. +resource_requirements = open( + "dev_tools/requirements/deps/resource_estimates.txt" +).readlines() +resource_requirements = [r.strip() for r in resource_requirements] +resource_requirements = [r for r in resource_requirements if not r.startswith("#")] -docs_files_gen = os.walk('docs') +docs_files_gen = os.walk("docs") docs_data_files_tuples = [] for cwd, subdirs, files in list(docs_files_gen)[1:]: - if 'ipynb_checkpoints' in cwd: + if "ipynb_checkpoints" in cwd: continue docs_data_files_tuples.append( - (os.path.join('openfermion', - cwd), [os.path.join(cwd, file) for file in files])) + (os.path.join("openfermion", cwd), [os.path.join(cwd, file) for file in files]) + ) setup( - name='openfermion', + name="openfermion", version=__version__, - author='The OpenFermion Developers', - author_email='help@openfermion.org', - url='http://www.openfermion.org', - description=('The electronic structure package for quantum computers.'), + author="The OpenFermion Developers", + author_email="help@openfermion.org", + url="http://www.openfermion.org", + description=("The electronic structure package for quantum computers."), long_description=long_description, install_requires=requirements, - license='Apache 2', - packages=find_packages(where='src'), - package_dir={'': 'src'}, + license="Apache 2", + packages=find_packages(where="src"), + package_dir={"": "src"}, include_package_data=True, package_data={ - '': [ - os.path.join('src', 'openfermion', 'testing', '*.npy'), - os.path.join('src', 'openfermion', 'testing', '*.hdf5'), + "": [ + os.path.join("src", "openfermion", "testing", "*.npy"), + os.path.join("src", "openfermion", "testing", "*.hdf5"), ], }, + extras_require={ + "resources": resource_requirements, + }, data_files=docs_data_files_tuples, ) From 912e5e983b194873f9670e6a49a5857a1529db1b Mon Sep 17 00:00:00 2001 From: Fionn Malone Date: Fri, 20 Oct 2023 19:03:43 +0000 Subject: [PATCH 2/6] Update readmes. --- src/openfermion/resource_estimates/README.md | 7 ++----- src/openfermion/resource_estimates/pbc/README.md | 11 +++++------ 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/openfermion/resource_estimates/README.md b/src/openfermion/resource_estimates/README.md index de2c44163..869bdd89f 100644 --- a/src/openfermion/resource_estimates/README.md +++ b/src/openfermion/resource_estimates/README.md @@ -2,13 +2,10 @@ Code is system tested on Debian GNU/Linux with Python 3.8.5. All the code comes with tests (use `pytest`), but not unit tested with GitHub worflows. -Since the FT costing is closely tied to manipulation of molecular integrals (localization, active space selection, benchmarking against CCSD(T), ...) the code depends on [PySCF](https://pyscf.org/). Since we do not want to burden all OpenFermion users with this dependency, testing is disabled in the GitHub workflow. Moreover, the `resource_estimates` functionality requires the dependencies +Since the FT costing is closely tied to manipulation of molecular integrals (localization, active space selection, benchmarking against CCSD(T), ...) the code depends on [PySCF](https://pyscf.org/) and is not installed by default. To install it do: ``` -pyscf -h5py~=3.3.0 -jax -jaxlib +pip install openfermion[resources] ``` For THC factorization, it also requires [BTAS](https://github.com/ValeevGroup/BTAS) and the [PyBTAS](https://github.com/ncrubin/pybtas) wrapper, which require their own installation + depends. diff --git a/src/openfermion/resource_estimates/pbc/README.md b/src/openfermion/resource_estimates/pbc/README.md index 8d0a6577c..5cb327ad7 100644 --- a/src/openfermion/resource_estimates/pbc/README.md +++ b/src/openfermion/resource_estimates/pbc/README.md @@ -76,11 +76,10 @@ Further details are provided in a [tutorial](./notebooks/resource_estimates.ipyn Similar to the case of molecular resource estimation, we do not wish to burden all OpenFermion users with these dependencies, and testing with GitHub workflows is disabled. Currently we only check if pyscf is available. If it is then pytest will pick up the pbc module and run the tests. Note the tests can be quite slow due to the cost associated with building the integrals. -## Requirements -Requirements can be found in [resource_estimates.txt](../../../../dev_tools/requirements/deps/resource_estimates.txt) +## Installation + +The additional requirements required can be installed with openfermion by doing + ``` -pyscf -jax -jaxlib -ase +pip install openfermion[resources] ``` \ No newline at end of file From 3f10d93df660ffe079ebc10afc23635fe7150c2d Mon Sep 17 00:00:00 2001 From: Fionn Malone Date: Tue, 24 Oct 2023 17:41:53 +0000 Subject: [PATCH 3/6] Fix quoutes. --- setup.py | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/setup.py b/setup.py index dc318e0b9..d704bd8da 100755 --- a/setup.py +++ b/setup.py @@ -15,56 +15,56 @@ from setuptools import find_packages, setup # This reads the __version__ variable from openfermion/_version.py -__version__ = "" -exec(open("src/openfermion/_version.py").read()) +__version__ = '' +exec(open('src/openfermion/_version.py').read()) # Readme file as long_description: -long_description = "===========\n" + "OpenFermion\n" + "===========\n" -stream = io.open("README.rst", encoding="utf-8") +long_description = '===========\n' + 'OpenFermion\n' + '===========\n' +stream = io.open('README.rst', encoding='utf-8') stream.readline() long_description += stream.read() # Read in package requirements.txt -requirements = open("dev_tools/requirements/deps/runtime.txt").readlines() +requirements = open('dev_tools/requirements/deps/runtime.txt').readlines() requirements = [r.strip() for r in requirements] -requirements = [r for r in requirements if not r.startswith("#")] +requirements = [r for r in requirements if not r.startswith('#')] # Resource estimates requirements. resource_requirements = open( - "dev_tools/requirements/deps/resource_estimates.txt" + 'dev_tools/requirements/deps/resource_estimates.txt' ).readlines() resource_requirements = [r.strip() for r in resource_requirements] -resource_requirements = [r for r in resource_requirements if not r.startswith("#")] +resource_requirements = [r for r in resource_requirements if not r.startswith('#')] -docs_files_gen = os.walk("docs") +docs_files_gen = os.walk('docs') docs_data_files_tuples = [] for cwd, subdirs, files in list(docs_files_gen)[1:]: - if "ipynb_checkpoints" in cwd: + if 'ipynb_checkpoints' in cwd: continue docs_data_files_tuples.append( - (os.path.join("openfermion", cwd), [os.path.join(cwd, file) for file in files]) + (os.path.join('openfermion', cwd), [os.path.join(cwd, file) for file in files]) ) setup( - name="openfermion", + name='openfermion', version=__version__, - author="The OpenFermion Developers", - author_email="help@openfermion.org", - url="http://www.openfermion.org", - description=("The electronic structure package for quantum computers."), + author='The OpenFermion Developers', + author_email='help@openfermion.org', + url='http://www.openfermion.org', + description=('The electronic structure package for quantum computers.'), long_description=long_description, install_requires=requirements, - license="Apache 2", - packages=find_packages(where="src"), - package_dir={"": "src"}, + license='Apache 2', + packages=find_packages(where='src'), + package_dir={'': 'src'}, include_package_data=True, package_data={ - "": [ - os.path.join("src", "openfermion", "testing", "*.npy"), - os.path.join("src", "openfermion", "testing", "*.hdf5"), + '': [ + os.path.join('src', 'openfermion', 'testing', '*.npy'), + os.path.join('src', 'openfermion', 'testing', '*.hdf5'), ], }, extras_require={ - "resources": resource_requirements, + 'resources': resource_requirements, }, data_files=docs_data_files_tuples, ) From 55f29971dda9066ca0df8d109bb91e2b65e5a163 Mon Sep 17 00:00:00 2001 From: Fionn Malone Date: Tue, 24 Oct 2023 17:43:24 +0000 Subject: [PATCH 4/6] Move to max line length of 100. --- dev_tools/conf/.pylintrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev_tools/conf/.pylintrc b/dev_tools/conf/.pylintrc index 2cf56b905..1b58f4379 100644 --- a/dev_tools/conf/.pylintrc +++ b/dev_tools/conf/.pylintrc @@ -1,5 +1,5 @@ [config] -max-line-length=80 +max-line-length=100 disable=all ignore-patterns=.*_pb2\.py,quantum_engine_service_client.py,engine_pb2_grpc.py output-format=colorized From d4669534a95760a8b909c171e336ec72c49d6115 Mon Sep 17 00:00:00 2001 From: Fionn Malone Date: Tue, 24 Oct 2023 17:43:54 +0000 Subject: [PATCH 5/6] Add black configuration to pyproject.toml. --- pyproject.toml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 000000000..c9f589cb2 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,5 @@ +[tool.black] +line-length = 100 +target_version = ['py39', 'py310'] +skip-string-normalization = true +skip-magic-trailing-comma = true From f435610a75b431d3cb3bfb583b78a84c3c754c91 Mon Sep 17 00:00:00 2001 From: Fionn Malone Date: Tue, 24 Oct 2023 17:46:06 +0000 Subject: [PATCH 6/6] Fix formatting. --- setup.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/setup.py b/setup.py index d704bd8da..e1f8989ba 100755 --- a/setup.py +++ b/setup.py @@ -29,9 +29,7 @@ requirements = [r.strip() for r in requirements] requirements = [r for r in requirements if not r.startswith('#')] # Resource estimates requirements. -resource_requirements = open( - 'dev_tools/requirements/deps/resource_estimates.txt' -).readlines() +resource_requirements = open('dev_tools/requirements/deps/resource_estimates.txt').readlines() resource_requirements = [r.strip() for r in resource_requirements] resource_requirements = [r for r in resource_requirements if not r.startswith('#')] @@ -61,10 +59,8 @@ '': [ os.path.join('src', 'openfermion', 'testing', '*.npy'), os.path.join('src', 'openfermion', 'testing', '*.hdf5'), - ], - }, - extras_require={ - 'resources': resource_requirements, + ] }, + extras_require={'resources': resource_requirements}, data_files=docs_data_files_tuples, )