                          Building on a mac
                          =================

Standalone PsychoPy is currently built using Framework Python 2.6.6 (not system python or enthought distributions). The following deals with how to set up a complete working python using that distribution under Snow Leopard (10.6). To get PsychoPy working on other python installations see the additional headers below that.


Framework Version
~~~~~~~~~~~~~~~~~~

binary installs
=================

Download double-click installers for these:
 - pygame
 - numpy
 - scipy
 - matplotlib
 - wxpython

easy_installs
===============

Install setuptools by downloading http://peak.telecommunity.com/dist/ez_setup.py
and running it with:: 
  sudo python ez_setup.py

Then::
  sudo easy_install -Z -U setuptools
  sudo easy_install -Z -U pyglet
  sudo easy_install -Z pyopengl
  sudo easy_install -Z pyobjc-core
  sudo easy_install -Z pyobjc
  sudo easy_install -Z pyobjc-framework-qtkit
  sudo easy_install -Z py2app
  sudo easy_install -Z bdist_mpkg
  STATIC_DEPS=true easy_install -Z lxml
  #optional extras for hardware
  sudo easy_install -Z pyserial
  sudo easy_install -Z parallel
  sudo easy_install -Z openpyxl
  sudo easy_install -Z ioLabs
  sudo easy_install -Z pyxid
  #optional, mostly for dev purposes
  sudo easy_install -Z ipython
  sudo easy_install -Z sphinx
  sudo easy_install -Z nose
  sudo easy_install cython

If you get build errors trying to easy_install::

  cc1: error: unrecognized command line option "-Wno-long-double"

edit the file lib/python2.5/config/Makefile and remove that
flag from the BASECFLAGS. Also in this file set::

  MACOSX_DEPLOYMENT_TARGET=10.5 and CC=gcc-4.0 ?

manual installs
===================
Install avbin for movies
labjack (you might prefer to use my fork of that at https://github.com/peircej/LabJackPython so that each file installs under site-packages/labjack)


compiled libs
==================

#hdf5 (needed for pytables or you get errors about symbols not found)
cd hdf5-1.8.9
CFLAGS='-arch i386' LDFLAGS='-arch i386' ./configure --prefix=/usr/local/ make
sudo make install

#ioHub also requires
# greenlet, gevent, msgpack-python, pyYAML


System python
~~~~~~~~~~~~~~
The following cannot be installed to 64bit python because they use carbon:
- wxpython (cocoa support expected in version 3.0)
- pyglet (cocoa support half-built last JWP looked)
- pygame/SDL

BUT, change to use 32bit python2.6 or 2.5 by adding the following to
bash_profile:

  export VERSIONER_PYTHON_VERSION=2.6
  export VERSIONER_PYTHON_PREFER_32_BIT=yes

Python should show compiled on GCC4.2 (sys python) and sys.maxint
should be 2147483647 (32bit)

Install these to Framework python (from python.org) and then copy over
=================================================================
- numpy (downloaded from SF)
- scipy (downloaded from SF)


ENTHOUGHT VERSION
~~~~~~~~~~~~~~~~~~
- install EPD version 6.1
- install avbin
- install pygame (see below)

easy_install
=============

  sudo easy_install -Z bdist_mpkg
  sudo easy_install -Z py2app
  sudo easy_install -Z pyobjc
  sudo easy_install -Z pyobjc
  sudo easy_install -Z pyobjc-framework-qtkit

Note:  This approach has worked well to created the manual version but
the standalone app doesn't run on other machines It complains about
numpy/lapack not loading correct object

Problems with installing
~~~~~~~~~~~~~~~~~~~~~~~~~

installing pygame
==================
I downloaded the version for pygame-1.9.1release-py2.6-macosx10.5.
This complains that it can't install on this system. Open the
installed bundle and from Contents/Packages install each of dependent
frameworks:

- pygame-SDL
- pygame-SDL_ttf
- pygame-SDL_mixer
- pygame-SDL_iamge
- pygame-headers
- pygame-smpeg

Then open the contents of bundle

- pygame-platlib

and drag the pygame and egg.info folders to your site packages.

This worked for me on a clean-install (no rosetta) 10.6 using the
EPD6.1


If easy_install is not downloading things check
================================================
1. that your http_proxy is set in .bash_profile
2. that sudo allows http_proxy to be used:  type visudo to open the
   sudo settings editor add the line (with same formatting as others):
   Defaults env_keep += “ftp_proxy http_proxy https_proxy”

Problems building the app
==========================

DistutilsFileError: /Library/Frameworks/Python.framework/Versions
------------------------------------------------------------------
This is caused by py2ap trying to find python2.5/pyconfig.h which may not exist.
Hack: add the following to the begin of py2app/util.py copy_file (around line 100):

  if path=="/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5/pyconfig.h":
     path="/Library/Frameworks/Python.framework/Versions/6.1/include/python2.6/pyconfig.h"

You may also get messages about not being able to locate pyconfig.h
during copy_file caused by the fact that py2app thinks that enthought
python(6.1) should be installed

TypeError: 'NoneType' object is unsubscriptable (in modulegraph.find_needed_modules)
-------------------------------------------------------------------------------------
This indicates that one of your required modules couldn't be
found. Check your easy_install.pth to make sure that all the required
modules have their paths there.

To make avbin work from the mac standalone:
--------------------------------------------
In pyglet/lib.py, around line 166, do this:

      search_path.append(os.path.join(sys.prefix, '..', 'Frameworks'))

instead (or as well as) of


      search_path.append(os.path.join(
                         os.environ['RESOURCEPATH'],
                         '..',
                         'Frameworks',
                         libname))

To build a 32-bit ffmpeg dylib
--------------------------------
For each codec, download the source and do:
	CFLAGS='-arch i386' LDFLAGS='-arch i386' configure --disable-static --enable-shared
	make
	sudo make install
Then for ffmpeg source do:
	configure --disable-static --enable-shared --disable-outdev=sdl --enable-runtime-cpudetect --disable-indev=jack --enable-zlib  --enable-libx264 --enable-libxvid --enable-libvorbis --cc="clang -m32" --enable-gpl
	make
	sudo make install
