Strange Loops

No Matter Where You Go, There You Are

Virtualenv

| Comments

One recent change to my life has been more python. Lots of nice/bad things have been said about the language that I won't repeat here. I'm generally enjoying my time with it. One useful tool I've found is virtualenv and its bash wrapper functions.

virtualenv allows me to create an environment (python + versioned set of packages) for me to work in. For example I have two virtualenvs right now (temp and django). "temp" contains a myriad number of different libraries I want to experiment with and "django" contains (well) django and a more limited set of libraries. To use I do "activate temp" or "activate django" from my shell depending on what I want to use.

I have a similar problem with perl. I have 2 versions 5.8.9 and 5.10 that I want to use. To take care of this, I have both perls compiled into two different locations. To switch working between the both of, I borrowed some inspiration from virtualenv.

#!/bin/sh
# use-perl5.10.sh
path-to/cpanp 's program perlwrapper path-to/perl5.10/bin/cpanp-run-perl; s save'
PATH=path-to/perl5.10/bin:${PATH} PS1="(5.10) \h:\W \u\$ " /bin/bash
#!/bin/sh
# use-perl5.8.sh
cpanp 's program perlwrapper path-to/bin/cpanp-run-perl; s save'
PATH=path-to/bin:${PATH} PS1="(5.8) \h:\W \u\$ " /bin/bash

I call use-perl5.8.sh and use-perl5.10.sh as appropriate from my shell to setup a working environment from perl. This doesn't isolate the libraries like virtualenv but switching between the two perls is all I needed for now.