Building PySide on a Mac OS X System¶
Mac OS X is a Unix flavor, partially based upon BSD Unix.
The supported Mac OS X versions created by Apple are
- OS X 10.6 Snow Leopard
- OS X 10.7 Lion
- OS X 10.8 Mountain Lion
- OS X 10.9 Mavericks
- OS X 10.10 Yosemite
Mac OS X is a proprietary UNIX flavor of BSD Unix and only partially similar to Linux. Therefore, the usual packages from Linux distributions cannot be used without modifications.
There are several known package managers which provide support for Mac OS X, namely
The main purpose of all of these projects is to provide the missing Linux packages for Mac OS X.
Throughout this tutorial, we are only using Homebrew, because it appears to be the most light-weight package manager available. All installations are made to /usr/local/(bin|lib|include|shared) by simple symlinks.
But it should be easy to translate these instructions for the other, heavier package managers.
Install Package Manager:
$ ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
Follow the on-screen instructions to make adjustions, especially run
$ brew doctor
Also see the homebrew homepage for further information
Install Xcode (optional):
Follow the on-screen instructions. If you selected any extensions to be installed, wait for their completion before you proceed.
If you are using Mavericks, you can also use the Xcode Command Line Tools without actually installing Xcode (not tested, see this article: How to Install Command Line Tools in OS X Mavericks (Without Xcode)).
Install the Xcode command Line Tools:
After Xcode installation has finished, you can open a command shell and issue
$ xcode-select --install
This will open a dialog window with further instructions. After the command line tools are installed, you will not need to use Xcode again in order to set up PySide.
Install build dependencies:
$ brew install python cmake qt
Remark: This installs
HomebrewPython, which is fine for you as a single user. If you are considering to build installers for external users, see the section
About PySide Distributions.
pipdistribution into the Python you installed in the first step: download get-pip.py and run it using the
pythoninterpreter of your Python 2.7 installation using a command prompt:
$ wget https://bootstrap.pypa.io/get-pip.py $ sudo python2.7 get-pip.py
There are situations with older Python versions, where the above procedure does not work. You can then use this last-resort work-around (tested):
$ wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py $ sudo python2.7 ez_setup.py $ sudo easy_install pip $ sudo pip install setuptools -U $ sudo pip install wheel -U
$ sudo pip2.7 install wheel
About PySide Distribution¶
If you want to build PySide for your own use, the above instructions are ok.
But when you are considering to build PySide for other versions or other users, you need to be aware of the following caveat:
- Mac OS X has the concept of a
- The current deployment targets which work with PySide are 10.6 to 10.9 .
- All binary installers from https://www.python.org are built with the setting
$ export MACOSX_DEPLOYMENT_TARGET=10.6 # Snow Leopard
- The default setting for the deployment target of an extension (like PySide) is always inherited from the Python used for building. You can set the deployment target higher than that, but not below the OS X version that was set during building your Python installation.
- Current distributions like Homebrew set the deployment target to the same value as the OS version they are built with. (I.E. 10.9 for Mavericks).
- Example: A PySide, built on Mavericks, will therefore not run on a Python that was built for Mountain Lion.
- Use Homebrew’s simplicity for your own machine. Do not use it for distributing.
- Use one of the Python.org Distributions or
- Build your own Python, either from a tar archive (
Python 2.7 or
Python 3.4), or from a
Mercurial repository with an explicit setting of
Building PySide distribution¶
$ wget https://pypi.python.org/packages/source/P/PySide/PySide-1.2.4.tar.gz
Extract the source distribution:
$ tar -xvzf PySide-1.2.4.tar.gz
Switch to the distribution directory:
$ cd PySide-1.2.4
$ python2.7 setup.py bdist_wheel
Building PySide distribution from a Git repository¶
PySidesetup scripts from git repository:
$ git clone https://github.com/PySide/pyside-setup.git pyside-setup
Switch to the
$ cd pyside-setup
$ python2.7 setup.py bdist_wheel --version=1.2.4
To build the development version of
PySidedistribution, ignore the –version parameter:
$ python2.7 setup.py bdist_wheel
Installing PySide distribution¶
After the successful build, install the distribution with
$ sudo pip2.7 install dist/PySide-1.2.4-cp27-none-linux-x86_64.whl
Installing PySide distribution into
virtual Python environment¶
$ sudo pip2.7 virtualenv
virtualenvto make a workspace:
$ virtualenv-2.7 env
Activate the virtual Python in the
$ source env/bin/activate
Install the distribution with
(env) $ pip install ../dist/PySide-1.2.4-cp27-none-linux-x86_64.whl
Leave the virtual environment (optional):
(env) $ deactivate $