My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for

Guides

API Reference

BuildingIbPy  
How to Build IbPy
Featured
Updated Nov 28, 2009 by troy.mel...@gmail.com

Synopsis

This tutorial describes how to build IbPy from scratch. By using this method, you can create an IbPy installation for the latest TWS API version.

Prerequisites

We're going to assume that you're using a modern POSIX system (such as Linux, Mac OS, or one of the BSDs). We're also going to assume that you've got Python installed.

Everything we do will be in a directory called src in our home directory. If you don't have such a thing, run these commands:

    $ cd ~
    $ mkdir src

Install java2python

To build IbPy sources, we need java2python and its dependancies. Be sure you've installed Antlr 2.7.7 and its Python library.

You'll need a very specific version of java2python, revision 50. Checkout, build and install:

    $ cd ~/src
    $ svn co -r 50 http://java2python.googlecode.com/svn/trunk java2python
    $ cd java2python/java2python
    $ make
    $ cd ..
    $ python setup.py install --user

This will install the java2python package into ~/.local/lib/python2.6/site-packages, and the j2py script in ~/.local/bin. Make sure the bin directory is in your PATH.

Checkout IbPy

The remaining build process is automated from within the IbPy package. Check out the source:

    $ cd ~/src
    $ svn co http://ibpy.googlecode.com/svn/trunk ibpy

Next we need to build the translated source code. The Makefile in ib/ext handles this for us:

    $ cd ~/src/ibpy/ib/ext
    $ make modules-clean
    $ make

Build a Distribution

At this point, you can copy or symlink the directory ~/src/ibpy/ib into your Python path and it will work. If you'd rather have a full distribution, you can now build that and install from it instead.

    $ cd ~/src/ibpy
    $ make

This will create two files, one .tar.gz and one .zip, in the release-M-N directory, where M is the IbPy version and N is the TWS API version.

Comment by bob.mcel...@gmail.com, Mar 18, 2011

Holy crap that was painful. I succeeded, in the end. But the procedure is extremely picky about the version of antlr and python-antlr that are installed. These had to be hand-installed since the ones in ubuntu are old, and somehow don't match versions. Doing that required installing Maven.

Making the modules requires that python be able to find the ib module, so after make modules-clean you should run PYTHONPATH=../.. make.

So I now have API version 9.65 built.

Comment by leonba...@gmail.com, Jan 29, 2012

I am having problems getting antlr and java2python installed. Is it still necessary to use such an older version of java2python?

Comment by kram...@gmail.com, May 1, 2012

@Leon (and all other people trying to build ibpy from source)

I also ran into trouble building java2python (on Ubuntu 12.04), and with me the problem seemed to be that when building java2python it was looking for the file /usr/bin/antlr, which didn't exist. With the help of some friendly people over at the ubuntuforums I found out that the file to run antlr was /usr/bin/runantlr. So I made a symlink from /usr/bin/antlr to /usr/bin/runantlr using the following command: sudo ln -s /usr/bin/runantlr /usr/bin/antlr

After fixing that, the build worked correctly. Yet have to test the result (just built it a minute ago), but this tip might at least help you abit further.

Cheers!


Sign in to add a comment
Powered by Google Project Hosting