#summary How to set up required source modules to compile FoFiX
#labels Featured,Phase-Deployment
<wiki:toc max_depth="2" />
=== `**` If you haven't read [http://www.fretsonfire.net/forums/viewtopic.php?f=32&t=37631 this page] yet in its entirety, please be sure to do so before you continue! `**` ===

----

= These instructions are deprecated! =

Support for running FoFiX under Python 2.4 with PyOpenGL 2.x is being phased out.  There are only a few issues remaining before 2.4/gl2 support will be dropped for good.  If you still want to run a *deprecated* 2.4/gl2 setup, use the instructions below, but bear in mind that *support can be removed at any time, at which time you will need to reconstruct your entire environment using Python 2.6 and PyOpenGL 3.x.*

== What should I use instead? ==

The current up-to-date setup consists of Python 2.6 and PyOpenGL 3.x.  Instructions can be found on the RunningUnderPython26 page.

----
----

=Checking out the latest code anonymously=
(requires a Subversion client, such as [http://tortoisesvn.net/ TortoiseSVN], to check out and receive easy updates of the latest FoFiX source code)

_(Note - it is recommended that you download the latest "full" release of FoFiX for your operating system, extract it where you want, and test it first.  This folder now has all the required dependencies for you to rebuild and recompile the source into FretsOnFire.exe and library.zip -- this should also be the folder you perform the "SVN Checkout" and "SVN Update" on!)_

*More detailed instructions can be found [http://www.fretsonfire.net/forums/viewtopic.php?f=11&t=30709&p=315847#p315846 here] if this Wiki does not make sense.*

[http://www.fretsonfire.net/forums/viewtopic.php?f=11&t=30709&p=315847#p315846 http://i374.photobucket.com/albums/oo189/ze_raph/svn-win.png]

Perform an "SVN Checkout" on the following URL to a local folder of your choosing: 
{{{http://fofix.googlecode.com/svn/MFH-Mod/trunk/}}}

Then, to check for and update to the very latest FoFiX source code from svn, perform an "SVN Update" on the folder where you checked out the source files.  

=Setting Up FoFiX Sources=
  * [http://code.google.com/p/fofix/wiki/RequiredSourceModules#For_GNU/Linux GNU/Linux]
  * [http://code.google.com/p/fofix/wiki/RequiredSourceModules#For_Windows Windows]
  * [http://code.google.com/p/fofix/wiki/RequiredSourceModules#For_MacOS_X MacOS X]

----

_It is highly recommended that when you become an svn tester, you keep a separate FoFiX folder containing a full install of the latest stable release - as svn's new features and bugfixes might cause other issues affecting playability._

_Alternatively, be familiar with your svn clients method of rolling back to previous revisions so you can downgrade to a working revision if the latest one breaks on you._


==For Windows==

===Download===

Versions are likely important. Don't substitute one for the other without trying the original versions first. These versions were tested, yours were not. I will not answer questions unless you have done the things in this document.

*Note:* FoFiX is now working on moving up to Python 2.6 under Windows, though until the move is completed, FoFiX will still fully support Python 2.4.  These instructions use Python 2.4.  See RunningUnderPython26 for detailed instructions for setting up Python 2.6 to run FoFiX.

  # Download Python 2.4.4 - [http://www.python.org/ftp/python/2.4.4/python-2.4.4.msi]
  # Download pyWin32 build 214 - [http://downloads.sourceforge.net/pywin32/pywin32-214.win32-py2.4.exe]
  # Download PyOpenGL 2.0.2.01 - [http://downloads.sourceforge.net/pyopengl/PyOpenGL-2.0.2.01.py2.4-numpy23.exe]
  # Download PyGame 1.9.1 - [http://pygame.org/ftp/pygame-1.9.1release.win32-py2.4.exe]
  # Download PIL 1.1.6 - [http://effbot.org/downloads/PIL-1.1.6.win32-py2.4.exe]
  # Download Numeric 2.4.2 - [http://downloads.sourceforge.net/numpy/Numeric-24.2.win32-py2.4.exe]
  # Download Numpy 1.2.1 - [http://downloads.sourceforge.net/numpy/numpy-1.2.1-win32-superpack-python2.4.exe?use_mirror=superb-east]
  # Download PyOgg 1.3 (this url is important, other versions dont work) - [http://www.mediafire.com/file/tzjhetkzkyl/pyogg-1.3.win32-py2.4.exe]
  # Download PyVorbis 1.4 (this URL is important, other versions don't work) - [http://www.mediafire.com/file/jnx4jenjzmi/pyvorbis-1.4.win32-py2.4.exe]
  # Download PySQLite 2.5.5 - [http://oss.itsystementwicklung.de/download/pysqlite/2.5/2.5.5/pysqlite-2.5.5.win32-py2.4.exe]
  # Download the FoFiX source files from the trunk, or SVN revision / tag of your choice - [http://code.google.com/p/fofix/source/browse/MFH-Mod]

*Additional, optional modules currently in use with the latest svn revision:*
  * py2exe: support for freezing the code into a standalone EXE (0.6.9: [http://downloads.sourceforge.net/py2exe/py2exe-0.6.9.win32-py2.4.exe])
  * [http://psyco.sourceforge.net/ Psyco] - just-in-time compiler for Python ([http://downloads.sourceforge.net/psyco/psyco-1.5.2.win32-py2.4.exe Direct download])
  * [http://trac2.assembla.com/pkaudio/wiki/pyrtmidi pyRtMidi] - for MIDI instruments to be used as controller inputs.  [http://www.mediafire.com/download.php?ok1vw2zjn22 Here] is a direct download link to an installer that js put together for Python 2.4.
  * [http://www.mediafire.com/stump jsPitchBend] - for a whammy pitchbend effect (source: [https://svn.stump.jstump.com/svnroot/pitchbend/trunk SVN Checkout], [https://svn.stump.jstump.com/websvn WebSVN]).  At least revision 7 or release 0.1 is needed for the effect to work.  ([http://www.mediafire.com/?3mgtxhagijt direct download of latest release])
  * [http://sourceforge.net/project/downloading.php?group_id=5988&filename=PyOpenGL-3.0.0.win32.exe&a=75398406 PyOpenGL 3.0] - for experimental shader code.  Install *instead of* the pyOpenGL 2.0.2.01 package from the required list.  ([http://prdownloads.sourceforge.net/pyopengl/PyOpenGL-3.0.0.win32.exe?download])
    * *NO LONGER REQUIRED to use shaders - they now work under PyOpenGL 2.x, as long as you have ctypes!*
  * ctypes - required if you install pyOpenGL 3.0 or want shaders under pyOpenGL 2.x  ([http://prdownloads.sourceforge.net/ctypes/ctypes-1.0.2.win32-py2.4.exe?download])
  * pyAudio - required for microphone support: [http://people.csail.mit.edu/hubert/pyaudio/#binaries Download choices] / [http://people.csail.mit.edu/hubert/pyaudio/packages/pyaudio-0.2.3.py24.exe Direct download for Python 2.4]
  * pyPitch - optional alternative to the pitch analysis engine built into FoFiX: [http://www.mediafire.com/file/j5mmkd212mi/pypitch-svn_rev9.win32-py2.4.exe Direct download of r9 for Python 2.4]
    * *At least r9 is REQUIRED or you will get crashes when you try to play using pypitch!*  (You can choose between pypitch and the built-in analyzer in Debug Settings.)


Here's a *package containing all dependencys* (as of 2009-09-21): [http://www.mediafire.com/download.php?e2inzrizjl3]

*Or, here's a complete installer package* with all the files above (as of 5/8/2009), courtesy of Chris Paiano:
[http://www.mediafire.com/?zzizzt4zmuw MFH's SVN Module Installer for 3.120r1454+ Win32-Py24-OGL2]
This Includes the all optional modules for 3.120 r1454+.  _Uses versions: Python 2.4, PyOpenGL 2_.  Installer also fixes the below OpenGL 2 version error.


===Install In This Order===

  # Install Python by double clicking the .msi
  # Install pyWin32 by double clicking the .exe
  # Install PyOpenGL by double clicking the .exe
  # Install PyGame by double clicking the .exe
  # Install PIL by double clicking the .exe
  # Install Numeric by double clicking the .exe
  # Install Numpy by double clicking the .exe
  # Install PyOgg by double clicking the .exe
  # Install PyVorbis by double clicking the .exe
  # Install PySQLite by double clicking the .exe
  # Install any optional modules by double clicking the .exe files in the order that you downloaded them.

_This next part fixes a opengl/py2exe bug so it may not be necessary in the future. Only if you get an error when running the FretsOnFire.exe that says:_

{{{
IOError: [Errno 2] No such file or directory: 'D:\\Games\\Frets on Fire\\dist\\data\\library.zip\\OpenGL\\version'
}}}
  # Go to your Python directory and go into the `Lib` and then `site-packages` directory
  # Go into the `OpenGL` directory and edit the file called `__init__.py`
  # Replace the line that reads:
    `__version__ = string.strip(open(filename).read())` *with*
    `__version__ = '2.0.2.01'`
  # Save this file
  # Delete `__init__.pyc` and `__init__.pyo` in the same directory

Back to what we were initially trying:
  # Locate the downloaded or checked-out FoFiX sources
  # Move the {{{src}}} directory into your FoFiX directory (same place as the {{{data}}} directory) if it is not already located there. *NOT _inside_ the {{{data}}} directory!!*
  # *ONLY for FoFiX 3.025 or earlier* -- *REBOOT* _(required)_
  # Open a command prompt
  # cd to the new {{{src}}} directory in your FoFiX directory
  # type {{{python FoFiX.py}}} (or run the {{{src\scripts\RunFofFromSources.bat}}} script)

At this point you should be able to play frets on fire directly from the source.

*New Method of Rebuilding The Executable*
Assuming you have TortoiseSVN installed in {{{C:\Program Files\TortoiseSVN\}}}, and assuming you have your Python 2.4's path included in the environment PATH variable, you should be able to use the following one-step Auto SVN Update / Rebuild / Play script:
{{{src\scripts\Win_Alpha_UpdateRebuildPlay.bat}}}

Note that you might not see any errors using this method; if things aren't working correctly, or if the game is not starting, try the below old method.

*Old Method of Rebuilding The Executable*
To create the executable we need a few more steps:
  # Go to your {{{src\scripts}}} directory where you have your SVN directory setup (IE- {{{C:\FoFiX SVN\src\scripts}}})
  # Double-click on the {{{RebuildWin.bat}}} script.  This will recompile and rebuild the game {{{.EXE}}} file, {{{library.zip}}}, and required Python support modules ({{{.PYD}}} files).  This script will also retrieve these files and replace the old files in your FoFiX and data folders, as well as copy over any {{{.DLL}}} files that the build process decided to include.  Then the intermediate files (in {{{src\build}}} and {{{dist\}}}) will automatically be cleaned up.
  # You may need the Windows support files for FoFiX (mostly {{{.DLL}}}s), which can be found inside any full Windows FoFiX distribution in the appropriate directory structure.

----
==For GNU/Linux==
Please see the dedicated [RunningUnderGNULinux running under GNU/Linux page] for instructions on getting and running FoFiX.

=== Creating binaries ===
*Unless you want to distribute binaries of FoFiX this is really _not_ required. Furthermore this section is depricated.*

You first need to...
  # Install cxFreeze 3.0.3
  # Modify FoFiX's Makefile to make CXFREEZE point on your cxFreeze binary.
    * You may force python and pyopengl versions if you want, by default they're autodetected.
  # Substitue line 16 of `/usr/lib/python2.4/site-packages/OpenGL/__init__.py` with `__version__ = "2.0.1.09"`.
  # Get the wiki pages by executing the following in the folder that contains `FoFiX-SVN`:
    * `svn checkout http://fofix.googlecode.com/svn/wiki FoFiX-wiki`

Then either create a patch or a full package.

==== Patch ====
  * Execute {{{make clean patch}}}.
==== Full package ====
  * Execute {{{make clean bindist}}}.

----
==For MacOS X==
=== Get latest FoFiX ===
  # Install [http://www.macports.org/ macports]
  # Open a terminal (Terminal.app)
  # Change to the directory in which you want to have FoFiX
  # Execute {{{svn checkout http://fofix.googlecode.com/svn/MFH-Mod/trunk/ FoFiX-SVN}}}
=== Install dependencies ===
You need to install these packages using macports (In a terminal, type {{{sudo port install [package]}}}, where `[package]` is the name of the required package to be installed):
  * python25
  * py25-game
  * py25-numpy
  * py25-numeric
  * py25-pil
  * py25-pysqlite3
  * glew¹
You need the following packages which are not available on macports:
  * opengl 2.x²
  * pyogg
  * pyvorbis
Download the files from [http://www.mediafire.com/?jzk2ywoznwt], unzip, and place files in `/opt/local/lib/python2.5/site-packages`.



Notes:
  * ¹ Probably optional, but it is still required if you are building the py2app package.  Copy `/opt/local/lib/libGLEW.1.5.1.dylib` as `libGLEW.dylib` in a `glew/lib` directory next to your FoFiX-SVN directory (i.e., copy it to `../glew/lib/libGLEW.dylib`).  
  * ² py25-opengl works okay but 2.x is still faster.

=== Running from sources ===
  # Change directory to {{{FoFiX-SVN/src}}}
  # Execute {{{python2.5 FoFiX.py}}}

_(Note: Prior to r1450, 'FoFiX.py' was known as 'FretsOnFire.py')_

=== Creating binaries ===
*Unless you want to distribute binaries of FoFiX this is really _not_ required.*

You first need to...
  # Install py25-py2app-devel using macports
  # Change directory to `FoFiX-SVN/src`
  # Execute {{{python2.5 setup_mac.py py2app}}}.

=== Optional PitchBending ===
==== Requirements ====
John Stumpo's pitchbend module is available here: [http://www.mediafire.com/?z2ewnzwntu2]
Be careful when copying these files into your site-packages directory.  If you paste the pygame directory in, it will overwrite everything in your current pygame directory.  Copy the files individually from the zip file into the appropriate locations in your site-packages directory.

_Clarifications to the MacOS X instructions may still need to be made as users go through these steps.  I (trinidude4) cannot go through the entire process of setting up the build environment since I went through a slightly more complicated procedure to make my current universal build environment._
----