Skip to content

Commit

Permalink
Define tox commands for cleaning up
Browse files Browse the repository at this point in the history
  • Loading branch information
goerz committed Sep 14, 2019
1 parent 60a1ffc commit df7c809
Show file tree
Hide file tree
Showing 3 changed files with 159 additions and 28 deletions.
41 changes: 14 additions & 27 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: black black-check clean clean-build clean-pyc clean-test clean-venvs coverage dist dist-check docs help install isort isort-check jupyter-lab jupyter-notebook flake8-check pylint-check notebooks pre-commit-hooks release spellcheck test test-upload uninstall upload
.PHONY: black black-check clean clean-build clean-tests clean-venvs coverage dist dist-check docs help install isort isort-check jupyter-lab jupyter-notebook flake8-check pylint-check notebooks pre-commit-hooks release spellcheck test test-upload uninstall upload
.DEFAULT_GOAL := help
TOXOPTIONS =
TOXINI = tox.ini
Expand Down Expand Up @@ -50,33 +50,20 @@ help: ## show this help
bootstrap: ## verify that tox is available and pre-commit hooks are active
@TOXINI="$(TOXINI)" python -c "$$BOOTSTRAP_PYSCRIPT"

clean: clean-docs clean-build clean-pyc clean-test clean-venvs ## remove all build, test, coverage, and Python artifacts, as well as environments
clean: ## remove all build, test, coverage, and Python artifacts, as well as environments
$(TOX) -e clean

clean-build: ## remove build artifacts
rm -fr build/
rm -fr dist/
rm -fr .eggs/
rm -fr src/*.egg-info
rm -fr pip-wheel-metadata
find tests src -name '*.egg-info' -exec rm -fr {} +
find tests src -name '*.egg' -exec rm -f {} +

clean-pyc: ## remove Python file artifacts
find tests src -name '*.pyc' -exec rm -f {} +
find tests src -name '*.pyo' -exec rm -f {} +
find tests src -name '*~' -exec rm -f {} +
find tests src -name '__pycache__' -exec rm -fr {} +

clean-test: ## remove test and coverage artifacts
rm -f .coverage
rm -fr htmlcov/

clean-venvs: ## remove testing/build environments
rm -fr .tox
rm -fr .venv
$(TOX) -e clean-build

clean-tests: ## remove test and coverage artifacts
$(TOX) -e clean-tests

clean-venvs: ## remove tox virtual environments
$(TOX) -e clean-venv

clean-docs: ## remove documentation artifacts
$(MAKE) -C docs clean
$(TOX) -e clean-docs

flake8-check: ## check style with flake8
$(TOX) -e run-flake8
Expand Down Expand Up @@ -123,11 +110,11 @@ coverage: test37 ## generate coverage report in ./htmlcov
$(TOX) -e coverage
@echo "open htmlcov/index.html"

test-upload: bootstrap clean-build clean-pyc dist ## package and upload a release to test.pypi.org
test-upload: bootstrap clean-build dist ## package and upload a release to test.pypi.org
$(TOX) -e run-cmd -- twine check dist/*
$(TOX) -e run-cmd -- twine upload --repository-url https://test.pypi.org/legacy/ dist/*

upload: bootstrap clean-build clean-pyc dist ## package and upload a release to pypi.org
upload: bootstrap clean-build dist ## package and upload a release to pypi.org
$(TOX) -e run-cmd -- twine check dist/*
$(TOX) -e run-cmd -- twine upload dist/*

Expand All @@ -142,7 +129,7 @@ dist: bootstrap ## builds source and wheel package
dist-check: bootstrap ## Check all dist files for correctness
$(TOX) -e run-cmd -- twine check dist/*

install: clean-build clean-pyc ## install the package to the active Python's site-packages
install: clean-build ## install the package to the active Python's site-packages
pip install .

uninstall: ## uninstall the package from the active Python's site-packages
Expand Down
75 changes: 75 additions & 0 deletions tox-conda.ini
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,81 @@ commands =
sphinx-build . _build {posargs:--color}


[testenv:clean]
description = "Clean up"
envdir = {toxworkdir}/clean_
conda_deps =
skip_install = True
commands_pre =
whitelist_externals = tox
commands =
tox -e clean-docs
tox -e clean-tests
tox -e clean-build
tox -e clean-venv
tox -e clean-venv-win32


[testenv:clean-docs]
description = "Clean up files resulting from generating the docs"
envdir = {toxworkdir}/clean
deps = setupext-janitor
conda_deps =
skip_install = True
commands_pre =
commands =
python docs/clean.py


[testenv:clean-tests]
description = "Clean up files resulting from testing/coverage"
envdir = {toxworkdir}/clean
conda_deps =
deps = setupext-janitor
skip_install = True
commands_pre =
commands =
python -c 'import os; import glob; [os.remove(file) for file in glob.glob(".coverage*")]'
python -c 'import shutil; shutil.rmtree("htmlcov", ignore_errors=True)'
python -c 'import shutil; shutil.rmtree(".pytest_cache", ignore_errors=True)'


[testenv:clean-build]
description = "Clean up build artifacts (including __pycache__ folders)"
envdir = {toxworkdir}/clean
conda_deps =
deps = setupext-janitor
skip_install = True
commands_pre =
commands =
python setup.py clean --all --egg-base src --virtualenv-dir=


[testenv:clean-venv]
description = "Remove tox virtual environments"
envdir = {toxworkdir}/clean
conda_deps =
deps = setupext-janitor
skip_install = True
commands_pre =
platform = linux|bsd|darwin
commands =
python setup.py clean --environment --virtualenv-dir={toxworkdir}


[testenv:clean-venv-win32]
description = "Remove tox virtual environments"
envdir = {toxworkdir}/clean
conda_deps =
deps =
skip_install = True
commands_pre =
platform = win32
whitelist_externals = cmd
commands =
cmd /C rmdir /S /Q .tox


[testenv:coverage]
description = "Generate a coverage report"
depends = py37-test
Expand Down
71 changes: 70 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ envdir = {toxworkdir}/.tox
[testenv]
basepython =
# current "stable" python
py37,run,docs,coverage: python3.7
py37,run,docs,coverage,clean: python3.7
# older pythons
py36: python3.6
py35: python3.5
Expand Down Expand Up @@ -63,6 +63,75 @@ commands =
sphinx-build . _build {posargs:--color}


[testenv:clean]
description = "Clean up"
envdir = {toxworkdir}/clean_
skip_install = True
commands_pre =
whitelist_externals = tox
commands =
tox -e clean-docs
tox -e clean-tests
tox -e clean-build
tox -e clean-venv
tox -e clean-venv-win32


[testenv:clean-docs]
description = "Clean up files resulting from generating the docs"
envdir = {toxworkdir}/clean
deps = setupext-janitor
skip_install = True
commands_pre =
commands =
python docs/clean.py


[testenv:clean-tests]
description = "Clean up files resulting from testing/coverage"
envdir = {toxworkdir}/clean
deps = setupext-janitor
skip_install = True
commands_pre =
commands =
python -c 'import os; import glob; [os.remove(file) for file in glob.glob(".coverage*")]'
python -c 'import shutil; shutil.rmtree("htmlcov", ignore_errors=True)'
python -c 'import shutil; shutil.rmtree(".pytest_cache", ignore_errors=True)'


[testenv:clean-build]
description = "Clean up build artifacts (including __pycache__ folders)"
envdir = {toxworkdir}/clean
deps = setupext-janitor
skip_install = True
commands_pre =
commands =
python setup.py clean --all --egg-base src --virtualenv-dir=


[testenv:clean-venv]
description = "Remove tox virtual environments"
envdir = {toxworkdir}/clean
deps = setupext-janitor
skip_install = True
commands_pre =
platform = linux|bsd|darwin
commands =
python setup.py clean --environment --virtualenv-dir={toxworkdir}


[testenv:clean-venv-win32]
description = "Remove tox virtual environments"
envdir = {toxworkdir}/clean
deps =
skip_install = True
commands_pre =
platform = win32
whitelist_externals = cmd
commands =
cmd /C rmdir /S /Q .tox


[testenv:coverage]
description = "Generate a coverage report"
depends = py37-test
Expand Down

0 comments on commit df7c809

Please sign in to comment.