From 4e35509619d5b10027de5f9db68cefac55cdffeb Mon Sep 17 00:00:00 2001 From: Jef Roosens Date: Tue, 18 May 2021 08:57:40 +0200 Subject: [PATCH] Added opinionated project config --- .flake8 | 7 +++++++ Makefile | 46 +++++++++++++++++++++++++++----------------- app/__init__.py | 0 app/__main__.py | 0 pyproject.toml | 2 ++ requirements-dev.txt | 11 ----------- requirements.txt | 2 -- setup.cfg | 25 ++++++++++++++++++++++++ setup.py | 12 ++++++++++++ tests/__init__.py | 0 10 files changed, 74 insertions(+), 31 deletions(-) create mode 100644 .flake8 create mode 100644 app/__init__.py create mode 100644 app/__main__.py create mode 100644 pyproject.toml delete mode 100644 requirements-dev.txt delete mode 100644 requirements.txt create mode 100644 setup.cfg create mode 100644 setup.py create mode 100644 tests/__init__.py diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..e64ee7d --- /dev/null +++ b/.flake8 @@ -0,0 +1,7 @@ +# vim: ft=cfg +[flake8] +max-complexity = 7 +docstring-convention=google +inline-quotes = double +# Required to be compatible with black +extend-ignore = E203,W503 diff --git a/Makefile b/Makefile index da1e6ec..92452b4 100644 --- a/Makefile +++ b/Makefile @@ -1,41 +1,51 @@ # =====CONFIG===== PYTHON := python3.9 # This can't contain spaces (I think) -VENV := venv +VENV := .venv +# Minimum % coverage for tests to succeed +MIN_COV := 10 # By default, just create the venv when needed all: venv -# Create the venv -$(VENV)/bin/activate: requirements.txt requirements-dev.txt +# =====RECIPES===== +## VENV +### Create the venv +$(VENV)/bin/activate: setup.py setup.cfg @ '$(PYTHON)' -m venv '$(VENV)' - @ '$(VENV)'/bin/pip install -r requirements.txt -r requirements-dev.txt + @ '$(VENV)'/bin/pip install -e .[develop] -# Convenient alias for the venv + +### Convenient alias for the venv venv: $(VENV)/bin/activate .PHONY: venv +## Formatting & linting +format: venv + '$(VENV)'/bin/black setup.py app +.PHONY: format + +lint: venv + '$(VENV)'/bin/flake8 setup.py app +.PHONY: lint + + +## Testing +test: venv + '$(VENV)'/bin/pytest --cov=app --cov-fail-under='$(MIN_COV)' tests/ +.PHONY: test + + +## Cleaning # Remove the venv clean: @ rm -rf '$(VENV)' +.PHONY: clean # Run the Flask server # TODO run: venv - - -# Format the codebase using black -format: venv - @ '$(VENV)/bin/python' -m black src - -# Lint the codebase using flake8 -lint: venv - @ '$(VENV)/bin/python' -m flake8 src - -# Run rests using pytest -# TODO -test: venv diff --git a/app/__init__.py b/app/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/app/__main__.py b/app/__main__.py new file mode 100644 index 0000000..e69de29 diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..a8f43fe --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,2 @@ +[tool.black] +line-length = 79 diff --git a/requirements-dev.txt b/requirements-dev.txt deleted file mode 100644 index d4647f1..0000000 --- a/requirements-dev.txt +++ /dev/null @@ -1,11 +0,0 @@ -# Formatter -black~=20.8b1 - -# Linter -flake8~=3.9.0 - -# Testing suite -pytest~=6.2.2 - -# Language server -jedi~=0.18.0 diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index dc4b804..0000000 --- a/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -# Web framework -Flask~=1.1.2 diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..4646fe8 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,25 @@ +[options] +install_requires = + flask==2.0.0 + +[options.extras_require] +# Used inside Tox for running tests +test = + pytest==6.2.3 + pytest-cov==2.11.1 + +# Used inside tox for linting +lint = + black==20.8b1 + flake8==3.9.1 + flake8-bugbear==21.4.3 + flake8-comprehensions==3.4.0 + flake8-docstrings==1.6.0 + flake8-print==4.0.0 + flake8-quotes==3.2.0 + +# Required for the developer +develop = + %(test)s + %(lint)s + jedi==0.18.0 diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..f70bbe5 --- /dev/null +++ b/setup.py @@ -0,0 +1,12 @@ +"""Setup file for installing the application.""" +from setuptools import setup + + +setup( + name="jos", + version="0.1.0", + author="Jef Roosens", + description="Simplify downloading music.", + # TODO add license + packages=["app", "tests"], +) diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29