19 de mayo de 2011

How to install NINJA-IDE in Mac OS X (Snow Leopard)

UPDATE: For Mac OS X Lion instructions, see here.

I wrote this for the Wiki of NINJA-IDE project to help people install it after making the port of NINJA to Mac.

How to install in Mac OS X (Snow Leopard)

Introduction

There are many ways to install the requirements for Ninja-IDE to run. Here my
aim will be to write a guide as straightforward as possible to get you runing
Ninja in a glimpse.
Then, I'll give a rough guide for more advanced or curious users than want to
perform their own installation their way(for instance, using a virtualenv).


Details

We'll need to install the following:
  • Mercurial (to checkout and keep track of Ninja repo in Google Code).
  • Brew (a.k.a. "HomeBrew", an awesome Mac OS X package installer that resembles apt-get a lot)
  • Qt
  • PyQt

Install Mercurial
  • Go to [http://mercurial.berkwood.com/ http://mercurial.berkwood.com/]
  • Download and install the latest version of the Mercurial binaries.

Install Brew

* With this command, you get Brew installed to /usr/local.
NOTE: DO NOT RUN THIS COMMAND AS ROOT OR USING SUDO, RUN IT AS A COMMON USER!!
$ ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
HomeBrew project site: http://github.com/mxcl/homebrew


Install XCode
  • You can get the latest version of XCode from Apple [http://developer.apple.com/technologies/xcode.html here]

Install sip, Qt and PyQt

  • From a console, run the following commands:
$ brew install sip
$ brew install qt
$ brew install pyqt
$ easy_install rope
$ easy_install pygments

Note: Brew downloads the source of the packages and compiles it and as some of the above listed programs are quite big, it is natural for the compilation to take A BUNCH of time.

Check installations:
To check the installation details for the packages you install using brew, run a command like this(in this example, for "pyqt" package):
MacBookPro:Cellar matias$ brew info pyqt
pyqt 4.8.3
http://www.riverbankcomputing.co.uk/software/pyqt
Depends on: sip, qt
/usr/local/Cellar/pyqt/4.7.7 (537 files, 19M)
/usr/local/Cellar/pyqt/4.8 (525 files, 19M)
This formula won't function until you amend your PYTHONPATH like so:
export PYTHONPATH=/usr/local/lib/python:$PYTHONPATH
http://github.com/mxcl/homebrew/commits/master/Library/Formula/pyqt.rb

Clone Ninja-IDE repository:
$ git clone https://github.com/ninja-ide/ninja-ide.git ninja-ide

Run Ninja
$ cd ninja-ide
$ python ninja.py

Note: If you get this error:

MacBookPro:ninja-ide matias$ python ninja.py
Traceback (most recent call last):
File "ninja.py", line 59, in
ninja_ide.setup_and_run() File "/Users/matias/Dev/ninja-ide/ninja_ide/__init__.py", line 40, in setup_and_run from ninja_ide import core, resources File "/Users/matias/Dev/ninja-ide/ninja_ide/core/__init__.py", line 4, in
from ninja_ide.core.core import run_ninja File "/Users/matias/Dev/ninja-ide/ninja_ide/core/core.py", line 6, in
from ninja_ide import gui File "/Users/matias/Dev/ninja-ide/ninja_ide/gui/__init__.py", line 1, in
import qt File "/Users/matias/Dev/ninja-ide/ninja_ide/gui/qt/__init__.py", line 1, in
from ide import IDE File "/Users/matias/Dev/ninja-ide/ninja_ide/gui/qt/ide.py", line 6, in
from PyQt4.QtGui import QMainWindow ImportError: No module named PyQt4.QtGui

add this line to your ~/.profile file to amend your PYTHONPATH:

export PYTHONPATH=/usr/local/lib/python:$PYTHONPATH

Done!

4 comentarios:

Anónimo dijo...

Your instructions for installing HomeBrew need to be modified because the present ruby URL does not work. The correct command is: ruby -e "$(curl -fsSL https://raw.github.com/gist/323731)" (from https://github.com/mxcl/homebrew/wiki/installation#wiki-fn3 ).

Matías dijo...

Updated! Thanks!

George dijo...

Homebrew code has changed.

ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"

Matías dijo...

Updated! Thanks! :)