/my-python-project-skeleton

Some useful utilities I like for managing Python projects.

Primary LanguagePythonGNU General Public License v3.0GPL-3.0

my-python-project-skeleton

Some useful utilities I like for managing Python projects.

(c) 2014 Gatlin Johnson gatlin@niltag.net

  1. 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
$>
  1. 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.

1.1 Makefile

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 in requirements.txt, and and creates a git repository if necessary.

  • upgrade. This upgrades all the packages in your virtual environment.

  • syncdeps. Periodically run this to ensure requirements.txt is up to date with your virtual environment.

  • hook. Symlinks any files in the hooks/ directory into your local repository's hooks directory. Every time you edit a hook, run this command.

1.2 gitignore

Generated by gitignore.io. Ignores vim swap files, .pyc files, the virtual environment directory, and other annoying intermediate files.

1.3 tests.py

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.

  1. 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.