These are just a few basic things you will need to ensure that you can use Python with CS and CEL.
1. First make sure you have Python installed
Python.org is a good place to get Python and find tutorials.
SWIG is a library which connects programs written in C/C++ with a variety of high-level programming languages. The CS/CEL python bindings use SWIG to generate the Python API. So you will need SWIG installed before you compile CS and CEL in order for them to create the python bindings. Tested versions of swig include 1.3.24 or 1.3.27, 1.3.28, 1.3.29, 1.3.31.
If you needed to install SWIG and/or Python, you will need to reconfigure and recompile CS and CEL.
You should check you have the following:
* cs: * both .py and .so files at out/<platform>/<buildmode>/bindings/python/cspace/
* cel: * blpython.dll in scripts/folder * _blcelc.so in out/<platform>/<buildmode>/bindings/python/ * blcelc.py in cel root folder or cel/scripts folder (depending if you used swig or not)
* CS: * .py files will be at scripts/python/frozen * .pyd files are in CS root folder.
* cel: * blcelc.py in scripts/ folder. * blpython.dll and _blcelc.pyd in cel root folder.
There are several apps you can run to test the python bindings are working correctly.
- For cs bindings: run pysimp from the crystalspace dir.
- For cel bindings: run start_smallgame.sh from the cel dir. Note for this the crystalspace python module (out/<platform>/<buildmode>/bindings/python/cspace/) must be in the pythonpath (setting PYTHONPATH to that dir should be enough at this point, or else just run "jam install_bindings").
Setting environment variables correctly
You should check that you have correctly set the CRYSTAL and CEL environment variables as explained in the manual, and then, you should check the python modules (the ones from the Check stage above) are in pythonpath. This is done by setting the PYTHONPATH environment variable to point to the dirs where these are located.
Note also that for statically built celstart, you'll also need to point to the zipfile so python can find the scripts
linux example "export PYTHONPATH=$CRYSTAL/out/<platform>/<buildmode>/bindings/python/:$CEL:$CEL/out/<platform>/<buildmode>/bindings/python" for linux).
windows example: set PYTHONPATH to E:\CS\scripts\python\frozen;E:\CS\;E:\cel;E:\cel\scripts
CS python bindings take too long to compile
This most likely means you're running out of ram compiling the bindings. You can try closing as many apps as possible before compiling, or getting a precompiled solution. This shouldnt happen on 1.3 onwards.
Problems linking on linux-ppc
Should be fixed from 1.3 onwards.
Errors compiling the bindings
Most probably your swig generated files are not up to date due to some recent api change. You can try getting swig and reconfiguring+recompiling, or wait and update to catch the next update of the files from the server (note this can take some hours).
crystalspace.application.celstart: Can't load behaviour layer 'blpython' with id 'cel.behaviourlayer.python'!
If all else is working (ie, pysimp, python tutorials, cel smallgame), then probably you need to set the PYTHONPATH environment variable to point to your CRYSTAL and CEL python plugin locations, and possibly also to the zip file with the world (ie, like said before, on windows: right click my computer, properties Advanced tab, Environment variables button).
Back to PyCrystal