by Bernat Gabor /
@gjbernat /
bernat.tech /
Bloomberg
😱 assure QC for each after every commit!!! 😱
make sure to invoke all those, after each commit 😢
run_it_all.bash
set -x # stop if any of these fails
python3.7 setup.py sdist # package it
python3.7 install . # test packaging
python3.7 -m pytest # run unit test
python3.7 -m mypy # run type checker
python3.7 -m flake8 # run code style check
sphinx-build doc/conf.py -d build # generate documentation
Reasonable. However, now it would be nice to:
usage by activate/deactivate:
python -m venv env # create virtual environment
./env/bin/activate # activate virtual env
pip install -r requirements.txt # install dependencies
python -m pytest # call pytest
deactivate # deactivate
you can also directly use these:
python -m venv env # create virtual environment
./env/pip install -r requirements.txt # install dependencies
./env/python -m pytest # call pytest
run_it_all.bash
set -x # stop if any of these fails
python3.7 -m virtualenv py27 # create venv
./py27/bin/activate # activate venv
python setup.py sdist # package it
python install . # test deploy
python -m pytest # run unit test
python -m pylint # run static code analysis
python -m flake8 # run code style check
sphinx-build doc/conf.py -d build # generate documentation
deactivate # deactivate
that starts to be hard to:
allows for a Python project:
tox -rvv
[tox]
envlist = py27, lint, doc
[testenv]
basepython = py27: python2.7
lint: python3.7
doc: python3.7
publish: python3.7
commands = pytest {posargs}
deps = pytest >= 3.0.0
pytest-cov
[testenv:lint]
deps = pylint >= 2.0.0
commands = pylint -r n --disable=similarities src tests {posargs}
[testenv:doc]
deps = Sphinx
commands = sphinx-build -v -W -b html -a doc/source {toxinidir}/build/doc
[testenv:publish]
deps = setuptools
twine
commands = python setup.py sdist bdist_wheel
twine upload build/*
[tox]
envlist = py27, lint, doc
[testenv]
basepython = py27: python2.7
lint: python3.7
doc: python3.7
publish: python3.7
commands = pytest {posargs}
deps = pytest >= 3.0.0
pytest-cov
[testenv:lint]
deps = pylint >= 2.0.0
commands = pylint -r n --disable=similarities src tests {posargs}
[testenv:doc]
deps = Sphinx
commands = sphinx-build -v -W -b html -a doc/source {toxinidir}/build/doc
[testenv:publish]
deps = setuptools
twine
commands = python setup.py sdist bdist_wheel
twine upload build/*
[tox]
envlist = py27, lint, doc
[testenv]
basepython = py27: python2.7
lint: python3.7
doc: python3.7
publish: python3.7
commands = pytest {posargs}
deps = pytest >= 3.0.0
pytest-cov
[testenv:lint]
deps = pylint >= 2.0.0
commands = pylint -r n --disable=similarities src tests {posargs}
[testenv:doc]
deps = Sphinx
commands = sphinx-build -v -W -b html -a doc/source {toxinidir}/build/doc
[testenv:publish]
deps = setuptools
twine
commands = python setup.py sdist bdist_wheel
twine upload build/*
[tox]
envlist = py27, lint, doc
[testenv]
basepython = py27: python2.7
lint: python3.7
doc: python3.7
publish: python3.7
commands = pytest {posargs}
deps = pytest >= 3.0.0
pytest-cov
[testenv:lint]
deps = pylint >= 2.0.0
commands = pylint -r n --disable=similarities src tests {posargs}
[testenv:doc]
deps = Sphinx
commands = sphinx-build -v -W -b html -a doc/source {toxinidir}/build/doc
[testenv:publish]
deps = setuptools
twine
commands = python setup.py sdist bdist_wheel
twine upload build/*
[tox]
envlist = py27, lint, doc
[testenv]
basepython = py27: python2.7
lint: python3.7
doc: python3.7
publish: python3.7
commands = pytest {posargs}
deps = pytest >= 3.0.0
pytest-cov
[testenv:lint]
deps = pylint >= 2.0.0
commands = pylint -r n --disable=similarities src tests {posargs}
[testenv:doc]
deps = Sphinx
commands = sphinx-build -v -W -b html -a doc/source {toxinidir}/build/doc
[testenv:publish]
deps = setuptools
twine
commands = python setup.py sdist bdist_wheel
twine upload build/*
[tox]
envlist = py27, lint, doc
[testenv]
basepython = py27: python2.7
lint: python3.7
doc: python3.7
publish: python3.7
commands = pytest {posargs}
deps = pytest >= 3.0.0
pytest-cov
[testenv:lint]
deps = pylint >= 2.0.0
commands = pylint -r n --disable=similarities src tests {posargs}
[testenv:doc]
deps = Sphinx
commands = sphinx-build -v -W -b html -a doc/source {toxinidir}/build/doc
[testenv:publish]
deps = setuptools
twine
commands = python setup.py sdist bdist_wheel
twine upload build/*
python setup.py sdist
# pyproject.toml
[build-system]
requires = [
"setuptools >= 35.0.2",
"setuptools_scm >= 2.0.0, <3",
"wheel >= 0.29.0",
]
pip build .
[testenv:lint]
deps = pylint >= 2.0.0
commands = pylint -r n --disable=similarities src tests {posargs}
[testenv:py27]
extras=testing
commands = pytest.py
setup(
name="tox",
install_requires=[
"packaging >= 17.1"
],
extras_require={
"testing": [
"pytest >= 3.0.0, <4",
"pytest-cov >= 2.5.1, <3"
]
}
)
[testenv:docs]
commands = sphinx-build -d "{toxworkdir}/docs_doctree" doc "{toxworkdir}/docs_out" --color -W -bhtml
sphinx-build -d "{toxworkdir}/docs_doctree" doc "{toxworkdir}/docs_out" --color -W -blinkcheck
python -c 'print("documentation available under file://{toxworkdir}/docs_out/index.html")'
____________________________________________ summary ____________________________________________
ERROR: py27: commands failed
ERROR: lint: commands failed
doc: commands succeeded
tox
tox
tox -e py27,lint
[testenv:docs]
description = invoke sphinx-build to build the HTML docs and check that all links are valid
basepython = python3.7
commands = sphinx-build -d "{toxworkdir}/docs_doctree" doc "{toxworkdir}/docs_out" --color -W -bhtml
sphinx-build -d "{toxworkdir}/docs_doctree" doc "{toxworkdir}/docs_out" --color -W -blinkcheck
python -c 'print("documentation available under file://{toxworkdir}/docs_out/index.html")'
# commands = py.test {posargs}
tox -e py27 -- -vvv -x --pdb
[testenv:dev]
description = generate the developer enviroment
usedevelop = True
basepython = python3.7
deps = {[testenv]deps}
{[testenv:doc]deps}
pip >= 10.0.0
tox >= 2.9.1, < 3
commands = pip list --format=columns
python -c 'import sys;print(sys.version);print(sys.executable)'
[tox]
envlist = py26, py27, lint, doc
skip_missing_interpreters = true
[testenv]
basepython = py26: python2.6
py27: python2.7
lint: python3.7
doc: python3.7
[tox]
envlist = py26-django{14,15,16},
py27-django{14,15,16,17,18},
py{36,37}-django{17,18, -master}
[testenv]
deps =
coverage
django14: Django>=1.4,<1.5
django15: Django>=1.5,<1.6
django16: Django>=1.6,<1.7
django17: Django>=1.7,<1.8
django18: Django>=1.8,<1.9
django-master: https://github.com/django/django/archive/master.tar.gz
six
commands = coverage run --branch --parallel-mode setup.py test
py26-django14
py26-django15
py26-django16
py27-django14
py27-django15
py27-django16
py27-django17
py27-django18
py36-django17
py36-django18
py36-django-master
py37-django17
py37-django18
py37-django-master
sudo: false
language: python
python:
- "2.7"
- "3.4"
install: pip install tox-travis
script: tox
tox -r
Bloomberg
© 2018 Bloomberg Finance L.P.
All rights reserved.