Some useful utilities I like for managing Python projects.
(c) 2014 Gatlin Johnson gatlin@niltag.net
- Synopsis
$> git clone https://github.com/gatlin/my-python-project-skeleton
$> make setup
$> . ve/bin/activate
(ve)$> make hooks
(ve)$> ...
(ve)$> make syncdeps
(ve)$> make clean
(ve)$> git add $FILES
(ve)$> git commit -m "Just committing some files which will run tests.py"
(ve)$> deactivate
$>
- Okay a little more elaboration
These are minimal scripts and helpers to aid in managing Python projects. It is assumed that your project will use a virtual environment and pip.
These utilities are not designed to automatically configure your entire project. You still need to create a source directory, install whatever modules you want, etc.
For more tips on setting up a Python project, see this post.
Much of this file is focused on maintaining a requirements.txt
file
containing all the dependencies for your project installed in your virtual
environment. I personally prefer this to checking in the actual virtual
environment directory (and indeed, ve
is in the .gitignore
file).
The Makefile contains the following actions:
-
setup
. This creates a virtual environment, installs anything you have inrequirements.txt
, and and creates a git repository if necessary. -
upgrade
. This upgrades all the packages in your virtual environment. -
syncdeps
. Periodically run this to ensurerequirements.txt
is up to date with your virtual environment. -
hook
. Symlinks any files in thehooks/
directory into your local repository's hooks directory. Every time you edit a hook, run this command.
Generated by gitignore.io. Ignores vim swap files, .pyc files, the virtual environment directory, and other annoying intermediate files.
Use this to orchestrate any tests you want to run before each commit. If you
install the default pre-commit
hook then this file must be present and exit
with 0
before the commit will succeed. By default, tests.py
indeed returns
0
so it should be safe to ignore it.
- Questions? Insults? Bugs? Suggestions?
For bugs, use GitHub's issue tracker. Pull requests are more than welcome!
You can reach me at gatlin@niltag.net if you want to inquire further.