|
BuildingIbPy
How to Build IbPy
Featured SynopsisThis tutorial describes how to build IbPy from scratch. By using this method, you can create an IbPy installation for the latest TWS API version. PrerequisitesWe'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 srcInstall java2pythonTo 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 --userThis 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 IbPyThe remaining build process is automated from within the IbPy package. Check out the source: $ cd ~/src
$ svn co http://ibpy.googlecode.com/svn/trunk ibpyNext 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
$ makeBuild a DistributionAt 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
$ makeThis 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. | |
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.
I am having problems getting antlr and java2python installed. Is it still necessary to use such an older version of java2python?
@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!