18 October 2010

How I Learned To Stop Worrying And Love The Setuptools

This is mainly note for myself if I ever forgot how to use it.

For most of the time my projects lived each in it's own directory and I resolved importing issues with sys.path manipulation. That works for low number of simple programs/libraries. Using distribute (setuptools) seems to be a natural step forward.

I'd like to stay with this approach (no setuptools) for a little bit longer because I'm easily distracted and I need to get used to setuptools boilerplate ;)

Steps to make life less painful (use setuptools) and to preserve old ways:

Step 1. install virtualenv
Step 2. virtualenv $SOME_PATH_TO_NEW_ENVIRONMENT
Step 3. source $SOME_PATH_TO_NEW_ENVIRONMENT/bin/activate

Then we've got cloned python installation that will work with python setup.py install or whatever. But we're only halfway done and need to setup our package.

Step 1. mkdir $PACKAGE_INSTALLER
Step 2. cd $PACKAGE_INSTALLER
Step 3. ln -s $REAL_PACKAGE_DIR .
Step 4. write setup.py as advertised in documentation

Thats all. I can hide package installers so I don't get distracted but still I get all power of setuptools.

edit:
Main benefit is that when using setup.py develop I can edit my package as always in $REAL_PACKAGE_DIR.