cookiecutter-flit

A Cookiecutter template for a Flit package
git clone git://git.danielmoch.com/cookiecutter-flit.git
Log | Files | Refs | LICENSE

commit 242e12ccaea459d810678e87e8edf58413e1ee95
parent 34098405b42c4e040834bed902549bee967c721e
Author: Daniel Moch <daniel@danielmoch.com>
Date:   Fri, 31 Aug 2018 19:55:02 -0400

Another general updated based on lessons learned

Diffstat:
Mcookiecutter.json | 3++-
Mhooks/post_gen_project.py | 3+++
A{{cookiecutter.project_slug}}/.coveragerc | 3+++
R{{cookiecutter.project_slug}}/tests/pylintrc -> {{cookiecutter.project_slug}}/.pylintrc | 0
M{{cookiecutter.project_slug}}/Makefile | 31+++++++++++++++++++------------
A{{cookiecutter.project_slug}}/appveyor.yml | 16++++++++++++++++
R{{cookiecutter.project_slug}}/__main__.py -> {{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/__main__.py | 0
7 files changed, 43 insertions(+), 13 deletions(-)

diff --git a/cookiecutter.json b/cookiecutter.json @@ -9,5 +9,6 @@ "pypi_username": "{{ cookiecutter.github_username }}", "version": "0.1.0", "script_entrypoint": "y", - "open_source_license": ["MIT license", "BSD license", "ISC license", "Apache Software License 2.0", "GNU General Public License v3", "Not open source"] + "open_source_license": ["MIT license", "BSD license", "ISC license", "Apache Software License 2.0", "GNU General Public License v3", "Not open source"], + "windows_support": "y" } diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py @@ -14,6 +14,9 @@ def remove_file(filepath): if 'Not open source' == '{{ cookiecutter.open_source_license }}': remove_file('LICENSE') + if 'n' == '{{ cookiecutter.windows_support }}': + remove_file('appveyor.yml') + try: subprocess.run( ['which', diff --git a/{{cookiecutter.project_slug}}/.coveragerc b/{{cookiecutter.project_slug}}/.coveragerc @@ -0,0 +1,3 @@ +[run] +branch = True +omit = {{ cookiecutter.project_slug }}/__main__.py diff --git a/{{cookiecutter.project_slug}}/tests/pylintrc b/{{cookiecutter.project_slug}}/.pylintrc diff --git a/{{cookiecutter.project_slug}}/Makefile b/{{cookiecutter.project_slug}}/Makefile @@ -25,6 +25,9 @@ endef export PRINT_HELP_PYSCRIPT BROWSER := python -c "$$BROWSER_PYSCRIPT" +PIPENV := pipenv +PIPRUN := $(PIPENV) run +PIPINST := $(PIPENV) --bare install --dev --skip-lock help: @python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST) @@ -43,6 +46,7 @@ clean-pyc: ## remove Python file artifacts find . -name '*.pyo' -exec rm -f {} + find . -name '*~' -exec rm -f {} + find . -name '__pycache__' -exec rm -fr {} + + $(PIPRUN) pip uninstall -y {{ cookiecutter.project_slug }} clean-test: ## remove test and coverage artifacts rm -f .coverage @@ -51,34 +55,37 @@ clean-test: ## remove test and coverage artifacts rm -fr .tox lint: ## check style with pylint - pipenv run pylint --rcfile tests/pylintrc {{ cookiecutter.project_slug }} tests --disable=parse-error + $(PIPRUN) pylint {{ cookiecutter.project_slug }} tests --disable=parse-error test: ## run tests quickly with the default Python - pipenv run python -m pytest + $(PIPRUN) python -m pytest + +test-all: ## run tests on every Python version with tox + $(PIPRUN) tox test-install: ## install dependenices from Pipfile (for tox / CI builds) - pipenv --bare install --dev --skip-lock + $(PIPINST) coverage: ## check code coverage quickly with the default Python - pipenv run python -m pytest --cov={{ cookiecutter.project_slug }} --cov-config tests/coveragerc - pipenv run coverage report -m + $(PIPRUN) python -m pytest --cov={{ cookiecutter.project_slug }} + $(PIPRUN) coverage report -m coverage-html: coverage ## generate an HTML report and open in browser - pipenv run coverage html + $(PIPRUN) coverage html $(BROWSER) htmlcov/index.html release: dist ## package and upload a release - pipenv run flit publish + $(PIPRUN) flit publish dist: ## builds source and wheel package - pipenv run flit build + $(PIPRUN) flit build ls -l dist install: ## install the package to the active Python's site-packages - pipenv run flit install + $(PIPRUN) flit install --deps=none -run: install ## run the package from site-packages - pipenv run {{ cookiecutter.project_slug }} +run: ## run the package from site-packages + $(PIPRUN) python -m {{ cookiecutter.project_slug }} $(cmd) debug: install ## debug the package from site packages - pipenv run pudb3 `pipenv run which {{ cookiecutter.project_slug }}` + $(PIPRUN) pudb3 $$($(PIPRUN) which {{ cookiecutter.project_slug }}) $(cmd) diff --git a/{{cookiecutter.project_slug}}/appveyor.yml b/{{cookiecutter.project_slug}}/appveyor.yml @@ -0,0 +1,16 @@ +environment: + matrix: + # For Python versions available on Appveyor, see + # http://www.appveyor.com/docs/installed-software#python + - PYTHON: "C:\\Python35-x64" + - PYTHON: "C:\\Python36" + - PYTHON: "C:\\Python37" + +install: + - "%PYTHON%\\python.exe -m pip install pipenv" + - "%PYTHON%\\python.exe -m pipenv --bare install --dev --skip-lock" + +build: off + +test_script: +- "%PYTHON%\\python.exe -m pipenv run python -m pytest" diff --git a/{{cookiecutter.project_slug}}/__main__.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/__main__.py