Skip to content

Commit

Permalink
Add tox to repo: (#51)
Browse files Browse the repository at this point in the history
Add the `tox` utility to the repo to run tests and linting.

Requires the addition of a `tox.ini` file, and `setup.cfg` to setup the
repo package correctly.

Requirements are now compiled by tox from the `requirements.in` file.
  • Loading branch information
Tiernan8r authored Dec 21, 2022
1 parent ff785b6 commit 3fc39d6
Show file tree
Hide file tree
Showing 7 changed files with 302 additions and 11 deletions.
39 changes: 32 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# VSCode settings files:
.vscode

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand All @@ -20,7 +23,6 @@ parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
Expand Down Expand Up @@ -50,6 +52,7 @@ coverage.xml
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
Expand All @@ -72,6 +75,7 @@ instance/
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
Expand All @@ -82,7 +86,9 @@ profile_default/
ipython_config.py

# pyenv
.python-version
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
Expand All @@ -91,6 +97,13 @@ ipython_config.py
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

Expand Down Expand Up @@ -128,9 +141,21 @@ dmypy.json
# Pyre type checker
.pyre/

# ignore generated plot files
data/plots
# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintainted in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
.idea/

# test coverage reports:
test-reports

#ignore project files
.idea
.vscode
# Generated plots:
data/
4 changes: 4 additions & 0 deletions requirements.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
matplotlib
numpy
scipy
pyinstaller
47 changes: 43 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,43 @@
matplotlib
numpy
scipy
pyinstaller
#
# This file is autogenerated by pip-compile with Python 3.10
# by the following command:
#
# pip-compile --output-file=requirements.txt requirements.in
#
altgraph==0.17.3
# via pyinstaller
contourpy==1.0.6
# via matplotlib
cycler==0.11.0
# via matplotlib
fonttools==4.38.0
# via matplotlib
kiwisolver==1.4.4
# via matplotlib
matplotlib==3.6.2
# via -r requirements.in
numpy==1.24.0
# via
# -r requirements.in
# contourpy
# matplotlib
# scipy
packaging==22.0
# via matplotlib
pillow==9.3.0
# via matplotlib
pyinstaller==5.7.0
# via -r requirements.in
pyinstaller-hooks-contrib==2022.14
# via pyinstaller
pyparsing==3.0.9
# via matplotlib
python-dateutil==2.8.2
# via matplotlib
scipy==1.9.3
# via -r requirements.in
six==1.16.0
# via python-dateutil

# The following packages are considered to be unsafe in a requirements file:
# setuptools
43 changes: 43 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
;MIT License
;
;Copyright (c) 2022 Tiernan8r
;
;Permission is hereby granted, free of charge, to any person obtaining a copy
;of this software and associated documentation files (the "Software"), to deal
;in the Software without restriction, including without limitation the rights
;to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
;copies of the Software, and to permit persons to whom the Software is
;furnished to do so, subject to the following conditions:
;
;The above copyright notice and this permission notice shall be included in all
;copies or substantial portions of the Software.
;
;THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
;IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
;FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
;AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
;LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
;OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
;SOFTWARE.
[metadata]
license_files = LICENSE
name = variational_principle
author = Tiernan8r
author_email = [email protected]
license = MIT
classifiers =
Programming Language :: Python :: 3
Programming Language :: Python

;[bdist_wheel]
;universal = 0 # don't build for python2, only python3

[tool:pytest]

[mypy]

[flake8]
exclude = .git,__pycache__,.tox,.eggs,*.egg,./venv
filename =
*.py,

28 changes: 28 additions & 0 deletions test-requirements.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# MIT License
#
# Copyright (c) 2022 Tiernan8r
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
-c requirements.txt
tox
pip-tools
mypy
pytest
pytest-cov
pytest-flake8
92 changes: 92 additions & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#
# This file is autogenerated by pip-compile with Python 3.10
# by the following command:
#
# pip-compile --output-file=test-requirements.txt test-requirements.in
#
attrs==22.2.0
# via pytest
build==0.9.0
# via pip-tools
cachetools==5.2.0
# via tox
chardet==5.1.0
# via tox
click==8.1.3
# via pip-tools
colorama==0.4.6
# via tox
coverage[toml]==7.0.0
# via pytest-cov
distlib==0.3.6
# via virtualenv
exceptiongroup==1.0.4
# via pytest
filelock==3.8.2
# via
# tox
# virtualenv
flake8==6.0.0
# via pytest-flake8
iniconfig==1.1.1
# via pytest
mccabe==0.7.0
# via flake8
mypy==0.991
# via -r test-requirements.in
mypy-extensions==0.4.3
# via mypy
packaging==22.0
# via
# -c requirements.txt
# build
# pyproject-api
# pytest
# tox
pep517==0.13.0
# via build
pip-tools==6.12.1
# via -r test-requirements.in
platformdirs==2.6.0
# via
# tox
# virtualenv
pluggy==1.0.0
# via
# pytest
# tox
pycodestyle==2.10.0
# via flake8
pyflakes==3.0.1
# via flake8
pyproject-api==1.2.1
# via tox
pytest==7.2.0
# via
# -r test-requirements.in
# pytest-cov
# pytest-flake8
pytest-cov==4.0.0
# via -r test-requirements.in
pytest-flake8==1.1.1
# via -r test-requirements.in
tomli==2.0.1
# via
# build
# coverage
# mypy
# pyproject-api
# pytest
# tox
tox==4.0.16
# via -r test-requirements.in
typing-extensions==4.4.0
# via mypy
virtualenv==20.17.1
# via tox
wheel==0.38.4
# via pip-tools

# The following packages are considered to be unsafe in a requirements file:
# pip
# setuptools
60 changes: 60 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
;MIT License
;
;Copyright (c) 2020 Tiernan8r
;
;Permission is hereby granted, free of charge, to any person obtaining a copy
;of this software and associated documentation files (the "Software"), to deal
;in the Software without restriction, including without limitation the rights
;to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
;copies of the Software, and to permit persons to whom the Software is
;furnished to do so, subject to the following conditions:
;
;The above copyright notice and this permission notice shall be included in all
;copies or substantial portions of the Software.
;
;THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
;IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
;FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
;AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
;LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
;OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
;SOFTWARE.
[tox]
minversion = 2.5
envlist = tests,pep8,mypy

[testenv]
deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
usedevelop = True
basepython = python3

[testenv:pep8]
deps = flake8
usedevelop = False
commands = flake8

[testenv:tests]
commands = pytest --cache-clear --verbose --cov-config=.coveragerc --cov=src \
--cov-report=xml:coverage/python/coverage.xml \
--cov-report=term \
--junitxml=test-reports/pytest/results.xml {posargs} \
{toxinidir}/tests
setenv =
RUNNING_IN_TOX = 1


[testenv:mypy]
commands = mypy -p src

[testenv:update-pins]
envdir = {toxworkdir}/pip_tools
deps = pip-tools
commands = pip-compile {posargs:--upgrade} --output-file requirements.txt requirements.in
pip-compile {posargs:--upgrade} --output-file test-requirements.txt test-requirements.in

[testenv:add-pins]
envdir = {toxworkdir}/pip_tools
deps = pip-tools
commands = pip-compile --output-file requirements.txt requirements.in
pip-compile --output-file test-requirements.txt test-requirements.in

0 comments on commit 3fc39d6

Please sign in to comment.