up

Virtual Environments for Cappuccino

capp_env

It’s been a little while, but Cappuccino Tools now have a newcomer: capp_env. This new tool is like virtualenv for Python. It makes it possible to create multiple self-contained Cappuccino environments. This way you can have multiple parallel Cappuccino installations, with different sets of libraries, and they won’t interfere with each other. This is extremely useful when you work on multiple projects with multiple branches. Here at Nuage Networks, we (sadly) have to deal with a lot of different branches. Each of them uses a specific version of Cappuccino, and a specific version of all our internal Frameworks. Before capp_env, switching from one branch to another required a lot of time to actually rebuild the different libraries and Cappuccino itself. And that was just not right.

capp_env fixes this problem by providing a way to keep different Cappuccino versions in confined environments. When you switch from a branch to another, you will just need to switch environment as well.

The way it works is simple. First you create some new environments by doing:

capp_env -p ~/.cappuccino/environments/master
capp_env -p ~/.cappuccino/environments/v0.9.9 #teasing :)

This will run a bootstrap process and install the latest cappuccino-base into that folder.

Then you can activate it by doing:

source ~/.cappuccino/environments/master/bin/activate

This will update your $PATH to take binaries from the environment in question. It will also set $CAPP_BUILD to match.

From this point you can easily switch between different environments with just a simple command:

source ~/.cappuccino/environments/master/bin/activate
git checkout master
jake install
source ~/.cappuccino/environments/v0.9.9/bin/activate
git checkout v0.9.9
jake install

This example would build and install the master branch in ~/.cappuccino/environments/master/narwhal and Cappuccino 0.9.9 into `~/.cappuccino/environments/v0.9.9.

Now if you do:

source ~/.cappuccino/environments/master/bin/activate
cd TNKit && jake release && jake debug

It will build the TNKit using the master version of Cappuccino.

source ~/.cappuccino/environments/v0.9.9/bin/activate
cd TNKit && jake release && jake debug

And this will build the TNKit using the 0.9.9 version. As per the environment you’re in, doing capp gen -F TNKit . will either use the version built against the master, or the version built against 0.9.9, respectively.

To deactivate an environment you can either type capp_env_deactivate or close your Terminal.

Available today in Cappuccino’s master. Enjoy!

RSS
Posted by Antoine Mercadal
on Mar 05, 2016.
comments powered by Disqus