diff --git a/Makefile b/Makefile index a9746b2..a835423 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ help: @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-12s\033[0m %s\n", $$1, $$2}' -test: +test: ## Build example cookicutter project and test rm -rf example_python_project/.git # Remove old git test repo if previously initilized cookiecutter --no-input --overwrite-if-exists . cd example_python_project; make all diff --git a/README.md b/README.md index 0f57157..bfa9cd5 100644 --- a/README.md +++ b/README.md @@ -349,11 +349,12 @@ exclude_lines = except ImportError assert False raise NotImplementedError() + pass ``` We have to explicitly omit the unit tests since we have placed the test files in the same directories as the code to test. -The [pragma](https://en.wikipedia.org/wiki/Directive_(programming)) `pragma: no cover` is used to mark untestable lines. This often happens with conditional imports used for backwards compatibility between python versions. The other excluded lines are common patterns of code that doesn't need test coverage. +The [pragma](https://en.wikipedia.org/wiki/Directive_(programming)) `pragma: no cover` is used to mark untestable lines. This often happens with conditional imports used for backwards compatibility between python versions. The other excluded lines are common patterns of code that don't need test coverage. ## Linting @@ -377,7 +378,7 @@ The configuration also lives in `setup.cfg`. max-line-length = 88 ignore = E203, W503 ``` -We need to override the linter on occasion. We add pragma such as `# noqa: F401` to assert that no, really, in this case we do know what we're doing. +We need to override the linter on occasion. We add pragmas such as `# noqa: F401` to assert that no, really, in this case we do know what we're doing. Two other python code format tools to consider using are [isort](https://pypi.org/project/isort/) and [black, The uncompromising code formatter](https://black.readthedocs.io/en/stable/). Isort sorts your import statements into a canonical order. And Black is the Model-T Ford of code formatting -- any format you want, so long as it's Black. I could quibble about some of Black's code style, but in the end it's just easier to blacken your code and accept black's choices, and thereby gain a consistent coding style across developers. @@ -698,7 +699,7 @@ The basic idea is to replace customizable text with template strings, e.g. `{{c Defaults for these templates are stored in `cookiecutter.json`. In particular example_python_package is moved to a directory called `{{cookiecutter.module_name}}`, and the module code is moved to `{{cookiecutter.module_name}}/{{cookiecutter.module_name}}`. -I'm more or less following [cookiecutter-pypackage])https://github.com/audreyfeldroy/cookiecutter-pypackage) +I'm more or less following [cookiecutter-pypackage](https://github.com/audreyfeldroy/cookiecutter-pypackage) One tricky bit is that some of the github configuration files already contain similar template strings. So we have to wrap those strings in special raw tags. diff --git a/example_python_project/Makefile b/example_python_project/Makefile index 4237645..7c4664c 100644 --- a/example_python_project/Makefile +++ b/example_python_project/Makefile @@ -86,10 +86,12 @@ build: ## Setuptools build ./setup.py clean --all ./setup.py sdist bdist_wheel - clean: ## Clean up after setuptools ./setup.py clean --all +requirements: ## Make requirements.txt + pip freeze > requirements.txt + .PHONY: help .PHONY: docs diff --git a/example_python_project/setup.cfg b/example_python_project/setup.cfg index 29e8710..5a039e2 100644 --- a/example_python_project/setup.cfg +++ b/example_python_project/setup.cfg @@ -46,7 +46,7 @@ python_requires = >= 3.8 packages = find: install_requires = - numpy # example + numpy >= 1.20 # v1.20 introduces typechecking for numpy setup_requires = setuptools_scm @@ -94,6 +94,7 @@ exclude_lines = except ImportError assert False raise NotImplementedError() + pass diff --git a/{{cookiecutter.module_name}}/Makefile b/{{cookiecutter.module_name}}/Makefile index 185216f..4c34d5d 100644 --- a/{{cookiecutter.module_name}}/Makefile +++ b/{{cookiecutter.module_name}}/Makefile @@ -86,10 +86,12 @@ build: ## Setuptools build ./setup.py clean --all ./setup.py sdist bdist_wheel - clean: ## Clean up after setuptools ./setup.py clean --all +requirements: ## Make requirements.txt + pip freeze > requirements.txt + .PHONY: help .PHONY: docs diff --git a/{{cookiecutter.module_name}}/setup.cfg b/{{cookiecutter.module_name}}/setup.cfg index 4278324..c99e3ea 100644 --- a/{{cookiecutter.module_name}}/setup.cfg +++ b/{{cookiecutter.module_name}}/setup.cfg @@ -18,7 +18,7 @@ Keywords = python Home-page = https://github.com/{{cookiecutter.github_username}}/{{cookiecutter.module_name}}/ Author = {{cookiecutter.author_name}} Author-email = {{cookiecutter.author_email}} -License = Apache-2.0 +License = {{cookiecutter.license}} License-File = LICENSE # https://pypi.org/classifiers/ @@ -46,7 +46,7 @@ python_requires = >= 3.8 packages = find: install_requires = - numpy # example + numpy >= 1.20 # v1.20 introduces typechecking for numpy setup_requires = setuptools_scm @@ -94,6 +94,7 @@ exclude_lines = except ImportError assert False raise NotImplementedError() + pass