Building from Source

Contents
========
    1. Linux
    2. Windows
    3. OS X

1. Linux
========
   1. Download and install the latest version of SWIG (preferably 1.3.31+) with 
      your package manager.

      If you are using Ubuntu, you can install it via Synaptic Package Manager
      (package name 'swig'). You will also need to install the python-dev 
      package, and build-essential (and python-pygame if you want to run the 
      testbed).

      sudo apt-get install build-essential python-dev swig python-pygame

   2. Check out the SVN

      svn checkout http://pybox2d.googlecode.com/svn/trunk/ pybox2d

   3. Build and install the pyBox2D library

      python setup.py build
      # Assuming everything goes well...
      sudo python setup.py install

      Note that if you receive some errors about -fPIC, adding -fPIC to your CXXFLAGS 
      might fix the problem. 

2. Windows
==========

   1. Install MinGW and then MSYS so that you can compile Box2D and pyBox2D.
   2. Install SWIG for making the Python wrapper. Install it in a location in 
      your PATH, or add the SWIG directory to your PATH.
   3. Create Python\Lib\distutils\distutils.cfg, if it doesn't exist, and add:

      [build]
      compiler=mingw32
      [build_ext]
      compiler=mingw32

   4. If you want to build from the SVN, install the Subversion client. Check 
      out the project by doing

      svn checkout http://pybox2d.googlecode.com/svn/trunk/ pybox2d

   5. Run MSYS and locate your pybox2d directory

      cd /c/path/to/pybox2d/

   6. Build and install pyBox2D

      setup.py build
      setup.py install

3. OS X
=======

Dependencies

To build pyBox2D, you will need:

    * Apple Developer Tools (see below)
    * SWIG (see below)
    * Python (of course) 

Install Apple Developer Tools

   1. This step is only required if the Apple Developer tools have not already
      been installed.
   2. Download the Apple Developer Tools or install them from the System 
      Installer CD provided with your Mac.
   3. Download from: http://developer.apple.com/tools/
   4. This will give your system all the tools it needs for software 
      development.
   5. These tools are required for you to proceed to the next step. 

SWIG Installation

   1. Download the latest source release of SWIG: 
      http://downloads.sourceforge.net/swig/swig-1.3.36.tar.gz
   2. Place the file onto your Desktop
   3. Open Terminal.app located in the Applications/Utilities folder
   4. Then enter the following into the terminal window:

      cd ~/Desktop
      tar -zxf swig-*.tar.gz
      cd swig-*
      ./configure
      make
      sudo make install
      <ENTER THE ADMINISTRATOR/ROOT PASSWORD IF PROMPTED>

   5. Hopefully all went well and no errors occurred.
   6. Close the Terminal.app window
   7. SWIG is now installed onto the system; we can now move to the next step. 

pyBox2D Installation

   1. Download the latest source distribution of pyBox2D: 
      http://pybox2d.googlecode.com/files/pyBox2D-2.0.2b0-Source.zip
   2. Place the file onto your Desktop
   3. Open Terminal.app located in the Applications/Utilities folder
   4. Then enter the following into the terminal window:

      cd ~/Desktop
      unzip pyBox2D-*-Source.zip
      cd pyBox2D-*-Source/
      python setup.py build

   5. If you get this error: ld: warning in Gen/float/libbox2d.a, file is not of 
      required architecture, run python setup.py build again.

      sudo python setup.py install
      <ENTER THE ADMINISTRATOR/ROOT PASSWORD IF PROMPTED>

   6. Hopefully all went well and no errors occurred.
   7. Close the Terminal.app window 

Test pyBox2D Installation (optional)

   1. NOTE: The pyBox2D testbed examples require pygame.
   2. Download pygame from: http://www.pygame.org/download.shtml
   3. For a simple gui installer download (as on pygame site): 
       http://rene.f0o.com/~rene/stuff/macosx/pygame-1.8.0rc5-py2.5-macosx10.4.mpkg.zip
   4. To test if the pyBox2D installation works we can see if the testbed examples included 
      in the distribution run

      cd ~/Desktop/pyBox2D-*-Source/Box2D/Python/testbed
      python demos.py

   5. At this stage take a look at the other examples provided. They are a good starting 
      point to get an idea of how pyBox2D works.
   6. For documentation / technical support to further your software development experience 
      see the links on the project home page. 

Building pyBox2D from the SVN

    This is only necessary if you want the latest features that pyBox2D has to offer.
    Follow the above headings Install Apple Developer Tools and SWIG Installation. Now follow
    steps 2 and beyond for Linux. 

