Skip to content

Commit

Permalink
Merge pull request #112 from MicaelJarniac/MicaelJarniac/issue111
Browse files Browse the repository at this point in the history
feat: add dependencies to `pyproject.toml`
  • Loading branch information
MicaelJarniac authored May 3, 2023
2 parents 5bd7f97 + ea42a31 commit 35ecaf3
Show file tree
Hide file tree
Showing 8 changed files with 139 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest coverage pytest-cov
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
pip install -e .
pip install -c constraints.txt -e .[tests]
- name: Generate coverage report
run: |
pytest --cov --cov-report=xml
Expand Down
3 changes: 2 additions & 1 deletion {{cookiecutter.project_slug}}/.readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ formats:
# Explicitly set the version of Python and its requirements
python:
install:
- requirements: docs/requirements.txt
- method: pip
path: .
extra_requirements:
- docs
92 changes: 92 additions & 0 deletions {{cookiecutter.project_slug}}/constraints.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
alabaster==0.7.13
argcomplete==3.0.8
Babel==2.12.1
beautifulsoup4==4.12.2
black==23.3.0
bleach==6.0.0
build==0.10.0
certifi==2022.12.7
cffi==1.15.1
cfgv==3.3.1
charset-normalizer==3.1.0
click==8.1.3
click-log==0.4.0
colorama==0.4.6
colorlog==6.7.0
coverage==7.2.5
cryptography==40.0.2
distlib==0.3.6
docutils==0.19
dotty-dict==1.3.1
exceptiongroup==1.1.1
filelock==3.12.0
furo==2023.3.27
gitdb==4.0.10
GitPython==3.1.31
identify==2.5.24
idna==3.4
imagesize==1.4.1
importlib-metadata==6.6.0
importlib-resources==5.12.0
iniconfig==2.0.0
invoke==1.7.3
jaraco.classes==3.2.3
jeepney==0.8.0
Jinja2==3.1.2
keyring==23.13.1
markdown-it-py==2.2.0
MarkupSafe==2.1.2
mdit-py-plugins==0.3.5
mdurl==0.1.2
more-itertools==9.1.0
mypy==1.2.0
mypy-extensions==1.0.0
myst-parser==1.0.0
nodeenv==1.7.0
nox==2023.4.22
packaging==23.1
pathspec==0.11.1
pkginfo==1.9.6
platformdirs==3.5.0
pluggy==1.0.0
pre-commit==3.3.1
pycparser==2.21
pyenchant==3.2.2
Pygments==2.15.1
pyproject_hooks==1.0.0
pytest==7.3.1
pytest-cov==4.0.0
python-gitlab==3.14.0
python-semantic-release==7.33.3
pytz==2023.3
PyYAML==6.0
readme-renderer==37.3
requests==2.29.0
requests-toolbelt==1.0.0
rfc3986==2.0.0
ruff==0.0.264
SecretStorage==3.3.3
semver==2.13.0
six==1.16.0
smmap==5.0.0
snowballstemmer==2.2.0
soupsieve==2.4.1
Sphinx==6.2.1
sphinx-basic-ng==1.0.0b1
sphinxcontrib-applehelp==1.0.4
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp==2.0.1
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.5
sphinxcontrib-spelling==8.0.0
toml==0.10.2
tomli==2.0.1
tomlkit==0.11.8
tqdm==4.65.0
twine==3.8.0
typing_extensions==4.5.0
urllib3==1.26.15
virtualenv==20.23.0
webencodings==0.5.1
zipp==3.15.0
9 changes: 4 additions & 5 deletions {{cookiecutter.project_slug}}/docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ Here is a summary of the steps to follow:
```bash
$ git checkout main
$ git pull upstream main
$ pip install -U -r requirements.txt
$ pip install -U -r requirements-dev.txt
$ pip install -U -c constraints.txt -e .[dev]
```
3. Create a new topic branch (off the main project development branch) to contain your feature, change, or fix:
```bash
Expand Down Expand Up @@ -220,8 +219,7 @@ source venv/bin/activate
.\venv\Scripts\activate

# Install the dependencies
pip install -U -r requirements.txt
pip install -U -r requirements-dev.txt
pip install -U -c constraints.txt -e .[dev]

# Set up pre-commit hooks
pre-commit install
Expand Down Expand Up @@ -275,7 +273,8 @@ make html

### Requirements

Packages that are necessary for the code to run should be on [`requirements.txt`](../requirements.txt), and those only necessary while developing should be on [`requirements-dev.txt`](../requirements-dev.txt).
All requirements should be on [`pyproject.toml`](../pyproject.toml), on their respective sections.
Constraints should be maintained in [`constraints.txt`](../constraints.txt).

To see which installed packages are outdated, run `pip list --outdated`.

Expand Down
4 changes: 0 additions & 4 deletions {{cookiecutter.project_slug}}/docs/requirements.txt

This file was deleted.

19 changes: 9 additions & 10 deletions {{cookiecutter.project_slug}}/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,34 @@

import nox

python_versions = ["3.7", "3.8", "3.9", "3.10"]
python_versions = ["3.8", "3.9", "3.10", "3.11"]
constraints = ("-c", "constraints.txt")


@nox.session(python=python_versions[-1], reuse_venv=True)
@nox.session(python=python_versions[-1])
def format_files(session: nox.Session) -> None:
"""Format files."""
session.install("-r", "requirements-dev.txt")
session.install(*constraints, "ruff", "black")
session.run("ruff", "check", "--fix-only", ".")
session.run("black", ".")


@nox.session(python=python_versions[-1], reuse_venv=True)
@nox.session(python=python_versions[-1])
def lint_files(session: nox.Session) -> None:
"""Lint files."""
session.install("-r", "requirements-dev.txt")
session.install(*constraints, "ruff")
session.run("ruff", "check", ".")


@nox.session(python=python_versions, reuse_venv=True)
@nox.session(python=python_versions)
def type_check_code(session: nox.Session) -> None:
"""Type-check code."""
session.install("-r", "requirements-dev.txt")
session.install(".")
session.install(*constraints, ".[dev]")
session.run("mypy")


@nox.session(python=python_versions)
def test_code(session: nox.Session) -> None:
"""Test code."""
session.install(".")
session.install("pytest")
session.install(*constraints, ".[tests]")
session.run("pytest")
32 changes: 30 additions & 2 deletions {{cookiecutter.project_slug}}/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ authors = [
]
description = "{{ cookiecutter.project_short_description }}"
readme = "docs/README.md"
requires-python = ">=3.7"
requires-python = ">=3.8"
license-files = { paths = ["LICENSE"] }
# Get more from http://pypi.python.org/pypi?%3Aaction=list_classifiers
classifiers = [
Expand All @@ -21,13 +21,41 @@ classifiers = [
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"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",
"Typing :: Typed",
]
dynamic = ["version"]
dependencies = []

[project.optional-dependencies]
# Use `constraints.txt`
tests = [
"coverage",
"pytest",
"pytest-cov",
]
docs = [
"furo",
"myst-parser",
"Sphinx",
"sphinxcontrib-spelling",
]
dev = [
"{{ cookiecutter.project_distribution_name }}[tests,docs]",
"black",
"build",
"mypy",
"mypy-extensions",
"nox",
"pre-commit",
"python-semantic-release",
"ruff",
"semver",
"toml",
]

[project.urls]
"Homepage" = "https://github.com/{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }}"
Expand Down
14 changes: 0 additions & 14 deletions {{cookiecutter.project_slug}}/requirements-dev.txt

This file was deleted.

0 comments on commit 35ecaf3

Please # to comment.