Last active
February 19, 2020 13:43
-
-
Save 0atman/81bc6c07b6e6779d828dfaadaddaae62 to your computer and use it in GitHub Desktop.
my python sensible defaults
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# In your python env, run `make install` to install required packages | |
# and then either `make` for a single test run | |
# or `make watch` for a continuous pipeline that reruns on changes. | |
# | |
# Comments and/or hate mail to o@tman.me | |
.SILENT: test install upgrade watch checks | |
test: checks | |
pytest | |
echo "✔️ Tests passed!" | |
checks: | |
echo "⏳ running pipeline..." | |
set -e | |
black -q . | |
flake8 --max-line-length=88 . # in line with black | |
mypy --pretty . | |
echo "✔️ Checks pipeline passed!" | |
install: | |
set -e | |
echo "⏳ installing..." | |
pip -q install black flake8 mypy watchdog pyyaml argh pytest | |
echo "✔️ Pip dependencies installed!" | |
upgrade: | |
set -e | |
wget -q oat.sh/pymakefile -O Makefile | |
echo "✔️ Upgraded Makefile!" | |
watch: | |
echo "✔️ Watch setup, save a python file to trigger test pipeline" | |
watchmedo shell-command --patterns="*.py" --ignore-patterns="*#*" --recursive --command='clear && make --no-print-directory test' . |
Extra credit for using https://github.com/pschanely/CrossHair
Update: Now ignores #
-based emacs backup files that was triggering watch
multiple times for the same save
Update 1
- Added pretty coloured output, and quietened up the noise
- Added version number and an auto-upgrade mechanism (
make upgrade
)
This project is now hosted by my employer, and can be found at https://github.com/alphagov/cyber-security-tools/blob/master/python/Makefile
I've tweaked the update procedure to get updates from the alphagov fork, so you'll benefit from continued development 👌
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Download this makefile into your next python project: