Skip to content

Instantly share code, notes, and snippets.

@0atman
Last active February 19, 2020 13:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 0atman/81bc6c07b6e6779d828dfaadaddaae62 to your computer and use it in GitHub Desktop.
Save 0atman/81bc6c07b6e6779d828dfaadaddaae62 to your computer and use it in GitHub Desktop.
my python sensible defaults
# 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' .
@0atman
Copy link
Author

0atman commented Jan 30, 2020

Download this makefile into your next python project:

wget oat.sh/pymakefile -O Makefile

@0atman
Copy link
Author

0atman commented Jan 30, 2020

@0atman
Copy link
Author

0atman commented Feb 18, 2020

Update: Now ignores #-based emacs backup files that was triggering watch multiple times for the same save

@0atman
Copy link
Author

0atman commented Feb 19, 2020

Update 1

  • Added pretty coloured output, and quietened up the noise
  • Added version number and an auto-upgrade mechanism (make upgrade)

@0atman
Copy link
Author

0atman commented Feb 19, 2020

This project is now hosted by my employer, and can be found at https://github.com/alphagov/cyber-security-tools/blob/master/python/Makefile

@0atman
Copy link
Author

0atman commented Feb 19, 2020

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