Python Implementation

Supported Interpreters

  • Python 2.x

Dependencies

Required Dependencies

Optional Dependencies

Installation of Dependencies on Debian-based Systems

$ sudo apt-get python-setuptools python-dev python-protobuf

Installation of Dependencies on MacOS using Homebrew

For installing RSB and its dependencies from source on Darwin, we recommend to use Homebrew, an easy-to-use package manager for MacOS.

$ brew install cmake boost protobuf

Installation of Dependencies on Windows Systems

Install Microsoft Visual Studio. If you are planning to use the Python implementation of RSB, only version 2008 currently works.

In order to install Spread a source-based installation is required. The visual studio solution for Spread 4.2 is currently broken. Hence only version 4.1 can be used.

In detail, perform the following steps:

  1. Open spread.sln in the win32 folder of the spread archive with Visual Studio.
  2. Set the active configuration to release.
  3. Build libspread and spread. If you build the whole solution errors might appear. However, only the aforementioned artifacts are required.
  4. Optionally, manually copy the generated .lib and .exe to an installation prefix.

Python can be installed using the binary installer. A 32 bit version is recommended.

Installation

  1. Clone RSB and its immediate dependencies from the git repository

    RSC

    “0.15” branch of https://code.cor-lab.org/git/rsc.git

    RSB Protocol

    “0.15” branch of https://code.cor-lab.org/git/rsb.git.protocol

    RSB Python

    “0.15” branch of https://code.cor-lab.org/git/rsb.git.python

  2. Install RSC and the RSB protocol definitions as described in the C++ installation instructions.

  3. Create and edit setup.cfg

    See also

    Setuptools Documentation

    Documentation of the format of the setup.cfg file

    Setuptools does not use command line arguments to configure projects. Instead a file called setup.cfg in the project root is used.

    Add or replace protocolroot in section [proto] with the path to the RSB protocol files (e.g. protocolroot=PREFIX/share/rsbprotocol). An exemplary setup.cfg file could look like this:

    # [existing content here]
    
    [proto]
    protocolroot=/your/prefix/share/rsbprotocol
    

    Note

    The following RSB-specific options are recognized:

    protoc in section [proto]

    The Google protocol buffers protoc compiler used to generate code from the RSB protocol description. If not specified PATH is used.

    format in section [doc]

    Either html or pdf for the API documentation generation.

    verbose in section [doc]

    Bool flag to control verbose output of the generation tool epydoc.

  4. Start building and installation

    $ export PYTHONPATH=PREFIX/lib/python2.VERSION/site-packages # if you are install to /usr or /usr/local it must be dist-packages
    $ python setup.py build
    $ python setup.py install --prefix=PREFIX
    

Adding Support for Spread

Install Spread as described in the C++ installation instructions.

Installation of the Spread module for Python

Warning

The Spread Python version automatically installed by setuptools is not working.

  1. Download sources from http://www.spread.org/files/SpreadModule-1.5spread4.tgz.

  2. Extract the downloaded archive file and change to the SpreadModule-1.5spread4 directory

  3. Edit setup.py and set SPREAD_DIR to your installation prefix (e.g., /usr, /your/prefix or c:\code\spread)

    Note

    On Windows it might also be necessary to change the following aspects of the setup.py:

    include_dirs = [SPREAD_DIR + r"\include"],
    library_dirs = [SPREAD_DIR + r"\lib\win32"],
    libraries = ['libspread', 'wsock32'],
    # comment out
    #extra_link_args = ['/NODEFAULTLIB:libcmt'],
    
  4. Build and install

    $ python setup.py build_ext --rpath PREFIX/lib
    $ python setup.py install --prefix=PREFIX
    

    Note

    It might be that the --rpath option needs to be removed on Windows.

Testing the Installation

See also

Invoking the Interpreter
How to configure and start the Python interpreter.

The following statement should succeed in a python shell:

import rsb

Note

It may be necessary to set PYTHONPATH to PREFIX/lib/python2.X/site-packages as in the installation step above.