-
Notifications
You must be signed in to change notification settings - Fork 34
Pythonect On Jython
Pythonect is a new, experimental, general-purpose dataflow programming language based on Python.
Pythonect programming language implementation is written purely in Python, making it (theoretically) easy to run on every Python implementation.
Jython is a Java implementation of the Python language. It allows users to compile Python source code to Java byte codes, and run the resulting bytecodes on any Java Virtual Machine.
This HOWTO explains how to run Pythonect 0.4.1 on Jython 2.7a2, it's written for Linux users, but can be easily ported to other platforms.
-
Download & Install Pythonect 0.4.1 or later:
easy_install pythonect
-
Download & Install Jython 2.7a2 or later
2.1. If you are using Jython 2.7a2, you will need to download this patch and apply it after the installation:
cd /opt/jython2.7a2/Lib/ wget http://dl.dropbox.com/u/29648242/jython2.7a2_queue_notifyall_fix.patch patch < jython2.7a2_queue_notifyall_fix.patch
NOTE: /opt/jython2.7a2 is not Jython's default directory, you have to REPLACE it with the directory you choose during the installation.
If successful, you should see:
patching file Queue.py
NOTE: This is a patch for Jython 2.7a2 only, other versions may need a different patch or no patch at all. (See: Issue #1963)
-
Execute Python and lookup current dist-package and PLY package paths:
import pythonect, ply pythonect.__file__ ply.__file__
If successful, you should see something like this:
>>> import pythonect, ply >>> pythonect.__file__ '/usr/local/lib/python2.7/dist-packages/pythonect/__init__.pyc' >>> ply.__file__ '/usr/local/lib/python2.7/dist-packages/ply-3.4-py2.7.egg/ply/__init__.pyc'
-
Write down the paths for Step #6
-
Execute Jython interpreter
-
Add Python's dist-package and PLY package to Jython's path (See Step #3):
import sys sys.path.insert(0, '/usr/local/lib/python2.7/dist-packages') sys.path.insert(0, '/usr/local/lib/python2.7/dist-packages/ply-3.4-py2.7.egg')
-
Import Pythonect package:
import pythonect
-
Greet yourself with a visual 'Hello, world' program that is written in Pythonect and uses Java Swing:
pythonect.eval('"Hello, world" -> javax.swing.JOptionPane.showMessageDialog(None, _, _, javax.swing.JOptionPane.PLAIN_MESSAGE)', {}, {})
Running Pythonect on Jython is still a bit patchy, but the results are promising. The ability to instrument, pipe, and chain Java code "AS IT IS".