This post was updated on Feb 11, 2013, since the old way never works now. However, the original post is still available here.
Travis CI is a hosted continuous integration service for the open source community, helping run tests for your GitHub projects for every single push and pull request. However, by the time this post is written, Travis CI has not officially supported Jython, a Python interpreter written in Java. This post will help you setup a Jython testing environment for a Python project on Travis CI.
Setup a Basic Travis CI Configuration for Your Python Project
Before we add a Jython testing environment, we need to setup a basic
configuration for the Python project. By reading
the Getting Started page and
Language-specific Guides for Python
in the Travis CI Documentation, you should understand how Travis CI works, and
the basic stuff of building your own configurations. Let's suppose we have the
following basic configuration file
Now we could have our python project tested with Python 2.6 and 2.7 on Travis CI. Then, let's add Jython as a Python interpreter for this project.
Add Jython Support for Your Python Project
You cannot simply append a
jython item to the
python list if you want your
project tested with Jython, because Jython is not supported officially. But we
can do something to make it work.
Here we need to take advantage of the Build Matrix feature of Travis CI.
First, add env entries to the
Then what we need to do is to use Jython if
JYTHON=true, and use C Python if
JYTHON=false. However, the testing matrix has 4 entries, two of which are
JYTHON=true entries, thus we need to let Travis CI ignore one of them. We
could achieve this by appending the following lines:
Then, tell Travis CI to install Jython by adding the following line to your
By the time this post is written, the Jython version by
sudo apt-get install
2.2.x, which is a bit outdated. If you want to install a later
version of Jython, such as
2.5.2, you could use the following lines instead of
the line above:
Then modify the test script to include the use of jython:
Note that we run
jython -c "print ''" before we run the testing script,
because something like the following may print when Jython run for the first
time, which may affect the testing result:
*sys-package-mgr*: processing new jar, '/home/vagrant/jython/jython.jar' *sys-package-mgr*: processing new jar, '/usr/lib/jvm/java-6-openjdk/jre/lib/resources.jar' *sys-package-mgr*: processing new jar, '/usr/lib/jvm/java-6-openjdk/jre/lib/rt.jar' *sys-package-mgr*: processing new jar, '/usr/lib/jvm/java-6-openjdk/jre/lib/jsse.jar' *sys-package-mgr*: processing new jar, '/usr/lib/jvm/java-6-openjdk/jre/lib/jce.jar' *sys-package-mgr*: processing new jar, '/usr/lib/jvm/java-6-openjdk/jre/lib/charsets.jar' *sys-package-mgr*: processing new jar, '/usr/lib/jvm/java-6-openjdk/jre/lib/rhino.jar' *sys-package-mgr*: processing new jar, '/usr/lib/jvm/java-6-openjdk/jre/lib/ext/sunjce_provider.jar' *sys-package-mgr*: processing new jar, '/usr/lib/jvm/java-6-openjdk/jre/lib/ext/pulse-java.jar' *sys-package-mgr*: processing new jar, '/usr/lib/jvm/java-6-openjdk/jre/lib/ext/gnome-java-bridge.jar' *sys-package-mgr*: processing new jar, '/usr/lib/jvm/java-6-openjdk/jre/lib/ext/localedata.jar' *sys-package-mgr*: processing new jar, '/usr/lib/jvm/java-6-openjdk/jre/lib/ext/dnsns.jar' *sys-package-mgr*: processing new jar, '/usr/lib/jvm/java-6-openjdk/jre/lib/ext/sunpkcs11.jar'
.travis.yml should look like this:
Or like this:
In this way, there will be one more testing for Jython every time the testing is triggered.