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.
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: inside cs directory: cspace.py and _cspace.pyd (or _cspace.so on unix like systems) inside cel directory: blpython.dll (ot blpython.so on unix like systems) and blcelc.py
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 (cspace.py and _cspace.*) must be in the pythonpath (setting PYTHONPATH to the CRYSTAL dir should be enough at this point).
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 (as an example "export PYTHONPATH=$CRYSTAL:$CEL:/path/to/worlfile.zip").
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.
Problems linking on linux-ppc
This is a known ppc gcc problem, and we're trying to work around this on a branch on svn. You can try to contact the python people to help on testing this, other than this there is no known solution yet.
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, $CRYSTAL:$CEL:/path/to/worlfile.zip, on windows: right click my computer, properties Advanced tab, Environment variables button).
Back to PyCrystal