WindowsBuildAuto
From PyWiki
Contents |
Introduction UNDER CONSTRUCTION
This page is intended to show you how to build Python-Ogre under windows using an automated approach. It is broken down into a number of steps...
- Download and build the support libraries
- Build the various libraries (OGRE, OIS, etc)
- Create the Python-Ogre wrapper code
- Compile the Python-Ogre modules
NOTE: There is a more manual process available that you should fall back onto if something fails during the process documeted here:
Before you begin
You'll need:
- Python 2.5.x
- Visual Studio 2008 - either the full version or the free Express version of C++
- VC/Microsoft Updates - please ensure you run 'Windows Update' after installing MSVC to ensure you have any necessary service packs etc
- Platform SDK - if you've installed VC++ Express edition, you'll need to install Platform SDK as well
- DirectX SDK - used to build OIS and Ogre D3D renderer
- CVS - used to retrieve gccxml source]
- SVN command line binary
- Various GnuWin32 tools. Specifically
System PATH
you have to to put the following to your system path, so these tools can be accessible by the python-ogre compiling scripts:
- Python's exe location
- GnuWin32 bin folder
- C:\Program Files\Microsoft Visual Studio 9.0\VC\bin
- location to cvs.exe
- location to svn.exe
One easy way to set up your paths properly is to just use a batch file. You'll need to change the paths to reflect your own system of course. I put this in the directory just outside python-ogre (usually called development), and run it to get a command prompt with everything set up for me.
@echo off set GNUWIN32_PATH="C:\gnuwin32\bin" set MSVS_PATH="C:\Program Files\Microsoft Visual Studio 9.0" set PYTHON_PATH="C:\python26" set SVN_PATH="C:\Program Files\SlikSvn\bin" set CVS_PATH="C:\Program Files\cvs" call %GNUWIN32_PATH%\set_gnuwin32.bat -s gnuwin32 -l EN call %MSVS_PATH%\Common7\Tools\vsvars32.bat set PATH=%PYTHON_PATH%;%SVN_PATH%;%CVS_PATH%;%PATH% cls cmd /K "echo Python-Ogre Build Environment"
Visual Studio
For these instructions I'm assuming you are using Visual Studio 9.0 Express(2008).
When you install everything you'll need to set up various lib/include directories for DirectX, Platform SDK etc (Tools/Options/Projects and Solutions/VC++ Directories -- check Include and Library paths)
Note that vcvars32.bat should be run each time you open a DOS command prompt to ensure you have the paths and environment variables set correctly -- you can see an example of this in the scripts directory of the Python-Ogre source once you download it..
Let the Fun Begin
On to our Python-Ogre install by creating a master development directory somewhere suitable and checkout Python-Ogre from the SVN. Open a DOS box/Command Prompt
mkdir c:\development cd c:\development svn co https://python-ogre.svn.sourceforge.net/svnroot/python-ogre/branches/v1-6 python-ogre
Step 2
Retrieve the support libraries. NOTE: This assumes you have setup your vcvars.bat file correctly - have a look in python-ogre\scripts for an example -- I typically move the vcvars.bat into c:\windows (so it's in the path) and then edit c:\program files\microsoft visual studio 9.0\common7\tools\vsvars32.bat to reflect the necessary paths etc..
If you're building this for the first time, I recommend always adding the -v flag to BuildModule, so you can spot and fix errors faster.
cd c:\development
vcvars32
python python-ogre\BuildModule.py -r cmake gccxml boost scons pygccxml pyplusplusAll the source files will have been placed in the ./downloads directory (or in ./gccxml and ./pygccxml as these are cvs/svn retrieves)
Step 3 build Libraries
Build the support libraries. You may want to build cmake first, as you'll need to fix your path when it's done for the rest to work.
python python-ogre\BuildModule.py -b cmake python python-ogre\BuildModule.py -b boost pygccxml scons pyplusplus
Any errors will be written to log.out so have a look there if there is an issue. If a single module fails you can run it individually to test again, realising that the order can be important .
python python-ogre/BuildModule.py -b <<modulename>>
build gccxml
We need to build gccxml and this can't be fully automated as it needs to build a vc project file and use MSVC to build it.
Run CMAKE from the start menu Set "C:\development\gccxml" as the source and binaries directory Press "Configure" (may have to run this twice after first set of 'issues' are shown) Press "OK" to create the project file (in the c:\development\gccxml directory) Run MSVC from the start menu Open the gccxml.sln project file from the gccxml directory Set the 'Build/Configuration Manager' to Release Build gccxml.
Step 4
Download and build the base Ogre libraries
python python-ogre/BuildModule.py -r cegui ois ogre python python-ogre/BuildModule.py -b ois ogre python python-ogre/BuildModule.py -b cegui
Now this hasn't actually built the libraries, but they should now be downloaded, unpacked and patched as required under the c:\development directory.
We now use MSVC to build them
At this point you can run the Ogre C++ samples
c:\development\ogre\samples\common\bin\release\demo_smoke
Step 5
Generate the wrapper code(-g), compile(-c) and install it
cd ~/development python python-ogre/BuildModule.py -g -c ois ogre python python-ogre/BuildModule.py -b install
Testing
You can now run the Python-Ogre demos.
NOTE: The demos will look for a plugins.cfg file in the ./demo directory first, and if that isn't found it looks in the local directory. So if there is a plugins.cfg in ./python-ogre/demos you need to edit it to point to the correct path, otherwise edit the one in the ./python-ogre/demos/ogre directory. The intention of this is to allow a single plugins file (located in the ./demos parent directory) to be used by all the demos.
cd ./python-ogre/demos/ogre
python Demo_Grass.pyBuilding Additional Modules
There are many (nearly 20 at time of writing) Python-Ogre modules that can be built -- and the build procedure is the same for all of them. 1. Retrieve the source - Note: You must be in the 'development' directory (one above python-ogre) when running this script. Of course you can do one module at a time and you can combine the retrieve/build/generate/compile into a single step.
cd ~/development
python python-ogre/BuildModule.py -r ode ogreode newton ogrenewt ogreal bullet2. Build the underlying C libraries
cd ~/development
python python-ogre/BuildModule.py -b ode ogreode newton ogrenewt ogreal bullet3. Generate the wrapper code
cd ~/development
python python-ogre/BuildModule.py -g ode ogreode newton ogrenewt ogreal bullet4. Compile the wrapper code to make the python module
cd ~/development
python python-ogre/BuildModule.py -c ode ogreode newton ogrenewt ogreal bullet5. And install the modules:
cd ~/development python python-ogre/BuildModule.py -b install
Available modules
It Didn't Work -- What Now?
Config
open PythonOgreConfig_nt.py and adjust paths to reflect your build directories. Variables you might want to change:
- PATH_Boost - full path to where your boost is (eg. './boost_1_36_0'
- gccxml_bin - Path to gccxml.exe (exe included!)
- pyplusplus_install_dir
- PATH_LIB_Boost
- LIB_Boost
Building
The easiest way to get a module wrapped is to use BuildModule.py
Usage:
python BuildModule.py -r <module_name> - Retrieve's a module from the internet python BuildModule.py -b <module_name> - Unzip's and patches source if necessary python BuildModule.py -g <module_name> - Generates Code for boost.python python BuildModule.py -c <module_name> - Compiles module
NOTE: if BuildModule fails, it stores it's log file in <python-ogre-root>/log.out
- a More detailed tutorial on compiling Python-Ogre wrappers is available here