chiark / gitweb /
Finish updating README for Mac OS X.
[cura.git] / README.md
1 Cura
2 ====
3
4 If you are reading this, then you are looking at the *development* version of Cura. If you just want to use Cura look at the following location: https://github.com/daid/Cura/wiki
5
6 Development
7 ===========
8
9 Cura is developed in Python. Getting Cura up and running for development is not very difficult. If you copy the python and pypy from a release into your Cura development checkout then you can use Cura right away, just like you would with a release.
10 For development with git, check the help on github. Pull requests is the fastest way to get changes into Cura.
11
12
13 Packaging
14 ---------
15
16 Cura development comes with a script "package.sh", this script has been designed to run under unix like OSes (Linux, MacOS). Running it from sygwin is not a priority.
17 The "package.sh" script generates a final release package. You should not need it during development, unless you are changing the release process. If you want to distribute your own version of Cura, then the package.sh script will allow you to do that.
18
19
20 Mac OS X
21 --------
22 The following section describes how to prepare environment for developing and packaing for Mac OS X.
23
24 ###Python
25 You'll need non-system, framework-based, universal with min deployment target set to 10.6 build of Python 2.7
26
27 **non-system**: it was not bundeled with distribution of Mac OS X. You can check this by `python -c "import sys; print sys.prefix"`. Output should *not* start with *"/System/Library/Frameworks/Python.framework/"*
28
29 **framework-based**: Output of `python -c "import distutils.sysconfig as c; print(c.get_config_var('PYTHONFRAMEWORK'))"` should be non-empty string
30
31 **universal**: output of ``lipo -info `which python` `` include both i386 and x86_64. E.g *"Architectures in the fat file: /usr/local/bin/python are: i386 x86_64"*
32
33 **deployment target set to 10.6**: Output of ``otool -l `which python` `` should contain *"cmd LC_VERSION_MIN_MACOSX ... version 10.6"*
34
35 The easiest way to install it is via [Homebrew](http://mxcl.github.com/homebrew/): `brew install --fresh osx_python_cura.rb --universal` (TODO: upload the formula). Note you'll need to uninstall Python if you already have it installed via Homebrew.
36
37 ###Virtualenv
38 You may skip this step if you don't bother to use [virtualenv](http://pypi.python.org/pypi/virtualenv). It's not a requirement.
39
40 The main problem with virtualenv is that wxWidgets cannot be installed via pip. We'll have to build it manually from source by specifing prefix to our virtualenv.
41
42 Assuming you have virtualenv at *~/.virtualenvs/Cura*:
43
44 1. Download [wxPython sources](http://sourceforge.net/projects/wxpython/files/wxPython/2.9.4.0/wxPython-src-2.9.4.0.tar.bz2)
45 2. Configure project with the following flags: `./configure --prefix=$HOME/.virtualenvs/Cura/ --enable-optimise --with-libjpeg=builtin --with-libpng=builtin --with-libtiff=builtin --with-zlib=builtin --enable-monolithic --with-macosx-version-min=10.6 --disable-debug --enable-unicode --enable-std_string --enable-display --with-opengl --with-osx_cocoa --enable-dnd --enable-clipboard --enable-webkit --enable-svg --with-expat --enable-universal_binary=i386,x86_64`
46 3. `make install`
47 4. cd into the *wxPython* directory
48 5. Build wxPython modules: `python setup.py build_ext WXPORT=osx_cocoa WX_CONFIG=$HOME/.virtualenvs/Cura/bin/wx-config UNICODE=1 INSTALL_MULTIVERSION=0 BUILD_GLCANVAS=1 BUILD_GIZMOS=1 BUILD_STC=1` (Note that python is the python of your virtualenv)
49 6. Install wxPython and modules: `python setup.py install --prefix=$HOME/.virtualenvs/Cura/ WXPORT=osx_cocoa WX_CONFIG=$HOME/virtualenvs/Cura/bin/wx-config UNICODE=1 INSTALL_MULTIVERSION=0 BUILD_GLCANVAS=1 BUILD_GIZMOS=1 BUILD_STC=1` (Note that python is the python of your virtualenv)
50
51 Another problem is that python in virtualenv is not suitable for running GUI code. Mac OS X requires python to be inside the bundle. To workaround this issue, we will add the following script to the ~/.virtualenvs/Cura/bin:
52
53     #!/bin/bash
54     ENV=`python -c "import sys; print sys.prefix"`
55     PYTHON=`python -c "import sys; print sys.real_prefix"`/bin/python
56     export PYTHONHOME=$ENV
57     exec $PYTHON "$@"
58
59 I typically name this script `pythonw`.
60
61 At this point virtualenv is configured for wxPython development. Remember to use `python` to pacakge the app and `pythonw` to run app without packaging (e.g. for debugging).
62
63 ###Requirements
64 Following packages are required for development:
65
66     PyOpenGL>=3.0.2
67     numpy>=1.6.2
68     pyserial>=2.6
69     pyobjc>=2.5
70
71 Following packages are required for packaging Cura into app:
72
73     py2app>=0.7.2
74
75 The easiest way to install all this packages is to use virtualenv's pip: `pip install requirements_darwin.txt`
76
77 ####PyObjC
78 At time of writing, pyobjc 2.5 is not available at pypi. You have to clone repo and install it manually:
79
80     hg clone https://bitbucket.org/ronaldoussoren/pyobjc
81     hg checkout c42c98d6e941 # last tested commit
82     python install.py
83
84 ###Packaging
85 To package Cura into application bundle simply do `python setup.py py2app`. Resulting bundle is self-contained -- it includes Python and all needed packages.