From 97ed509793f88d3695203e6d18c173f67bbe6928 Mon Sep 17 00:00:00 2001 From: GeoJulien Date: Thu, 7 Dec 2023 16:15:08 +0100 Subject: [PATCH 1/8] project: split development and testing dependencies --- requirements/development.txt | 9 +++++---- requirements/testing.txt | 9 +++++++++ 2 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 requirements/testing.txt diff --git a/requirements/development.txt b/requirements/development.txt index 71f82d6e..a8dc549f 100644 --- a/requirements/development.txt +++ b/requirements/development.txt @@ -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 diff --git a/requirements/testing.txt b/requirements/testing.txt new file mode 100644 index 00000000..769ab475 --- /dev/null +++ b/requirements/testing.txt @@ -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 From 2516821ffe05d2c8e630baed6757e0947180ed9b Mon Sep 17 00:00:00 2001 From: GeoJulien Date: Thu, 7 Dec 2023 16:15:20 +0100 Subject: [PATCH 2/8] packaging: improve requirements loading --- setup.py | 58 ++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 23 deletions(-) diff --git a/setup.py b/setup.py index 208101a3..9e12c31f 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ # ################################## # standard library -import pathlib +from pathlib import Path # 3rd party from setuptools import find_packages, setup @@ -17,30 +17,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: 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 # ############################################################################ @@ -70,10 +80,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=[ From 392e0ed65a066cda0dce6afc0c4eb628530ed5de Mon Sep 17 00:00:00 2001 From: GeoJulien Date: Thu, 7 Dec 2023 16:15:34 +0100 Subject: [PATCH 3/8] docs: add how to run the tests and build the doc --- README.md | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index eaf23c3f..b509ec9a 100644 --- a/README.md +++ b/README.md @@ -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] @@ -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` From 7c07079b19613047f9287bf899ffc5f795474c9f Mon Sep 17 00:00:00 2001 From: GeoJulien Date: Thu, 7 Dec 2023 16:19:32 +0100 Subject: [PATCH 4/8] ci: install tests dependencies --- .github/workflows/lint-and-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint-and-tests.yml b/.github/workflows/lint-and-tests.yml index ed571bba..b9d7b131 100644 --- a/.github/workflows/lint-and-tests.yml +++ b/.github/workflows/lint-and-tests.yml @@ -39,7 +39,7 @@ jobs: run: | 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: | From e109b552ffbcc099eb0d9f886205d06c41de8386 Mon Sep 17 00:00:00 2001 From: GeoJulien Date: Thu, 7 Dec 2023 16:22:45 +0100 Subject: [PATCH 5/8] fix: | operator was introduced in Python 3.10 --- setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 9e12c31f..f7b009b2 100644 --- a/setup.py +++ b/setup.py @@ -6,6 +6,7 @@ # standard library from pathlib import Path +from typing import Union # 3rd party from setuptools import find_packages, setup @@ -25,7 +26,7 @@ # ################################## -def load_requirements(requirements_files: Path | list[Path]) -> list: +def load_requirements(requirements_files: Union[Path, list[Path]]) -> list: """Helper to load requirements list from a path or a list of paths. Args: From cd4ffcc9b9d88dca7635d7d5c3dfa0c2cc7b96ad Mon Sep 17 00:00:00 2001 From: GeoJulien Date: Thu, 7 Dec 2023 16:22:59 +0100 Subject: [PATCH 6/8] fix: dev dependencies are required for flake8 --- .github/workflows/lint-and-tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/lint-and-tests.yml b/.github/workflows/lint-and-tests.yml index b9d7b131..dd13acb0 100644 --- a/.github/workflows/lint-and-tests.yml +++ b/.github/workflows/lint-and-tests.yml @@ -39,6 +39,7 @@ jobs: run: | python -m pip install --upgrade pip setuptools wheel python -m pip install --upgrade -r requirements.txt + python -m pip install --upgrade -r requirements/dependencies.txt python -m pip install --upgrade -r requirements/testing.txt - name: Lint with flake8 From 8db2173aad45a904fb54e7c571ee6f34caee27f1 Mon Sep 17 00:00:00 2001 From: GeoJulien Date: Thu, 7 Dec 2023 16:25:38 +0100 Subject: [PATCH 7/8] fixx: typo name requirements --- .github/workflows/lint-and-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint-and-tests.yml b/.github/workflows/lint-and-tests.yml index dd13acb0..531fd898 100644 --- a/.github/workflows/lint-and-tests.yml +++ b/.github/workflows/lint-and-tests.yml @@ -39,7 +39,7 @@ jobs: run: | python -m pip install --upgrade pip setuptools wheel python -m pip install --upgrade -r requirements.txt - python -m pip install --upgrade -r requirements/dependencies.txt + python -m pip install --upgrade -r requirements/development.txt python -m pip install --upgrade -r requirements/testing.txt - name: Lint with flake8 From 8ec8aa33fa483c2af89fe0e02ae13f46f38500e6 Mon Sep 17 00:00:00 2001 From: GeoJulien Date: Thu, 7 Dec 2023 16:29:48 +0100 Subject: [PATCH 8/8] ifx: subscriptable types for type hint not available in 3.8 --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index f7b009b2..b7c2f5cf 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ # standard library from pathlib import Path -from typing import Union +from typing import List, Union # 3rd party from setuptools import find_packages, setup @@ -26,7 +26,7 @@ # ################################## -def load_requirements(requirements_files: Union[Path, list[Path]]) -> list: +def load_requirements(requirements_files: Union[Path, List[Path]]) -> list: """Helper to load requirements list from a path or a list of paths. Args: