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

Replacing requirement files and setup.py with pyproject.toml #70

Merged
merged 22 commits into from
Jun 29, 2023
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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
4 changes: 2 additions & 2 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ This workflow checks that the code is formatted properly and follows the style g

This workflow installs the latest version of tox and runs [the current repository's tests](/tests/#test-py-environments) under each supported Python version on Linux and under a single Python version on macOS and Windows. This is the primary testing workflow. It runs for all code changes and additionally once per day, to ensure tests continue to pass as new versions of dependencies are released.

## Development version tests (`test_development_versions.yml`)
<!-- ## Development version tests (`test_development_versions.yml`)

This workflow installs tox and modifies `requirements.txt` to use the _development_ versions of all Qiskit packages. For all other packages, the latest version is installed. This workflow runs on two versions of Python: the minimum supported version and the maximum supported version. Its purpose is to identify as soon as possible (i.e., before a Qiskit release) when changes in Qiskit will break the current repository. This workflow runs for all code changes, as well as on a timer once per day.

## Minimum version tests (`test_minimum_versions.yml`)

This workflow first installs the minimum supported tox version (the `minversion` specified in [`tox.ini`](/tox.ini)) and then installs the _minimum_ compatible version of each package listed in `requirements.txt` and `requirements-dev.txt`. The purpose of this workflow is to make sure the minimum version specifiers in these files are accurate, i.e., that the tests actually pass with these versions. This workflow uses a single Python version, typically the oldest supported version, as the minimum supported versions of each package may not be compatible with the most recent Python release.

Under the hood, this workflow uses a regular expression to change each `>=` and `~=` specifier in the requirements files to instead be `==`, as pip [does not support](https://github.com/pypa/pip/issues/8085) resolving the minimum versions of packages directly. Unfortunately, this means that the workflow will only install the minimum version of a package if it is _explicitly_ listed in one of the requirements files with a minimum version. For instance, a requirements file that simply lists `qiskit>=0.34` will actually install `qiskit==0.34` (i.e., the minimum version of the _meta_-package) along with the latest versions of `qiskit-terra` and `qiskit-aer`, unless their minimum versions are specified explicitly as well.
Under the hood, this workflow uses a regular expression to change each `>=` and `~=` specifier in the requirements files to instead be `==`, as pip [does not support](https://github.com/pypa/pip/issues/8085) resolving the minimum versions of packages directly. Unfortunately, this means that the workflow will only install the minimum version of a package if it is _explicitly_ listed in one of the requirements files with a minimum version. For instance, a requirements file that simply lists `qiskit>=0.34` will actually install `qiskit==0.34` (i.e., the minimum version of the _meta_-package) along with the latest versions of `qiskit-terra` and `qiskit-aer`, unless their minimum versions are specified explicitly as well. -->

## Code coverage (`coverage.yml`)

Expand Down
50 changes: 0 additions & 50 deletions .github/workflows/test_development_versions.yml

This file was deleted.

47 changes: 0 additions & 47 deletions .github/workflows/test_minimum_versions.yml

This file was deleted.

5 changes: 3 additions & 2 deletions docs/file-map-and-description.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ File descriptions for template
[Most popular open-source licenses](https://opensource.org/licenses).
- [README.md](../README.md) - main readme for repository.
- [docs](../docs) - documentation for repository.
- [requirements.txt](../requirements.txt) - list of required 3rd party packages to run your project.
<!-- - [requirements.txt](../requirements.txt) - list of required 3rd party packages to run your project.
- [requirements-dev.txt](../requirements-dev.txt) - list of required 3rd party packages that are
NOT required to run your project, but which might benefit developers. It can include specific test
libraries, style checks packages etc.
libraries, style checks packages etc. -->
Copy link
Member

Choose a reason for hiding this comment

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

Can you remove these lines containing requirements.txt and requirements-dev.txt? (since there is no chance in them coming back)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That has been resolved.

Copy link
Member

@garrison garrison Jun 29, 2023

Choose a reason for hiding this comment

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

Can you double check? I think you removed a different commented region, actually, than this one in c3a3519. I was thinking it makes sense to keep the explanations in README.md commented out since (we hope) the development and minimum version tests will re-appear in a subsequent PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hello @garrison you can check my last push a4a72f7 it contains the changes you requested.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have also re-added the comment section I wrongly removed previously. Sorry about that.

- [pyproject.toml](../pyproject.toml) - file that contains the build system requirments for your python project
robotAstray marked this conversation as resolved.
Show resolved Hide resolved
- [setup.py](../setup.py) - file that tells package managers how to use your project.
robotAstray marked this conversation as resolved.
Show resolved Hide resolved
This is the main configuration file for all Python projects.
- [tests](../tests) - folder where all project tests are located.
Expand Down
54 changes: 54 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# file pyproject.toml

[project]
name = "prototype_template"
dynamic = [
"version",
]
readme = "README.md"
requires-python = ">=3.7"
license = {file = "LICENSE.txt"}
description = "Repository for a quantum prototype"
authors = [
{ name = "My Name", email = "my.email@email.net"},
]

dependencies = [
"certifi>=2021.5.30",
"importlib_metadata>=4.8.1",
"qiskit-aer>=0.10.3",
"qiskit-terra>=0.19.2",
]

[project.optional-dependencies]
# Dev dependencies.
dev = [
"coverage>=5.5",
"pylint>=2.9.5",
"nbqa>=1.1.1",
"treon>=0.1.3",
"pytest>=6.2.5",
"pytest-randomly>=1.2.0",
"mypy>=0.780",
"mypy-extensions>=0.4.3",
"jupyter-sphinx>=0.3.2",
"nbsphinx>=0.8.8",
"sphinx-autodoc-typehints>=1.17.0",
"reno>=3.5.0",
# Black's formatting rules can change between major versions, so we use
# the ~= specifier for it.
"black[jupyter]~=22.1",
]

[project.urls]
"Homepage" = "https://github.com/qiskit-community/quantum-prototype-template"
"Bug Tracker" = "https://github.com/qiskit-community/quantum-prototype-template/issues"

[build-system]
requires = [
"setuptools>=61.0",
"wheel",
"toml",
"setuptools-scm",
]
build-backend = "setuptools.build_meta"
15 changes: 0 additions & 15 deletions requirements-dev.txt

This file was deleted.

4 changes: 0 additions & 4 deletions requirements.txt

This file was deleted.

24 changes: 5 additions & 19 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,7 @@
"""Setup file for prototype template."""
# See pyproject.toml for project configuration.
# This file exists for compatibility with legacy tools:
# https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html

import setuptools
from setuptools import setup

with open("README.md", encoding="utf-8") as f:
long_description = f.read()

with open("requirements.txt") as f:
install_requires = f.read().splitlines()

setuptools.setup(
name="prototype_template",
description="Repository for a quantum prototype",
long_description=long_description,
long_description_content_type="text/markdown",
packages=setuptools.find_packages(),
install_requires=install_requires,
python_requires=">=3.7",
setup_requires=["setuptools_scm"],
use_scm_version=True,
)
setup()
7 changes: 3 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ setenv =
VIRTUAL_ENV={envdir}
LANGUAGE=en_US
LC_ALL=en_US.utf-8
deps = -rrequirements.txt
-rrequirements-dev.txt
extras = dev
commands =
pip check
python -m pytest -v --doctest-modules
Expand All @@ -22,6 +21,7 @@ commands =
[testenv:lint]
envdir = .tox/lint
skip_install = true
allowlist_externals = pylint, nbqa
robotAstray marked this conversation as resolved.
Show resolved Hide resolved
commands =
black --check .
pylint -rn prototype_template tests
Expand All @@ -44,8 +44,7 @@ commands =

[testenv:docs]
skip_install = false
deps =
-rrequirements-dev.txt
extras = dev
commands =
sphinx-build -b html -W -T --keep-going {posargs} docs/ docs/_build/html

Expand Down