| 1 | = Python-purple !HowTo = |
| 2 | |
| 3 | == Introduction == |
| 4 | |
| 5 | '''Python-purple''' is a python bind for libpurple. It was written using [http://www.cython.org Cython] extension. As the Cython's website says: ''"Cython is a language that makes writing C extensions for the Python language as easy as Python itself. Cython is based on the well-known Pyrex, but supports more cutting edge functionality and optimizations."''. |
| 6 | |
| 7 | '''Python-purple''' provides fully access to libpurple functions from python programs. You only need to import purple.so module (e.g. ''import purple'' from python shell) to start using python-purple. This HOWTO is not about modifying/extending python-purple bind itself, but how to write a python application using python-purple. |
| 8 | |
| 9 | == Downloading python-purple == |
| 10 | |
| 11 | Python-purple source code is part of Carman's project. To download from SVN repository, issue the following command: |
| 12 | |
| 13 | {{{ |
| 14 | svn checkout https://garage.maemo.org/svn/carman |
| 15 | }}} |
| 16 | |
| 17 | You will find python-purple source code inside ''carman/python-purple'' directory. |
| 18 | |
| 19 | == Building and installing python-purple == |
| 20 | |
| 21 | In order to build python-purple, you need the following packages: |
| 22 | |
| 23 | * cdbs |
| 24 | * debhelper |
| 25 | * libpurple-dev |
| 26 | * libglib2.0-dev |
| 27 | * python2.5-dev |
| 28 | * python2.5-distutils |
| 29 | * cython (optional) |
| 30 | |
| 31 | NOTE: Although it's not dependent, cython should also needed if you want to re-create purple.c file (generated from cython using ''purple.pyx''). |
| 32 | |
| 33 | Building cython-generated ''purple.c'' file (optional): |
| 34 | |
| 35 | {{{ |
| 36 | $ cython purple.pyx -I libpurple/ |
| 37 | }}} |
| 38 | |
| 39 | This is also done by ''setup.py'' when running: |
| 40 | |
| 41 | {{{ |
| 42 | $ python2.5 setup.py build |
| 43 | }}} |
| 44 | |
| 45 | If you don't need to generate ''purple.c'' file, you can use ''setup_dist.py'': |
| 46 | |
| 47 | {{{ |
| 48 | $ python2.5 setup_dist.py build |
| 49 | }}} |
| 50 | |
| 51 | Both setups generates ''purple.so'' inside ''build/'' directory. The difference is that ''setup.py'' also generates ''purple.c'' file, if it doesn't exists. |
| 52 | |
| 53 | To install files inside your system: |
| 54 | |
| 55 | {{{ |
| 56 | $ sudo python2.5 setup.py install --root=/usr |
| 57 | }}} |
| 58 | |
| 59 | You can also create a debian package of it: |
| 60 | |
| 61 | {{{ |
| 62 | $ dpkg-buildpackage -rfakeroot |
| 63 | }}} |
| 64 | |
| 65 | == Run python-purple module == |
| 66 | |
| 67 | To import ''purple'' module inside a python program, you need to call python interpreter and/or run the python script with '''LD_PRELOAD''' tag attached. For example: |
| 68 | |
| 69 | {{{ |
| 70 | $ LD_PRELOAD=/usr/lib/libpurple.so.0 python2.5 nullclient.py |
| 71 | }}} |