From 4e1d92ca41d4c895be0c392c56cc6a27c076e823 Mon Sep 17 00:00:00 2001 From: Holger Frey Date: Tue, 30 Aug 2022 11:04:10 +0200 Subject: [PATCH] modernized project layout and infrastructure - bumped version to 0.8.0 - requires now at least Python 3.9 - tox tests run in Python verions 3.9 and 3.10 - moved package source to "src" directory --- .pre-commit-config.yaml | 7 +- Makefile | 30 ++++++--- pyproject.toml | 66 +++++++++++-------- .../sensospot_parser}/__init__.py | 2 +- .../sensospot_parser}/columns.py | 0 .../sensospot_parser}/parameters.py | 0 .../sensospot_parser}/parser.py | 0 tox.ini | 4 +- 8 files changed, 67 insertions(+), 42 deletions(-) rename {sensospot_parser => src/sensospot_parser}/__init__.py (99%) rename {sensospot_parser => src/sensospot_parser}/columns.py (100%) rename {sensospot_parser => src/sensospot_parser}/parameters.py (100%) rename {sensospot_parser => src/sensospot_parser}/parser.py (100%) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a68a93e..7eea836 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,6 +3,7 @@ repos: rev: v2.4.0 hooks: - id: check-added-large-files + - id: check-byte-order-marker - id: check-json - id: check-merge-conflict - id: check-toml @@ -12,7 +13,7 @@ repos: hooks: - id: isort-project name: isort_project - entry: isort -rc sensospot_parser + entry: isort -rc src language: system pass_filenames: false - id: isort-test @@ -22,12 +23,12 @@ repos: pass_filenames: false - id: black name: black - entry: black sensospot_parser tests + entry: black src tests language: system pass_filenames: false - id: flake8 name: flake8 - entry: flake8 --ignore E231,W503 sensospot_parser tests + entry: flake8 --ignore E231,W503 src tests language: system pass_filenames: false - id: pytest diff --git a/Makefile b/Makefile index d46632c..62a54b1 100644 --- a/Makefile +++ b/Makefile @@ -51,16 +51,27 @@ clean-test: ## remove test and coverage artifacts rm -fr htmlcov/ lint: ## reformat with black and check style with flake8 - isort sensospot_parser + isort src isort tests - black sensospot_parser tests - flake8 --ignore E231,W503,E402 sensospot_parser tests + black src tests + flake8 --ignore E231,W503,E402 src tests -test: ## run tests quickly with the default Python - pytest tests -x --disable-warnings --failed-first +test: lint ## run tests quickly, stop on first error + pytest tests -x -l --last-failed --disable-warnings -m "not functional" -coverage: ## full test suite, check code coverage and open coverage report - pytest tests --cov=sensospot_parser +testfunctional: lint ## run functional tests, stop on first error + pytest tests -x -l -m "functional" + +testall: lint ## run all tests + pytest tests -l + +coverage: lint ## functional test suite, check code coverage and open coverage report + pytest tests --cov=sensospot_parser -l -m "functional" + coverage html + $(BROWSER) htmlcov/index.html + +coverall: lint ## full test suite, check code coverage and open coverage report + pytest tests --cov=sensospot_parser -l coverage html $(BROWSER) htmlcov/index.html @@ -73,14 +84,15 @@ install: ## install updated project.toml with flint devenv: ## setup development environment python3 -m venv --prompt sensospot .venv .venv/bin/pip3 install --upgrade pip - .venv/bin/pip3 install flit + .venv/bin/pip3 install "flit>3.2" .venv/bin/flit install --pth-file repo: devenv ## complete project setup with development environment and git repo git init . git add . git commit -m "import of project template" + git branch -m main git remote add origin https://git.cpi.imtek.uni-freiburg.de/holgi/sensospot_parser.git - git push -u origin master --no-verify + git push -u origin main --no-verify .venv/bin/pre-commit install --install-hooks diff --git a/pyproject.toml b/pyproject.toml index 47528c2..1431d02 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,36 +1,42 @@ [build-system] -requires = ["flit"] -build-backend = "flit.buildapi" +requires = ["flit_core>=3.2,<4"] +build-backend = "flit_core.buildapi" -[tool.flit.metadata] -module = "sensospot_parser" -dist-name = "sensospot_parser" -author = "Holger Frey" -author-email = "frey@imtek.de" -home-page = "https://git.cpi.imtek.uni-freiburg.de/holgi/sensospot_parser.git" -description-file = "README.md" -license = "Beerware" +[project] +name = "sensospot_parser" +readme = "README.md" +license = { file = "LICENSE" } +requires-python = ">=3.9" +dynamic = ["version", "description"] + +authors = [ + {name = "Holger Frey", email = "frey@imtek.de"}, +] # see https://pypi.org/classifiers/ classifiers = [ "Development Status :: 2 - Pre-Alpha", "Intended Audience :: Developers", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3 :: Only", "License :: Freely Distributable", ] -requires = [ +dependencies = [ "pandas >=1.0.0", "defusedxml >=0.6.0", "tables >=3.6.1", "click", ] +[project.urls] +Source = "https://git.cpi.imtek.uni-freiburg.de/holgi/sensospot_parser.git" -requires-python = ">=3.7" +[project.scripts] +sensospot_parse = "sensospot_parser:main" -[tool.flit.metadata.requires-extra] +[project.optional-dependencies] test = [ "pytest >=4.0.0", "pytest-cov", @@ -42,26 +48,24 @@ dev = [ "black", "flake8", "flake8-comprehensions", - "isort", + "flake8-bandit", + "isort >= 5.0.0", "keyring", "pre-commit", ] -[tool.flit.scripts] -sensospot_parse = "sensospot_parser:main" - [tool.black] line-length = 79 -target-version = ['py37'] +target-version = ['py39', 'py310'] include = '\.pyi?$' -exclude = ''' -/( - \.git - | \.tox - | \.venv - | build - | dist -)/ +extend-exclude = ''' +# A regex preceded with ^/ will apply only to files and directories +# in the root of the project. +^/.git +^/.tox +^/.venv +^/.build +^/.dist ''' [tool.isort] @@ -69,3 +73,11 @@ line_length=79 multi_line_output=3 length_sort="True" include_trailing_comma="True" + +[tool.pytest.ini_options] +markers = [ + "functional: marks tests as functional (deselect with '-m \"not functional\"')", +] +addopts = [ + "--strict-markers", +] diff --git a/sensospot_parser/__init__.py b/src/sensospot_parser/__init__.py similarity index 99% rename from sensospot_parser/__init__.py rename to src/sensospot_parser/__init__.py index 7a2ee63..ad00f48 100644 --- a/sensospot_parser/__init__.py +++ b/src/sensospot_parser/__init__.py @@ -3,7 +3,7 @@ Parsing the numerical output from Sensovations Sensospot image analysis. """ -__version__ = "0.7.0" +__version__ = "0.8.0" import sys diff --git a/sensospot_parser/columns.py b/src/sensospot_parser/columns.py similarity index 100% rename from sensospot_parser/columns.py rename to src/sensospot_parser/columns.py diff --git a/sensospot_parser/parameters.py b/src/sensospot_parser/parameters.py similarity index 100% rename from sensospot_parser/parameters.py rename to src/sensospot_parser/parameters.py diff --git a/sensospot_parser/parser.py b/src/sensospot_parser/parser.py similarity index 100% rename from sensospot_parser/parser.py rename to src/sensospot_parser/parser.py diff --git a/tox.ini b/tox.ini index 679b074..57f3a9c 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py37 +envlist = py39, py310 isolated_build = True [testenv] @@ -11,4 +11,4 @@ deps = pip>=20.0.2 changedir = {toxinidir}/tests -commands = pytest --cov=sensovation_data_parser +commands = pytest --cov=sensovation_parser