This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!
Project Description

This is a Buildout recipe that automates the download, configuration, and deployment of Jython, the Python environment implemented in Java.

Introduction

Java is a statically-typed, object-oriented, compiled programming language with a vast standard application programmer interface (API) as well as enterprise API. Python is a dynamically-typed, object-oriented scripting language with a vast API but fewer enterprise features. Jython brings the agility of Python to the elephantine vastness of Java by implementing the Python runtime in Java and providing access to Java’s APIs.

Buildout is a civilized, coarse-grained environment for managing repeatable software deployments. Buildout is driven by recipes, each of which accomplish a specific goal, often in a cross-platform method. This recipe, sk.recipe.jython, enables the user to automatically download, configure, and deploy Jython in a Buildout environment.

Installation

Since this is a Buildout recipe, there’s nothing really to install. Just mention the recipe name in a buildout and enjoy! For example, your buildout.cfg might be something like this:

[buildout]
develop = src/myegg
parts =
    jython
    myegg
[jython]
recipe = sk.recipe.jython
[myegg]
recipe = zc.recipe.egg
python = jython
interpreter = mypy
eggs = myegg

The above buildout accomplishes the following:

  • Specifies a Python egg in-development in src/myegg.
  • Downloads and installs Jython.
  • Creates a new interpreter bin/mypy pre-baked with myegg and powered by Jython.

Easy!

Supported Options

The sk.recipe.jython recipe supports the following options:

url
(Optional.) URL to a release of Jython. If not given, defaults to the URL to the 2.5.1 release of Jython. This URL must point to a Jython installer jar file.
md5sum
(Optional.) MD5 hash of the Jython installer mentioned by url. If specified, the downloaded Jython release will be checked against this hash and installation will not proceed if there’s a mismatch. If both md5sum and url are missing, then the recipe will check the 2.5.1 release for its proper MD5 hash, 2ee978eff4306b23753b3fe9d7af5b37.
java
(Optional.) Full path to a Java virtual machine executable. If not specified, the recipe will find one by shell path. This java executable will be invoked to install Jython only, not for Jython’s runtime. Example: /usr/java/j2sdk/bin/java.
jre
(Optional.) Home directory of a Java runtime or development kit used to run Jython. Specify this if you wish to have Jython use a separate runtime from that of the installer. Unlike the java option above, the jre option expects the home directory of a Java runtime; i.e., there will be bin, lib, etc., directories in the directory named by this option. Exampe: /System/Library/Frameworks/JavaVM.framework/Home.
include-parts
(Optional.) List of parts to install. See “Installable Parts” below. If not specified, you’ll get a minimal Jython installation, which is more than likely what you’ll want if you’re developing Jython-based applications.

All options are optional. Really. By default the recipe makes a complete Jython installation in the Buildout’s parts/jython directory (you can override the parts directory in the [buildout] itself). That means your recipe can be as simple as:

[jython]
recipe = sk.recipe.jython

This recipe exports two values that are handy in other recipes:

location
This exported option identifies where the recipe installed Jython. You can use its value as the JYTHON_HOME environment variable.
executable
This exported option names the path of the jython executable. You can use this as a Python interpreter, for example with the zc.recipe.egg collection of recipes.

Installable Parts

Jython consists of a number of parts that comprises an installation. The include-parts option specifies which extra parts to include in an installation (by default, no additional parts are installed). The additional parts are:

  • mod: Library modules.
  • demo: Demonstrations and example code.
  • doc: Documentation.
  • src: Source code to Jython.

Example Usage

For this demonstration, we’ll use a fanciful Jython installer jar (actually an empty file) and Java virtual machine (written in Python) to mimic what the actual an Jython installer does. In actuality, it merely echoes the options given to it. These files are in the testdata directory:

>>> import os.path
>>> testdata = join(os.path.dirname(__file__), 'testdata')

The file java is actually an executable Python script, while jython-fake.jar is an empty file.

Let’s create a buildout to build and install Jython:

>>> write(sample_buildout, 'buildout.cfg', '''
... [buildout]
... parts = jython
...
... [jython]
... recipe = sk.recipe.jython
... java = %(testdata)s/java
... url = file://%(testdata)s/jython-fake.jar
... ''' % dict(testdata=testdata))

This will “download” the fake Jython installer and install it with all parts. Running the buildout:

>>> print system(buildout)
Installing jython.
"JVM": Jython installer in file ".../jython-fake.jar"
"JVM": Installer options: ['--silent', '--directory', '/sample-buildout/parts/jython']

And the parts directory should now have Jython installed:

>>> ls(sample_buildout, 'parts')
d jython

Using Additional Options

Let’s exercise the jre and include-parts options, specifying a mythical JRE at /usr/mythical/java/j3sdk and asking for the documentation (doc) and source code (src) to be installed:

>>> write(sample_buildout, 'buildout.cfg', '''
... [buildout]
... parts = jython
...
... [jython]
... recipe = sk.recipe.jython
... java = %(testdata)s/java
... jre = /usr/mythical/java/j3sdk
... include-parts =
...     doc
...     src
... url = file://%(testdata)s/jython-fake.jar
... ''' % dict(testdata=testdata))

Re-running the buildout now gives us:

>>> print system(buildout)
Uninstalling jython.
Installing jython.
"JVM": Jython installer in file ".../jython-fake.jar"
"JVM": Installer options: ['--silent', '--directory', '/sample-buildout/parts/jython', '--jre', '/usr/mythical/java/j3sdk', '--include', 'doc', 'src']

Perfect.

MD5 Hashes

Let’s re-write the buildout but inject an error: an incorrect MD5 hash:

>>> write(sample_buildout, 'buildout.cfg',
... '''
... [buildout]
... parts = jython
...
... [jython]
... recipe = sk.recipe.jython
... java = %(testdata)s/java
... md5sum = c120503f1e327388bd0b6bbdee530733
... url = file://%(testdata)s/jython-fake.jar
... ''' % dict(testdata=testdata))

The hash shown above is not the correct MD5 for an empty file (which is what jython-fake.jar is). Running the buildout should bail:

>>> print system(buildout)
Uninstalling jython.
Installing jython.
While:
  Installing jython.
Error: MD5 checksum mismatch...

Specifying the correct MD5:

>>> write(sample_buildout, 'buildout.cfg',
... '''
... [buildout]
... parts = jython
...
... [jython]
... recipe = sk.recipe.jython
... java = %(testdata)s/java
... md5sum = d41d8cd98f00b204e9800998ecf8427e
... url = file://%(testdata)s/jython-fake.jar
... ''' % dict(testdata=testdata))

Makes the problem go away:

>>> print system(buildout)
Installing jython.
"JVM": Jython installer in file ".../jython-fake.jar"
"JVM": Installer options: ['--silent', '--directory', '/sample-buildout/parts/jython']

That’s pretty much it.

Changelog

0.0.0

This release is destined to become the eventual GA release.

Release History

Release History

0.0.0

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.0dev-r14

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.0dev-r6

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
sk.recipe.jython-0.0.0-py2.4.egg (14.9 kB) Copy SHA256 Checksum SHA256 2.4 Egg Feb 21, 2010
sk.recipe.jython-0.0.0-py2.5.egg (14.9 kB) Copy SHA256 Checksum SHA256 2.5 Egg Feb 21, 2010
sk.recipe.jython-0.0.0-py2.6.egg (14.9 kB) Copy SHA256 Checksum SHA256 2.6 Egg Feb 21, 2010
sk.recipe.jython-0.0.0.tar.gz (8.7 kB) Copy SHA256 Checksum SHA256 Source Feb 21, 2010

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting