Home - Forums - Documentation - Gallery - Bugs
Current revision (19:05, 14 May 2008) (edit) (undo)
(What you need)
 
(4 intermediate revisions not shown.)
Line 3: Line 3:
== What you need ==
== What you need ==
-
This tutorial explains you, how you can build cspython, _cspace, and CEL blpython plugins with MSVC. First, I assume, you succeslfully compiled CS (and optionally CEL). You can find the comlete 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 11: Line 11:
1. Run MSVC IDE.
1. Run MSVC IDE.
 +
2. Go to the ''Tools->Options->Projects and Solutions->VC++ Directories''
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.
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.
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.
+
From now MSVC will find Python related headers and directories.
-
== Creating the solution ==
+
== Adding projects to CS solution ==
-
Click to the ''File->New->Project...'' and select ''Win32 console application'' template.
+
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.
-
Add a name to your solution (''csypthon'' is ideal), select the location of your project.
+
-
Click to the ok. Now click to the ''Application settings''. Set as DLL project and check the Empty project box. Now click to the finish button.
+
Open up the Crystal Space solution you normally use.
 +
Right click on the ''Solution'' item and choose ''Add->Existing Project...''.
-
Now click to the Solution explorer, right click to the ''Headers->Add existing item...''. Add the following headers to your project from your ''CS/plugins/cscript/cspython'' directory:
+
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''.
-
'''cspython.h<br>
+
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''.
-
'''pytocs.h'''<br>
+
-
Noe right click to the source files, Add existing item, then add the following source files to your project from your ''CS/plugins/cscript/cspython'' directory:
+
-
'''cs_pyth.cpp<br>
+
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.
-
'''cspython.cpp<br>
+
-
'''pytocs.cpp'''<br>
+
-
 
+
-
Now right click to the Resource files, add existing item. Navigate to your ''CS/mk/msvc'' directroy, and add '''cspython.rc''' to your project.
+
-
 
+
-
Press '''F7''' to build the solution.
+
== Creating _cspace.pyd ==
== Creating _cspace.pyd ==
-
When you want to write Cs applications with Python, you need to compille _cspace.pyd. This is easy. You need to compile:<br>
+
When you want to write CS applications with Python, you need to compile _cspace.pyd. This is easy. You need to compile:<br>
'''cs_pyth.cpp <br>
'''cs_pyth.cpp <br>
'''pythmod.cpp'''<br>
'''pythmod.cpp'''<br>
-
in one prioject. All project settings is the same, like in the previous, but you don't need any rc file. Additional settings are here:
+
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:
[http://www.crystalspace3d.org/docs/online/manual-1.0/cs_4.18.4.php#4.18.4 manual].
[http://www.crystalspace3d.org/docs/online/manual-1.0/cs_4.18.4.php#4.18.4 manual].
-
When you copiy cspace.pyd int oyur ''CS/scripts/python'' directory, you can run turial1,2,3 python scprits. Try it.
+
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 [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 |