Home - Forums - Documentation - Gallery - Bugs
(Compiling Python bindings with MSVC - typos and spelling fixes)
Current revision (19:05, 14 May 2008) (edit) (undo)
(What you need)
 
(One intermediate revision not shown.)
Line 4: Line 4:
This tutorial explains you, how you can build cspython, _cspace, and CEL blpython plugins with MSVC. First, I assume, you successfully compiled CS (and optionally CEL). You can find the complete guide to do this in the [http://www.crystalspace3d.org/docs/online/manual-1.0/cs_2.4.2.php#2.4.2 manual].
This tutorial explains you, how you can build cspython, _cspace, and CEL blpython plugins with MSVC. First, I assume, you successfully compiled CS (and optionally CEL). You can find the complete guide to do this in the [http://www.crystalspace3d.org/docs/online/manual-1.0/cs_2.4.2.php#2.4.2 manual].
-
Get python packages from the official [http://www.python.org site], and download a Windows binary package. Install it. I tested this tutorial with Python 2.3.5 and it will not work with Python 2.5!!!
+
Get python packages from the official [http://www.python.org site], and download a Windows binary package. Install it.
Finally, download the correct ''cs_pyth.cpp'' from [http://www.crystaldoc.atw.hu/src/CS/cs_pyth.zip here]. Extract the zip file, and copy int your CS/plugins/cscript/csypthon directory. Yes, rewrite the original file.
Finally, download the correct ''cs_pyth.cpp'' from [http://www.crystaldoc.atw.hu/src/CS/cs_pyth.zip here]. Extract the zip file, and copy int your CS/plugins/cscript/csypthon directory. Yes, rewrite the original file.
Preparation finished.
Preparation finished.
Line 43: Line 43:
You can download my build from [http://crystaldoc.atw.hu/_cspace.rar here].
You can download my build from [http://crystaldoc.atw.hu/_cspace.rar here].
- 
-
== Creating CEL Python behavior layer ==
 

Current revision

Contents

Compiling Python bindings with MSVC

What you need

This tutorial explains you, how you can build cspython, _cspace, and CEL blpython plugins with MSVC. First, I assume, you successfully compiled CS (and optionally CEL). You can find the complete guide to do this in the manual. Get python packages from the official site, and download a Windows binary package. Install it. Finally, download the correct cs_pyth.cpp from here. Extract the zip file, and copy int your CS/plugins/cscript/csypthon directory. Yes, rewrite the original file. Preparation finished.

Setting up MSVC IDE

1. Run MSVC IDE.

2. Go to the Tools->Options->Projects and Solutions->VC++ Directories Select Include files above. Click to New Line icon, and type or select your Python"2X/Include directory.

3. Select Library files Click to New Line icon, and type or select your Python"2X/libs directory.

From now MSVC will find Python related headers and directories.

Adding projects to CS solution

There are VC projects for cspython and _cspace.pyd shipped with Crystal Space; however, they're not contained in the default solutions since Python may not be present on the user's machine, and the default solutions shouldn't produce build errors.

Open up the Crystal Space solution you normally use.

Right click on the Solution item and choose Add->Existing Project....

Navigate to the directory with the Crystal Space Visual C++ projects for your version of VC (e.g. mk/msvc8). Add the libcrystalspace_python project. Repeat for plgcspython and plg_cspace.

Once they have been added, the dependencies must be set correctly. Right click plg_cspace, choose Project Dependencies.... Tick libcrystalspace and libcrystalspace_python in the Depends On list. Repeat for plg_cspace.

If you now hit F7 to build the solution, the three projects added should be built, with the Python module (_cspace.pyd) and the Python CS plugin (cspython.dll) as the result.

Creating _cspace.pyd

When you want to write CS applications with Python, you need to compile _cspace.pyd. This is easy. You need to compile:
cs_pyth.cpp
pythmod.cpp

in one project. All project settings are the same, like in the previous, but you don't need any rc file. Additional settings are here: manual. When you copy cspace.pyd in your CS/scripts/python directory, you can run tutorial1,2,3 python scripts. Try them.

You can download my build from here.

| Article | Discussion | View source | History |