LinuxBuildV2

From PyWiki

Jump to: navigation, search

Contents

Binary Packages

If you are using Debian or Ubuntu it is highly recommended that you use the Binary_Releases. Building Python-Ogre can take over 8 hours, while downloading a binary releases takes about 10 minutes.

Windows binary through Wine

A secondary binary package method that is zero-fuss:

1. Install Wine through your package manager (many tutorials online if you need help)

2. Install Python 2.5 for Windows using Wine

  (ActivePython will let you use other Windows functions (API) through Wine on your Linux Machine - Interesting)
  Or install normal Windows Python from python.org
     (You'll probably not find .exe installers that Wine likes, only .msi installers. Use "msiexec /i" installed by wine to open these.
     Setting your Wine to Windows98 and installing InstMsiA.exe might be necessary, look for tutorials online if the installers won't work immediately!)

3. Install the PythonOgre Windows binary into your Wine C: drive

DONE!

To run the demos and test this thoroughly, cd into your ~/.wine/drive_c/PythonOgre/demos folder and change the Plugins.cfg file (you might have to remove the .linux heading from the linux version and change the PluginsFolder path to your plugins folder.) The error messages generated by ogre when it can't find a plugin are pretty comprehensive!

Now type

alias wipy='/home/YOURUSERNAME/.wine/drive_c/Python25/python.exe'
wipy Demo_Grass.py

and enjoy a running PythonOgre demo :)

Idea first posted in forum by kyathir and tested by rdrey. If you need help EPost a complaint to myUserName+1 aka (rdrey1) in eatspam or gmail ~.Dot.~ com.


Introduction

Building Python-Ogre under Linux (tested with Ubuntu 8.04) is a straight forward, if slightly lengthy process. However please don't expect it to be a classic UNIX (untar, configure, make) build cycle as it's not. Python-Ogre is different in that it needs to build the underlying C/C++ libraries then create and compile the wrapper code. However all is not lost as there is a fairly simple build script and configuration that handles most of the complexity.

Note: we create all the libraries etc into the ./root/usr/... area so as to not overwrite any system libraries etc that you may have. Hence making the Python-Ogre build process a simple and "safe" one -- ie we never overwrite any system files or existing libraries.

We use a single build script (BuildModule.py) that can retrieve, build, generate wrapper code and compile the Python-Ogre modules (do a -h for more info or look at the script). It basically reads a set of commands from the environment.py script and executes them. By default all the logging is to log.out so if you have any problems have a look there.

If you use Gentoo Linux and are brave enough to overwrite system libraries, and you only want the wrappers for ogre, ois, and ogrenewt, then you can try the overlay ebuilds mentioned at the bottom of this page.

Notes on Installing in Ubuntu

Installation on Ubuntu 8.04 (the LTS version) works flawlessly, if you follow this guide on a clean install. Do note that you'll certainly need to install build-essentials to get g++ &c.

Between Ubuntu 8.04 and Ubuntu 9.04, there have been a few minor changes in the default set up. Most notably, the default Python now seems to be Python 2.6 instead of the older 2.5. So, you'll want to be aware of this and correct issues in the setup scripts as they arise. The simplest fix is to just live on python2.5: sudo rm /usr/bin/python; sudo ln -s `which python2.5` /usr/bin/python

Step 1

You will need to have subversion (svn) installed.

This can be done on Debian or Ubuntu by:

sudo apt-get install subversion

This can be done on SUSE by:

sudo zypper install subversion


On to our Python-Ogre install by creating a master development directory somewhere suitable (under your home directory is a good place) and checkout Python-Ogre from the SVN.

cd ~
mkdir development
cd development
svn co https://python-ogre.svn.sourceforge.net/svnroot/python-ogre/trunk/python-ogre python-ogre -r 1084

Ensure you have the necessary prerequisites installed. This is the only part of the build that you will need the superuser password Note if you are running a non Debian Linux (one with out apt-get) then you'll have to look at the script and work out for yourself that you have what is needed.

ln -s python-ogre/scripts/00-PreReqs.sh .
sh ./00-PreReqs.sh

Step 2

Retrieve the support libraries.

python python-ogre/BuildModule.py -r cmake gccxml boost cg scons freeimage zziplib pygccxml pyplusplus

All 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 the support libraries.

python python-ogre/BuildModule.py -b cmake gccxml boost pygccxml cg scons freeimage zziplib 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 (ie boost requires cmake).

python python-ogre/BuildModule.py -b <<modulename>>

Step 4

Download and build the base Ogre libraries

python python-ogre/BuildModule.py -r ois ogre cegui
python python-ogre/BuildModule.py -b ois ogre cegui

Again if there are problems the errors will be in log.out and you can try to build the modules individually and/or do seperate retrieve(-r) and build(-b) steps.

At this point you can run the Ogre C++ samples Note: We have to set the LD_LIBRARY_PATH because we have our libraries in a 'non-system' location.

export LD_LIBRARY_PATH=~/development/root/usr/lib/
cd ~/development/ogre/Samples/Common/bin

Change the plugins.cfg to look something like:

# Defines plugins to load
 
# Define plugin folder
# CHANGE THIS TO YOUR PATH
PluginFolder=/home/andy/development/root/usr/lib/OGRE
 
# Define D3D rendering implementation plugin
Plugin=RenderSystem_GL.so
Plugin=Plugin_ParticleFX.so
Plugin=Plugin_BSPSceneManager.so
Plugin=Plugin_OctreeSceneManager.so
Plugin=Plugin_CgProgramManager.so

The run the demos

./Smoke

Step 5

Generate the wrapper code(-g), compile(-c) and install it - Ensure ogre is generated before any other module !

cd ~/development
python python-ogre/BuildModule.py -g -c ogre ois cegui
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.


export LD_LIBRARY_PATH=~/development/root/usr/lib/
export PYTHONPATH="/home/$USER/development/root/usr/lib/python2.5/site-packages:"
cd ./python-ogre/demos/ogre
python Demo_Grass.py

Config Notes

In this build procedure we use a slightly non-typical location for our libraries, the reason behind this is to ensure we don't overwrite any existing libraries (and it's generally good practice)

This does mean we need to tell Linux where to look for the libraries and the Python Modules. In the demos we fix the python path by doing this:

import sys
sys.path.insert(0,'..')
import PythonOgreConfig

Have a look at ./demos/PythonOgreConfig.py to see how this is managed. However we still need to set the Library path so we can find the shared libraries like this:

export LD_LIBRARY_PATH=~/development/root/usr/lib/
export PYTHONPATH=~/development/root/usr/lib/pythonXXX/site-packages

or to make the library path more sticky (otherwise you have to set it every time you open a terminal window)

sudo ldconfig ~/development/root/usr/lib/

Building 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 bullet

2. Build the underlying C libraries

cd ~/development
python python-ogre/BuildModule.py -b ode ogreode newton ogrenewt ogreal bullet

3. Generate the wrapper code

cd ~/development
python python-ogre/BuildModule.py -g ode ogreode newton ogrenewt ogreal bullet

4. Compile the wrapper code to make the python module

cd ~/development
python python-ogre/BuildModule.py -c ode ogreode newton ogrenewt ogreal bullet

5. And install the modules:

cd ~/development
python python-ogre/BuildModule.py -b install

Available modules

ModuleList

It Didn't Work -- What Now?

Gentoo ebuilds

WARNING: These ebuilds change your system libraries and currently only cover the wrappers for ogre, ois, and newton.

Ebuilds for a portage overlay: http://www.ofai.at/~stefan.rank/repos/python-ogre-portage-overlay.zip ( darcs repo: http://www.ofai.at/~stefan.rank/repos/python-ogre-portage-overlay/ ). For more information, see the txt file in the repo. The ebuilds in the overlay are: (suffix -9999 means source directly from version control and _p99 indicates patched packages)

dev-games/python-ogre-9999 (svn) (builds the ogre and ois modules)
- dev-games/ogre-1.4.7_p99 (gentoo version + freeimage support + python-ogre specific patch)
  USE="cegui cg freeimage -devil -gtk -threads"
  (automatic dependencies: cegui, cg, freeimage, zzlib, ois)
- dev-python/py++-9999 (svn)
  - dev-python/pygccxml-9999 (svn)
    - dev-cpp/gccxml-9999 (cvs)
  - dev-libs/boost-1.34.1_p99 (gentoo version + patch, bjam (boost-build) is automatically used)
dev-games/python-ogre-ogrenewt-9999 (svn)
- dev-games/python-ogre-9999 (svn)
- dev-games/ogrenewt-9999 (cvs ogreaddons + patches)
  - dev-games/newton-1.53_p99 (gentoo version + python-ogre specific patch)

Be warned that compilation, especially of python-ogre, takes a long time (the numbers are from an arguably old Athlon <1GHz):

# qlop -t python-ogre python-ogre-ogrenewt ogre py++ pygccxml gccxml ogrenewt newton boost
python-ogre: 7 hours, 53 minutes, 48 seconds for 7 merges
python-ogre-ogrenewt: 35 minutes, 13 seconds for 1 merges
ogre: 1 hour, 41 minutes, 19 seconds for 7 merges
py++: 3 minutes, 52 seconds for 3 merges
pygccxml: 2 minutes, 6 seconds for 3 merges
gccxml: 42 minutes, 36 seconds for 3 merges
ogrenewt: 5 minutes, 1 second for 4 merges
newton: 48 seconds for 2 merges
boost: 1 hour, 36 minutes, 18 seconds for 5 merges

Debian and cegui

If you get an error when building cegui (CEGUIXercesParser.cpp:233: error: incomplete type ‘xercesc_2_8::Grammar’ ) on Debian testing/unstable, adding the following line to CEGUI-0.5.0/XMLParserModules/XercesParser/CEGUIXercesParser.h (line 54) should help:

#include <xercesc/validators/schema/SchemaGrammar.hpp>

Boost / Boost Jam

If Boost isn't being built, this might be due to a faulty version of bjam on your system. In that case try the following:

cd boost_1_34_1
./configure --with-libraries=python --prefix=~/development/root/usr --without-icu  --with-bjam=../root/usr/bin/bjam
make && make install

In the current build-script bjam is being built (and placed into root/usr/bin) but not used for the compilation of boost.

Stackless Python

If you are using Stackless python and SCons throws an exception while building stating "setting stack size not supported' you need to modify SCons job.py. Locate the __init__ in the class ThreadPool and comment out the lines where threading.stack_size() is used to explicitly set the stack size

job.py
 #try:
 #     prev_size = threading.stack_size(stack_size*1024) 
 #except AttributeError, e:
 #threading.stack_size(prev_size)
Personal tools