From 36610dd11360dc93e1c5e7c320822058121420cd Mon Sep 17 00:00:00 2001 From: Tobias Hangleiter Date: Fri, 18 Feb 2022 12:48:20 +0100 Subject: [PATCH 1/7] Move all configuration to pyproject.toml --- .coveragerc | 7 ---- pyproject.toml | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++ pytest.ini | 7 ---- setup.cfg | 3 -- setup.py | 53 +++--------------------------- 5 files changed, 92 insertions(+), 66 deletions(-) delete mode 100644 .coveragerc create mode 100644 pyproject.toml delete mode 100644 pytest.ini delete mode 100644 setup.cfg diff --git a/.coveragerc b/.coveragerc deleted file mode 100644 index b3b2d15..0000000 --- a/.coveragerc +++ /dev/null @@ -1,7 +0,0 @@ -[run] -branch = True - -[report] -omit = - */tests/* - */__init__.py \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..b97b825 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,88 @@ +[build-system] +requires = [ + "setuptools >= 42", + "versioningit", + "wheel", +] +build-backend = "setuptools.build_meta" + +[project] +name = "filter_functions" +description = "Package for efficient calculation of generalized filter functions" +readme = "README.md" +requires_python = ">= 3.7" +license = {file = "LICENSE"} +authors = [ + {name = "Quantum Technology Group, RWTH Aachen University"}, + {name = "Tobias Hangleiter", email = "tobias.hangleiter@rwth-aachen.de"}, +] +classifiers = [ + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)", + "Operating System :: OS Independent", + "Topic :: Scientific/Engineering :: Physics", +] +dependencies = [ + "numpy", + "scipy", + "opt_einsum", + "sparse", + "tqdm", +] +dynamic = [ + "version" +] + +[project.optional-dependencies] +plotting = ["matplotlib"] +bloch_sphere_visualization = ["qutip", "matplotlib"] +fancy_progressbar = ["ipynbname", "jupyter"] +doc = ["jupyter", "nbsphinx", "numpydoc", "sphinx", "sphinx_rtd_theme"] +tests = ["pytest >= 4.6", "pytest-cov", "codecov"] +all = [ + # Combined dependency resolution would be nice! + # https://discuss.python.org/t/pyproject-toml-optional-dependencies-redundancy-aka-dry-extras/8428 + "matplotlib", + "qutip", + "ipynbname", + "jupyter", + "nbsphinx", + "numpydoc", + "sphinx", + "sphinx_rtd_theme", + "pytest >= 4.6", + "pytest-cov", + "codecov", +] + +[project.urls] +Source = "https://github.com/qutech/filter_functions" +Documentation = "https://filter-functions.readthedocs.io/en/latest/" +Homepage = "https://www.quantuminfo.physik.rwth-aachen.de/cms/Quantuminfo/Forschung/Quantum-Technology-Group/~zcsx/code/lidx/1/" + +# Dynamically obtains the version from git tags +[tool.versioningit] + +[tool.pytest.ini_options] +minversion = "4.6" +addopts = "-ra --verbose --cov=filter_functions --cov-report=xml" +testpaths = [ + "tests" +] + +[tool.coverage.run] +branch = true + +[tool.coverage.report] +omit = ["tests/*", "*/__init__.py"] + +[tool.pylint.'MESSAGES CONTROL'] +disable = "E123,E226,W504" + +[tool.pylint.FORMAT] +# Maximum number of characters on a single line. +max-line-length = 99 diff --git a/pytest.ini b/pytest.ini deleted file mode 100644 index 0925052..0000000 --- a/pytest.ini +++ /dev/null @@ -1,7 +0,0 @@ -[pytest] -addopts = - -ra - --verbose - --cov=filter_functions - --cov-config=.coveragerc - --cov-report=xml diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 4de2bb9..0000000 --- a/setup.cfg +++ /dev/null @@ -1,3 +0,0 @@ -[flake8] -max-line-length = 99 -ignore = E123,E226,W504 diff --git a/setup.py b/setup.py index edc38a9..0a50772 100644 --- a/setup.py +++ b/setup.py @@ -1,51 +1,6 @@ # -*- coding: utf-8 -*- -import os -import re -import sys +"""Shim to enable editable install.""" +import setuptools -from setuptools import setup - - -def read(*args): - return open(os.path.join(os.path.dirname(__file__), *args), encoding='utf8').read() - - -def extract_version(version_file): - version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", version_file, re.M) - if version_match: - return version_match.group(1) - - raise RuntimeError("Unable to find version string.") - - -if sys.version_info < (3, 7): - sys.stderr.write('ERROR: You need Python 3.7 or later to install this package.\n') - exit(1) - -extras_require = {'plotting': ['matplotlib'], - 'bloch_sphere_visualization': ['qutip', 'matplotlib'], - 'fancy_progressbar': ['ipynbname', 'jupyter'], - 'doc': ['jupyter', 'nbsphinx', 'numpydoc', 'sphinx', 'sphinx_rtd_theme'], - 'tests': ['pytest>=4.6', 'pytest-cov', 'codecov']} - -extras_require['all'] = [dep for deps in extras_require.values() for dep in deps] - -setup(name='filter_functions', - version=extract_version(read('filter_functions', '__init__.py')), - description='Package for efficient calculation of generalized filter functions', - long_description=read('README.md'), - long_description_content_type='text/markdown', - url='https://github.com/qutech/filter_functions', - author='Quantum Technology Group, RWTH Aachen University', - author_email='tobias.hangleiter@rwth-aachen.de', - packages=['filter_functions'], - package_dir={'filter_functions': 'filter_functions'}, - install_requires=['numpy', 'scipy', 'opt_einsum', 'sparse', 'tqdm'], - extras_require=extras_require, - test_suite='tests', - classifiers=[ - 'Programming Language :: Python :: 3', - 'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)', - 'Operating System :: OS Independent', - 'Topic :: Scientific/Engineering :: Physics', - ]) +if __name__ == "__main__": + setuptools.setup() From d8cf10395c2bdf5b9428ab94df53d5c7e10ce79e Mon Sep 17 00:00:00 2001 From: Tobias Hangleiter Date: Fri, 18 Feb 2022 13:20:41 +0100 Subject: [PATCH 2/7] Add shim setup.cfg file apparently still needed --- setup.cfg | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 setup.cfg diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..d6e13cc --- /dev/null +++ b/setup.cfg @@ -0,0 +1,2 @@ +[metadata] +name = filter_functions From a7b13b566d46aa7eda02a01390f0f73e18b79202 Mon Sep 17 00:00:00 2001 From: Tobias Hangleiter Date: Fri, 18 Feb 2022 15:32:38 +0100 Subject: [PATCH 3/7] Use ppsetuptools to work around PEP 621 not being implemented --- pyproject.toml | 13 +++++++++---- setup.cfg | 2 -- setup.py | 5 ++--- 3 files changed, 11 insertions(+), 9 deletions(-) delete mode 100644 setup.cfg diff --git a/pyproject.toml b/pyproject.toml index b97b825..876479d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,8 +1,10 @@ [build-system] requires = [ "setuptools >= 42", + "ppsetuptools", "versioningit", - "wheel", + "wheel >= 0.35.1", + "toml >= 0.10.1", ] build-backend = "setuptools.build_meta" @@ -10,7 +12,7 @@ build-backend = "setuptools.build_meta" name = "filter_functions" description = "Package for efficient calculation of generalized filter functions" readme = "README.md" -requires_python = ">= 3.7" +requires_python = ">= 3.7, <4" license = {file = "LICENSE"} authors = [ {name = "Quantum Technology Group, RWTH Aachen University"}, @@ -36,6 +38,7 @@ dependencies = [ dynamic = [ "version" ] +keywords = ["physics", "numerics", "quantum information", "quantum computing", "noise"] [project.optional-dependencies] plotting = ["matplotlib"] @@ -67,6 +70,10 @@ Homepage = "https://www.quantuminfo.physik.rwth-aachen.de/cms/Quantuminfo/Forsch # Dynamically obtains the version from git tags [tool.versioningit] +[tool.versioningit.vcs] +method = "git" +match = ["v*"] + [tool.pytest.ini_options] minversion = "4.6" addopts = "-ra --verbose --cov=filter_functions --cov-report=xml" @@ -76,8 +83,6 @@ testpaths = [ [tool.coverage.run] branch = true - -[tool.coverage.report] omit = ["tests/*", "*/__init__.py"] [tool.pylint.'MESSAGES CONTROL'] diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index d6e13cc..0000000 --- a/setup.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[metadata] -name = filter_functions diff --git a/setup.py b/setup.py index 0a50772..c53f32f 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- """Shim to enable editable install.""" -import setuptools +from ppsetuptools import setup -if __name__ == "__main__": - setuptools.setup() +setup() From a419af57712a1164f4fa4647890c312ae51cb917 Mon Sep 17 00:00:00 2001 From: Tobias Hangleiter Date: Mon, 7 Oct 2024 16:33:07 +0200 Subject: [PATCH 4/7] Change build backend to hatch --- .github/workflows/main.yml | 8 ++--- pyproject.toml | 72 +++++++++++++++++++++++--------------- 2 files changed, 47 insertions(+), 33 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a761856..4ccadea 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -27,11 +27,11 @@ jobs: - name: Install run: | python -m pip install --upgrade pip - pip install .[${{ matrix.install_extras }}] + python -m pip install .[${{ matrix.install_extras }}] - name: Test with pytest run: | - pytest + python -m hatch run tests:run - name: Upload coverage to Codecov uses: codecov/codecov-action@v4 @@ -60,11 +60,11 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install setuptools wheel twine + pip install hatch - name: Build package run: | - python setup.py sdist bdist_wheel + python -m hatch build - name: Publish package env: diff --git a/pyproject.toml b/pyproject.toml index 876479d..9e786dd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,33 +1,30 @@ [build-system] -requires = [ - "setuptools >= 42", - "ppsetuptools", - "versioningit", - "wheel >= 0.35.1", - "toml >= 0.10.1", -] -build-backend = "setuptools.build_meta" +requires = ["hatchling"] +build-backend = "hatchling.build" [project] name = "filter_functions" description = "Package for efficient calculation of generalized filter functions" readme = "README.md" -requires_python = ">= 3.7, <4" +requires_python = ">= 3.8" license = {file = "LICENSE"} +dynamic = ["version"] authors = [ - {name = "Quantum Technology Group, RWTH Aachen University"}, {name = "Tobias Hangleiter", email = "tobias.hangleiter@rwth-aachen.de"}, + {name = "Quantum Technology Group, RWTH Aachen University"}, ] classifiers = [ "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)", "Operating System :: OS Independent", "Topic :: Scientific/Engineering :: Physics", ] +keywords = ["physics", "numerics", "quantum information", "quantum computing", "noise"] dependencies = [ "numpy", "scipy", @@ -35,31 +32,38 @@ dependencies = [ "sparse", "tqdm", ] -dynamic = [ - "version" -] -keywords = ["physics", "numerics", "quantum information", "quantum computing", "noise"] [project.optional-dependencies] plotting = ["matplotlib"] -bloch_sphere_visualization = ["qutip", "matplotlib"] -fancy_progressbar = ["ipynbname", "jupyter"] -doc = ["jupyter", "nbsphinx", "numpydoc", "sphinx", "sphinx_rtd_theme"] -tests = ["pytest >= 4.6", "pytest-cov", "codecov"] -all = [ - # Combined dependency resolution would be nice! - # https://discuss.python.org/t/pyproject-toml-optional-dependencies-redundancy-aka-dry-extras/8428 - "matplotlib", +bloch_sphere_visualization = [ + "filter_functions[plotting]", "qutip", +] +fancy_progressbar = [ "ipynbname", + "jupyter" +] +doc = [ "jupyter", "nbsphinx", "numpydoc", "sphinx", "sphinx_rtd_theme", + "ipympl", + "qutip-qip", + "qutip-qtrl" +] +tests = [ "pytest >= 4.6", "pytest-cov", - "codecov", + "codecov" +] +all = [ + "filter_functions[plotting]", + "filter_functions[bloch_sphere_visualization]", + "filter_functions[fancy_progressbar]", + "filter_functions[doc]", + "filter_functions[tests]", ] [project.urls] @@ -67,12 +71,22 @@ Source = "https://github.com/qutech/filter_functions" Documentation = "https://filter-functions.readthedocs.io/en/latest/" Homepage = "https://www.quantuminfo.physik.rwth-aachen.de/cms/Quantuminfo/Forschung/Quantum-Technology-Group/~zcsx/code/lidx/1/" -# Dynamically obtains the version from git tags -[tool.versioningit] +[tool.hatch.version] +path = "filter_functions/__init__.py" -[tool.versioningit.vcs] -method = "git" -match = ["v*"] +[tool.hatch.envs.tests] +features = ["tests"] +[tool.hatch.envs.tests.scripts] +run = ["python -m pytest"] + +[tool.hatch.envs.doc] +features = [ + "doc", +] +[tool.hatch.envs.doc.scripts] +build = [ + "sphinx-build -b html doc/source public" +] [tool.pytest.ini_options] minversion = "4.6" From af1e8acfaee178a10ad5ade407aec4e3108ff251 Mon Sep 17 00:00:00 2001 From: Tobias Hangleiter Date: Mon, 7 Oct 2024 16:33:31 +0200 Subject: [PATCH 5/7] Small rtd changes --- .readthedocs.yml | 5 +++++ environment.yml | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.readthedocs.yml b/.readthedocs.yml index dcabba2..e07d9d5 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -21,3 +21,8 @@ python: sphinx: builder: html configuration: doc/source/conf.py + +formats: + - pdf + - epub + - \ No newline at end of file diff --git a/environment.yml b/environment.yml index 018eb5f..60f7de2 100644 --- a/environment.yml +++ b/environment.yml @@ -1,7 +1,6 @@ name: filter_functions channels: - - defaults - conda-forge dependencies: From d50a0140597bf49f03a29c6a8663db69644cb532 Mon Sep 17 00:00:00 2001 From: Tobias Hangleiter Date: Mon, 7 Oct 2024 17:33:12 +0200 Subject: [PATCH 6/7] Install hatch --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4ccadea..ca2b7cc 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -27,7 +27,7 @@ jobs: - name: Install run: | python -m pip install --upgrade pip - python -m pip install .[${{ matrix.install_extras }}] + python -m pip install hatch .[${{ matrix.install_extras }}] - name: Test with pytest run: | @@ -60,7 +60,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install hatch + python -m pip install hatch - name: Build package run: | From 03ae597025b1027e06b98e07de0fa46916198eed Mon Sep 17 00:00:00 2001 From: Tobias Hangleiter Date: Mon, 7 Oct 2024 17:44:04 +0200 Subject: [PATCH 7/7] Remove auto-dash --- .readthedocs.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.readthedocs.yml b/.readthedocs.yml index e07d9d5..b80ba3c 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -25,4 +25,3 @@ sphinx: formats: - pdf - epub - - \ No newline at end of file