Coding: Bring the Noise

%26lt;0011 Em

PyProMan: virtualenv wrapper for multi-project development

leave a comment »

Developing with SublimeText continues to be a pleasure, except that curious interaction with virtualenv and ST’s build system.  I seem to have two choices:

  1. Create a new build system for each virtualenv – which is pretty much 1:1 for my projects.  When switching between projects in ST, don’t forget to change the build system, too.
  2. Use 1 build system for python, but every time I switch projects, edit the build system with the proper python target.  No initial setup, but I’ve got to keep the build system open and remember where the venv is.

Enter PyProMan.  Basic, but it gets the job done and there’s almost no overhead if you decide later that you don’t want to use it anymore.

tl;dr

Put your projects in the $PROJ folder, and get started with a new virtualenv by running “proj pythonX.X” from that folder.  For the project “foo” there will be a new virtualenv in $VENV/foo.  Now, you can interact with any projects’ appropriate bin/ scripts by putting “proj” before the command (much like sudo).  Want to install a package for the project you’re in?  “proj pip install some_package” and it’s done.

But wait there’s more

The real reason this was put together was to make the SublimeText integration trivial.  Since our build system will always run the script we’re building from the project folder it lives in, we can use the same exact build cmd for all projects.  We don’t have to create and manage multiple build systems, we don’t have to edit it when switching projects.  “proj python $file” will figure out the appropriate python interpreter and hand it the rest of our arguments.  And we can use that command outside of the project folder as well, and still use the right virtualenv.  As long as you have put proj before python when executing a script, you can be sure it’s executing in the right environment.

Wow!  Anything else I should know?

Not really – two environment variables and two small bash scripts (that could be one).  For more information including my full SublimeText build system, check out the readme at https://github.com/numberoverzero/pyproman

Advertisements

Written by delwinna

May 26, 2013 at 8:03 am

Posted in Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: