Development Environment

This article describes, how to set up a development environment that doesn't need you to install libsoy and pysoy every time you build changes and try it out. The reason why you would want to do this is to be able to develop on a system where you don't have root rights, if you don't want to harm the installed pysoy version or if you want to work on multiple versions at the same time.

Preparation

To start we will define some directories where you put your stuff:

  • %libsoy% is the directory where you checked out the libsoy source code
  • %pysoy% is the directory where you checked out the pysoy source code
  • %install% is a directory where you will install libsoy to, only user access is necessary, don't use a system directory for it

An example for these directories would be:

  • %libsoy% = ~/soy/libsoy
  • %pysoy% = ~/soy/pysoy
  • %install% = ~/soy/install

Replace all further occurrences of this paths in the article below with the directories you chose. This article is not about mercurial, so make sure you have the repositories checked out in the first two directories. A good tutorial can be found at  http://hginit.com/.

libsoy / soy-1

The first step is to configure, where we will use the prefix / as opposed to the default /usr/local prefix, mostly to keep our paths shorter.

cd %libsoy%
./waf configure --prefix=/

Building now consists of two steps:

./waf build
./waf install --destdir=%install%

Preparing libsoy for pysoy

In order to be able to compile pysoy it needs to find libsoy. For this the program pkg-config is used which has configuration files to find specific libraries. As we didn't install libsoy system wide, we have to copy and modify this configuration file:

sed 's#prefix=/#prefix=%install%#' %install%/lib/pkgconfig/soy-1.pc > %install%/soy-1.pc

pysoy

Now we can configure pysoy using an environment variable for pkg-config:

cd %pysoy%
PKG_CONFIG_PATH=%install% ./waf configure

Building works as usual:

./waf build

Execution of a pysoy script

To execute a script now, it obviously needs to be told where libsoy and pysoy are. This is done by using environment variables again:

LD_LIBRARY_PATH=%install%/lib PYTHONPATH=%pysoy%/build/src python Example.py

Setting up an IDE

Now depending on which project you're working on (libsoy/pysoy) you only have to configure your IDE to execute the build steps above. The configuration steps only need execution when specific changes are made (eg. new build dependencies, python version of your system updated, new version number for libsoy, etc.). If you want to use MonoDevelop with which you can also debug libsoy/pysoy Code, you can follow the IDE Setup article.