User Tools

Site Tools


python-install

The Python binding is available for both Python2 (tested with version 2.7 only) and Python3 (tested with version 3.4). Instructions depend on the Python version.

Build and install the Python 2 binding of the ROHC library from sources

The instructions hereafter are for native build on Unix-like systems, such as Linux, FreeBSD, or OpenBSD.

  1. Log in as normal user on the system on which you want to install the Python binding of the ROHC library.
  2. Install the swig dependency:
    $ su
    # yum install swig            # for RHEL/CentOS
    # apt-get install swig        # for Debian/Ubuntu
    # emerge -av swig             # for Gentoo
    # exit
  3. Install the Python dependencies:
    $ su
    # pip2 install future
    # exit
  4. Build the Python binding:
    $ cd contrib/python/
    $ python2 setup.py build
  5. Install the Python binding:
    $ su
    # python2 setup.py install
    # exit

The Python2 binding of the ROHC library is installed, you may now use it.

Build and install the Python 3 binding of the ROHC library from sources

The instructions hereafter are for native build on Unix-like systems, such as Linux, FreeBSD, or OpenBSD.

  1. Log in as normal user on the system on which you want to install the Python binding of the ROHC library.
  2. Install the swig dependency:
    $ su
    # yum install swig            # for RHEL/CentOS
    # apt-get install swig        # for Debian/Ubuntu
    # emerge -av swig             # for Gentoo
    # exit
  3. Install the Python dependencies:
    $ su
    # pip3 install future
    # exit
  4. Build the Python binding:
    $ cd contrib/python/
    $ python3 setup.py build
  5. Install the Python binding:
    $ su
    # python3 setup.py install
    # exit

The Python3 binding of the ROHC library is installed, you may now use it.

Cross-compiling the Python 3 binding of the ROHC library from sources

The instructions hereafter are for cross-compilation build on Unix-like systems. The instructions were tested on Gentoo Linux, please adapt them to your system when needed.

  1. Log in as normal user on the system on which you want to build the Python binding of the ROHC library.
  2. Cross-compile the ROHC library from sources for your target.
  3. Install the swig dependency:
    $ su
    # emerge -av swig
    # exit
  4. Build the Python binding:
    $ cd contrib/python/
    $ CC='arm-softfloat-linux-gnueabi-gcc -pthread' \
      CFLAGS='-I/usr/arm-softfloat-linux-gnueabi/usr/include/python3.5m/' \
      LDSHARED='arm-softfloat-linux-gnueabi-gcc -shared' \
      LDFLAGS='-L/usr/arm-softfloat-linux-gnueabi/usr/lib/' \
        python3.5 setup.py build
    $ # change arch in the library name
    $ ln -s _rohc.cpython-35m-x86_64-linux-gnu.so \
            build/lib.linux-x86_64-3.5/_rohc.cpython-35m-arm-linux-gnueabi.so

Run within Qemu with:

$ PYTHONPATH=/usr/arm-softfloat-linux-gnueabi/usr/lib64/python3.5/site-packages/:build/lib.linux-x86_64-3.5/ \
    qemu-arm -B 1048576 \
      /usr/arm-softfloat-linux-gnueabi/lib/ld-linux.so.3 \
        --library-path /usr/arm-softfloat-linux-gnueabi/lib:/usr/arm-softfloat-linux-gnueabi/usr/lib:/usr/lib/gcc/arm-softfloat-linux-gnueabi/6.1.0:../../src/.libs/:build/lib.linux-x86_64-3.5/ \
        /usr/arm-softfloat-linux-gnueabi/usr/bin/python3.5 ./example.py 5
python-install.txt · Last modified: 2016/07/03 19:55 by didier