Skip to content

Commit e31831b

Browse files
authored
Project: split dev and test dependencies (#213)
2 parents ba0701f + 8ec8aa3 commit e31831b

5 files changed

Lines changed: 70 additions & 31 deletions

File tree

.github/workflows/lint-and-tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ jobs:
4040
python -m pip install --upgrade pip setuptools wheel
4141
python -m pip install --upgrade -r requirements.txt
4242
python -m pip install --upgrade -r requirements/development.txt
43+
python -m pip install --upgrade -r requirements/testing.txt
4344
4445
- name: Lint with flake8
4546
run: |

README.md

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ Following initiative from the author of Material for MkDocs, this plugin provide
6767
6868
Clone the repository:
6969
70-
```bash
70+
```sh
7171
# install development dependencies
7272
python -m pip install -U -r requirements/development.txt
7373
# alternatively: pip install -e .[dev]
@@ -77,18 +77,33 @@ python -m pip install -e .
7777

7878
# install git hooks
7979
pre-commit install
80+
```
81+
82+
Then follow the [contribution guidelines](CONTRIBUTING.md).
83+
84+
### Run the tests
85+
86+
```sh
87+
# install development dependencies
88+
python -m pip install -U -r requirements/testing.txt
89+
# alternatively: pip install -e .[test]
8090

8191
# run tests
8292
pytest
93+
```
94+
95+
### Build the documentation
8396

97+
```sh
8498
# install dependencies for documentation
8599
python -m pip install -U -r requirements/documentation.txt
86100
# alternatively: pip install -e .[doc]
87-
```
88101

89-
Then follow the [contribution guidelines](CONTRIBUTING.md).
102+
# build the documentation
103+
mkdocs build
104+
```
90105

91-
## Release workflow
106+
### Release workflow
92107

93108
1. Fill the `CHANGELOG.md`
94109
1. Change the version number in `__about__.py`

requirements/development.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
# Development
44
# -----------------------
55
black
6-
feedparser>=6.0,<6.1
7-
flake8>=4,<7
6+
flake8>=6,<7
7+
flake8-bugbear>=23.12
8+
flake8-builtins>=2.1
9+
flake8-eradicate>=1
10+
flake8-isort>=6
811
pre-commit>=3,<4
9-
pytest-cov>=4,<4.2
10-
validator-collection>=1.5,<1.6

requirements/testing.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
-r base.txt
2+
3+
# Testing
4+
# -------
5+
6+
feedparser>=6.0,<6.1
7+
mkdocs-material>=9
8+
pytest-cov>=4,<4.2
9+
validator-collection>=1.5,<1.6

setup.py

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
# ##################################
66

77
# standard library
8-
import pathlib
8+
from pathlib import Path
9+
from typing import List, Union
910

1011
# 3rd party
1112
from setuptools import find_packages, setup
@@ -17,30 +18,40 @@
1718
# ########## Globals #############
1819
# ################################
1920

20-
HERE = pathlib.Path(__file__).parent
21+
HERE = Path(__file__).parent
2122
README = (HERE / "README.md").read_text()
2223

23-
with open(HERE / "requirements/base.txt") as f:
24-
requirements = [
25-
line
26-
for line in f.read().splitlines()
27-
if not line.startswith(("#", "-")) and len(line)
28-
]
24+
# ############################################################################
25+
# ########### Functions ############
26+
# ##################################
27+
28+
29+
def load_requirements(requirements_files: Union[Path, List[Path]]) -> list:
30+
"""Helper to load requirements list from a path or a list of paths.
31+
32+
Args:
33+
requirements_files (Path | list[Path]): path or list to paths of requirements
34+
file(s)
35+
36+
Returns:
37+
list: list of requirements loaded from file(s)
38+
"""
39+
out_requirements = []
2940

30-
with open(HERE / "requirements/development.txt") as f:
31-
requirements_dev = [
32-
line
33-
for line in f.read().splitlines()
34-
if not line.startswith(("#", "-")) and len(line)
35-
]
41+
if isinstance(requirements_files, Path):
42+
requirements_files = [
43+
requirements_files,
44+
]
3645

46+
for requirements_file in requirements_files:
47+
with requirements_file.open(encoding="UTF-8") as f:
48+
out_requirements += [
49+
line
50+
for line in f.read().splitlines()
51+
if not line.startswith(("#", "-")) and len(line)
52+
]
3753

38-
with open(HERE / "requirements/documentation.txt") as f:
39-
requirements_docs = [
40-
line
41-
for line in f.read().splitlines()
42-
if not line.startswith(("#", "-")) and len(line)
43-
]
54+
return out_requirements
4455

4556

4657
# ############################################################################
@@ -70,10 +81,12 @@
7081
# dependencies
7182
python_requires=">=3.8, <4",
7283
extras_require={
73-
"dev": requirements_dev,
74-
"doc": requirements_docs,
84+
# tooling
85+
"dev": load_requirements(HERE / "requirements/development.txt"),
86+
"doc": load_requirements(HERE / "requirements/documentation.txt"),
87+
"test": load_requirements(HERE / "requirements/testing.txt"),
7588
},
76-
install_requires=requirements,
89+
install_requires=load_requirements(HERE / "requirements/base.txt"),
7790
# metadata
7891
keywords="mkdocs rss git plugin",
7992
classifiers=[

0 commit comments

Comments
 (0)