1. mercurial-users.jp
  2. Untitled project
  3. thg-ja


Clone wiki

thg-ja / developers / MacOSX

TortoiseHg on Mac OS X

Note: tortoisehg is now available in fink's unstable tree, as tortoisehg-py27 (or 25 or 26 if you are using an older python for some reason).

Note: A way via MacPorts is described at the end.

Note: Also if you already use Homebrew there are steps at the end. These steps have been confirmed to work with TortoiseHg 2.2.2. They also create an app for your Applications folder. Homebrew does not install Qt from source anymore, so this should be the fastest way.

Dependencies: PyQt and QScintilla

0. Install Apple Development Tools (Xcode)


1. Install Qt4 (Qt SDK for Mac)


Direct access via http://qt.nokia.com/downloads/qt-for-open-source-cpp-development-on-mac-os-x/

For Snow Leopard (10.6) users: python2.6 is now run on 64-bit environment by default. Please install 64-bit Qt binary, "Cocoa: Mac binary package for Mac OS X 10.5 - 10.6 (32-bit and 64-bit)".

Do not install Qt version 4.7.1 or 4.7.2. These versions generate crashes in some cases.

Note: Qt 4.7.0 does not crash but you will not be able to use keyboard shortcuts corresponding to contextual menu items. This version could be found on ftp://ftp.qt.nokia.com/qt/source/qt-mac-opensource-4.7.0.dmg with all other versions.

2. Install QScintilla (from source)


$ cd Qt4
$ qmake -spec macx-g++
$ make
$ sudo make install

installed files:

  • /usr/include/Qsci
  • /Developer/Applications/Qt/translations/qscintilla_*
  • /usr/local/Qt4.6/qsci
  • /Library/Frameworks/libqscintilla*

(Optionally) install Qt Designer plugin:

$ cd designer-Qt4
$ qmake -spec macx-g++
$ make
$ sudo make install

installed files:

  • /Developer/Applications/Qt/plugins/designer/libqscintillaplugin.dylib

3. Install Sip (from source)


$ python configure.py
$ make
$ sudo make install

For Snow Leopard (10.6) users: If you installed 32-bit Qt, append -n --arch i386 to configure.py. See http://old.nabble.com/PyQt4,-Qt-on-osx-SnowLeopard-td26394590.html

installed files:

  • /System/Library/Frameworks/Python.framework/Versions/2.6/bin/sip
  • /Library/Python/2.6/site-packages/sip.so
  • /System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/sip.h
  • /Library/Python/2.6/site-packages/sipconfig.py
  • /Library/Python/2.6/site-packages/sipdistutils.py

4. Install PyQt (from source)


$ python configure.py
$ make
$ sudo make install

installed files:

  • /Library/Python/2.6/site-packages/PyQt4
  • /System/Library/Frameworks/Python.framework/Versions/2.6/share/sip/PyQt4
  • /System/Library/Frameworks/Python.framework/Versions/2.6/bin/pyuic4
  • /System/Library/Frameworks/Python.framework/Versions/2.6/bin/pylupdate4
  • /System/Library/Frameworks/Python.framework/Versions/2.6/bin/pyrcc4
  • /usr/local/Qt4.6/qsci/api/python/PyQt4.api

You may need to add /System/Library/Frameworks/Python.framework/Versions/2.6/bin to PATH; or create symlink to them:

$ for name in pyuic4 pylupdate4 pyrcc4; do sudo ln -s ../../../System/Library/Frameworks/Python.framework/Versions/2.6/bin/$name; done

Also, PyQt4 will install versions of pyuic4 for both Python 2 and Python 3, and py2app will find the wrong version when both are present. To work around this problem, simply delete the /Library/Python/2.6/site-packages/PyQt4/uic/port_v3 directory. If you see an error in proxy_base.py when attempting to build, you most likely did not delete the port_v3 directory.

5. Install Python binding for QScintilla

$ cd Python
$ python configure.py
$ make
$ sudo make install

installed files:

  • /System/Library/Frameworks/Python.framework/Versions/2.6/share/sip/PyQt4/Qsci
  • /usr/local/Qt4.6/qsci/api/python/QScintilla2.api

6. Test installation

# Only for Snow Leopard (10.6) users who installed 32bit Qt:

$ python
Python 2.6.1 (r261:67515, Feb 11 2010, 00:51:29) 
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from PyQt4.QtGui import *
>>> app = QApplication([])
>>> w = QDialog()
>>> w.show()
>>> app.exec_()

Optional Dependencies

  • Install iniparse - allows thg to modify your configuration files
  • install pygments - enables auto-completion of source in commit tool

Get Latest Mercurial and TortoiseHg

$ hg clone http://selenic.com/repo/hg mercurial
$ hg clone http://bitbucket.org/tortoisehg/thg/
$ cd mercurial
$ make local

Add ~/Documents/mercurial to PYTHONPATH, or symlink to them:

$ ln -s ../mercurial/mercurial
$ ln -s ../mercurial/hgext

Run it:

# Only for Snow Leopard (10.6) users who installed 32bit Qt:

$ thg log

Happy Hacking!

Alternative: Install via MacPorts

Warning: Installing TortoiseHg this way usually takes a couple of hours because Qt is compiled from its sources.

  • Install XCode (Version 3.x is free and works)
  • Install Python and PyQt from ports:
$ sudo port install python27 python_select
# Make this the default version
# Old version: $ sudo python_select python27
# New version:
$ sudo port select python python27

$ sudo port install py27-pyqt4 py27-qscintilla
  • Set " /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin" to your Path (edit /.bash_profile)
  • Install pip (if not present)
$ curl -O http://python-distribute.org/distribute_setup.py
$ sudo python distribute_setup.py
$ sudo easy_install pip
  • Install the easy_installable thg fork
$ sudo pip install thg-mac

Alternative: Install via Homebrew

Note: Qt now comes pre-compiled with homebrew. So installing TortoiseHg is much faster than it used to be.

  • Add Homebrew's paths to $PATH and $PYTHONPATH:
# Edit ~/.bash_profile or ~/.bashrc
# Add these lines (or adjust them)
BREW_PREFIX=`brew --prefix`
export PATH=$BREW_PREFIX/share/python:$BREW_PREFIX/bin/:$BREW_PREFIX/sbin:$PATH
export PYTHONPATH=$BREW_PREFIX/lib/python2.7/site-packages:$PYTHONPATH
  • Install PyQt via homebrew (this also installs qt and sip):
$ brew install pyqt
  • Install QScintilla via homebrew.
$ brew install qscintilla2

If there is an error about missing git repository, try to update Homebrew first:

$ brew update
  • Install required Python packages:
$ easy_install pip
$ pip install Pygments iniparse Mercurial
  • Checkout TortoiseHg (using Mercurial):
$ hg clone http://bitbucket.org/tortoisehg/thg/ ~/Documents/TortoiseHg
$ cd ~/Documents/TortoiseHg
$ hg update stable  # or hg update <version-number>

Now you should be able to start TortoiseHg:

$ ./thg log

The final step is to "create" a "wrapper app bundle" for your Mac OS X applications folder. Simply checkout this repository and copy the app bundle it contains to your Applications folder.

Note: If you've checked out TortoiseHg to /Documents/TortoiseHg, this app should work out of the box. Otherwise you need to read the readme file included in the repository.