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

Project: split dev and test dependencies #213

Merged
merged 8 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .github/workflows/lint-and-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ jobs:
python -m pip install --upgrade pip setuptools wheel
python -m pip install --upgrade -r requirements.txt
python -m pip install --upgrade -r requirements/development.txt
python -m pip install --upgrade -r requirements/testing.txt

- name: Lint with flake8
run: |
Expand Down
23 changes: 19 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Following initiative from the author of Material for MkDocs, this plugin provide

Clone the repository:

```bash
```sh
# install development dependencies
python -m pip install -U -r requirements/development.txt
# alternatively: pip install -e .[dev]
Expand All @@ -77,18 +77,33 @@ python -m pip install -e .

# install git hooks
pre-commit install
```

Then follow the [contribution guidelines](CONTRIBUTING.md).

### Run the tests

```sh
# install development dependencies
python -m pip install -U -r requirements/testing.txt
# alternatively: pip install -e .[test]

# run tests
pytest
```

### Build the documentation

```sh
# install dependencies for documentation
python -m pip install -U -r requirements/documentation.txt
# alternatively: pip install -e .[doc]
```

Then follow the [contribution guidelines](CONTRIBUTING.md).
# build the documentation
mkdocs build
```

## Release workflow
### Release workflow

1. Fill the `CHANGELOG.md`
1. Change the version number in `__about__.py`
Expand Down
9 changes: 5 additions & 4 deletions requirements/development.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
# Development
# -----------------------
black
feedparser>=6.0,<6.1
flake8>=4,<7
flake8>=6,<7
flake8-bugbear>=23.12
flake8-builtins>=2.1
flake8-eradicate>=1
flake8-isort>=6
pre-commit>=3,<4
pytest-cov>=4,<4.2
validator-collection>=1.5,<1.6
9 changes: 9 additions & 0 deletions requirements/testing.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-r base.txt

# Testing
# -------

feedparser>=6.0,<6.1
mkdocs-material>=9
pytest-cov>=4,<4.2
validator-collection>=1.5,<1.6
59 changes: 36 additions & 23 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
# ##################################

# standard library
import pathlib
from pathlib import Path
from typing import List, Union

# 3rd party
from setuptools import find_packages, setup
Expand All @@ -17,30 +18,40 @@
# ########## Globals #############
# ################################

HERE = pathlib.Path(__file__).parent
HERE = Path(__file__).parent
README = (HERE / "README.md").read_text()

with open(HERE / "requirements/base.txt") as f:
requirements = [
line
for line in f.read().splitlines()
if not line.startswith(("#", "-")) and len(line)
]
# ############################################################################
# ########### Functions ############
# ##################################


def load_requirements(requirements_files: Union[Path, List[Path]]) -> list:
"""Helper to load requirements list from a path or a list of paths.

Args:
requirements_files (Path | list[Path]): path or list to paths of requirements
file(s)

Returns:
list: list of requirements loaded from file(s)
"""
out_requirements = []

with open(HERE / "requirements/development.txt") as f:
requirements_dev = [
line
for line in f.read().splitlines()
if not line.startswith(("#", "-")) and len(line)
]
if isinstance(requirements_files, Path):
requirements_files = [
requirements_files,
]

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

with open(HERE / "requirements/documentation.txt") as f:
requirements_docs = [
line
for line in f.read().splitlines()
if not line.startswith(("#", "-")) and len(line)
]
return out_requirements


# ############################################################################
Expand Down Expand Up @@ -70,10 +81,12 @@
# dependencies
python_requires=">=3.8, <4",
extras_require={
"dev": requirements_dev,
"doc": requirements_docs,
# tooling
"dev": load_requirements(HERE / "requirements/development.txt"),
"doc": load_requirements(HERE / "requirements/documentation.txt"),
"test": load_requirements(HERE / "requirements/testing.txt"),
},
install_requires=requirements,
install_requires=load_requirements(HERE / "requirements/base.txt"),
# metadata
keywords="mkdocs rss git plugin",
classifiers=[
Expand Down