Easy access and remote control of local/remote Python instances
Project description
- Info:
See the Simple Remote Python site for more information.
- Copyright:
- 2009 by Ricardo Henriques
- License:
BSD, see LICENSES folder for more details.
About
Simple Remote Python - SRPy (pronounced ser-pie) is a Python/Jython module providing easy access and control of local/remote python instances. It features:
Remote control of python instances (through Python or Jython)
Parallel execution of python code on SMP and clusters
Simple and light weight
Low overhead
Pure python
Cross-platform portability and interoperability (Windows, Linux, Unix, Mac OS X)
Cross-architecture portability and interoperability (x86, x86-64, etc.)
Open source
Note: Although Jython SRPy clients are supported, the server will not run under Jython. This is a limitation inherited by the Pyro dependency.
Installation
If you have setuptools installed you should be able to do easy_install srpy to install SRPy. Otherwise you can download the project source and do python setup.py install to install. SRPy also works directly from source, just copy the folder srpy to your favorite location and import it. To start the server do: python path/to/srpyapp.py
Dependencies
The SRPy distribution depends on the Pyro and Parallel-Python packages, these are bundled inside SRPy. It has been tested on Python 2.5 and 2.6.
Acknowledgments
- SRPy is not the only software of the genre, many other great libraries that provide similar features are available:
- Many of the ideas inside SRPy have come from this packages, we don’t intend to be the best, just a different flavor that concentrates in bringing
easy of use
compatibility with the great features brought from [http://pyro.sourceforge.net/ Pyro] and [http://www.parallelpython.com/ Parallel-Python]
both Python and Jython compatibility
Examples
Here’s a basic example:
>>> import srpy >>> pyeng=srpy.PythonEngine("PYRO://157.99.245.20:7767/9d63f5141e70441a42018b6d48c8cc6c") >>> pyeng.get() ['debug', '__builtins__', 'types'] >>> pyeng.set(a=3) >>> pyeng.get() ['debug', '__builtins__', 'a', 'types'] >>> pyeng.get('a') 3
>>> pyeng.imp('math') >>> pyeng.eval('math.sqrt(b)', b=2) 1.4142135623730951 >>> pyeng.exe('c=math.sqrt(c)', c=5) >>> pyeng.get('c') 2.2360679774997898 >>> pyeng.ns.dir() ['__args__', '__builtins__', '__kwds__', 'a', 'c', 'debug', 'math', 'types']
>>> pyeng.ns.math.sqrt(5) 2.2360679774997898 >>> pyeng.ns.whoami='Ricardo' >>> pyeng.ns.whoami 'Ricardo'
>>> # Jython friendly NumPy >>> pyeng.imp('numpy') >>> pyeng.exe("zeros=lambda *args, **kwds: numpy.zeros(*args, **kwds).tolist()") >>> pyeng.ns.zeros((2,2)) [[0.0, 0.0], [0.0, 0.0]] >>> pyeng.ns.zeros(shape=(2,2), dtype='uint16') [[0, 0], [0, 0]]
Documentation
You will need epydoc installed to generate the documentation. Documentation can be generated by running epydoc –config=epydoc-config. Generated documentation can be found in the doc/ directory. Also do python path/to/srpyapp.py –help to see the server options.
Changelog
- 0.1.2
Fixed several errors
Added EngBox class to srpyclient to help manage multiple PythonEngines
- 0.1.1
Fixed a Pyro import error: Successfully imports bundled Pyro if available
srpy and srpy-bundled are now a unified package