python-rtmidi/install

Last modified 6 years ago Last modified on 11/10/2013 05:32:13 AM

Installation

python-rtmidi uses the de-facto standard Python distutils and setuptools based installation mechanism. Since it is a Python C(++)-extension a C++ compiler and build environment as well as some system-dependant libraries are needed. See "Requirements" below for details.

Installer (Windows only)

An installer with a pre-compiled version for Windows with Windows MultiMedia API support is available through PyPI for some Python versions. Download it from python-rtmidi's PyPI page and start the installer by double-clicking.

From PyPI

If you have all the dependencies, you should be able to install the package with pip or easy_install (from setuptools):

$ pip install --pre python-rtmidi

or, if you prefer easy_install:

$ easy_install python-rtmidi

This will download the source distribution, compile the extension and install it in your active Python installation. Unless you want to change the Cython source file _rtmidi.pyx, there is no need to have Cython installed.

Note

Starting with pip version 1.4, the installer requires the --pre option for installing pre-release versions of packages. Since development of python-rtmidi is still in beta-stage and the version numbers of its releases reflect this, the --pre option is necessary for now.

python-rtmidi also works well with virtualenv and virtualenvwrapper. If you have both installed, creating an isolated environment for testing and using python-rtmidi is as easy as:

$ mkvirtualenv rtmidi
(rtmidi)$ pip install --pre python-rtmidi

From the Source Distribution

Of course, you can also download the source distribution package as a Zip archive or tarball, extract it and install using the common distutils commands, e.g.:

$ wget http://chrisarndt.de/projects/python-rtmidi/download/python-rtmidi-0.4.3b1.tar.gz
$ tar -xzf python-rtmidi-0.4.3b1.tar.gz
$ cd python-rtmidi-0.4.3b1
$ python setup.py install

If you do not have setuptools installed yet, the last command should download it for you into the source directory and use it directly.

From Subversion

Lastly, you can check out the python-rtmidi source code from the Subversion repository and then install it from your working copy. Since the repository does not include the C++ module source code pre-compiled from the Cython source, you'll also need to install Cython >= 0.17, either via pip or from its Git repository. Using virtualenv/virtualenvwrapper is strongly recommended in this scenario:

Make a virtual environment:

$ mkvirtualenv rtmidi
(rtmidi)$ cdvirtualenv

Install Cython from PyPI:

(rtmidi)$ pip install Cython

or the Git repository:

(rtmidi)$ git clone https://github.com/cython/cython.git
(rtmidi)$ cd cython
(rtmidi)$ python setup.py install
(rtmidi)$ cd ..

Install python-rtmidi:

(rtmidi)$ svn co svn://svn.chrisarndt.de/projects/python-rtmidi/trunk python-rtmidi
(rtmidi)$ cd python-rtmidi
(rtmidi)$ python setup.py install

Requirements

Naturally, you'll need a C++ compiler and a build environment. See the platform-specific hints below.

Only if you want to change the Cython source file _rtmidi.pyx or want to recompile _rtmidi.cpp with a newer Cython version, you'll need to install Cython >= 0.17. The _rtmidi.cpp file in the current source distribution (version 0.4.3b1) is tagged with:

/* Generated by Cython 0.19.2 on Thu Nov  7 18:09:16 2013 */

RtMidi (and therefore python-rtmidi) supports several low-level MIDI libraries on different operating systems. Only one of the available options needs to be present on the target system, but support for more than one can be compiled in. The setup script will try to detect available libraries and should use the appropriate compilations flags automatically.

  • Linux: ALSA, JACK
  • OS X: CoreMIDI, JACK
  • Windows: MultiMedia (MM), Windows Kernel Streaming

The osc2midi example, which is installed alongside python-rtmidi additionally requires the pyliblo and PyYAML libraries. These additional dependencies are only installed by the setup.py script, if you specify the extra osc2midi, e.g.:

$ pip install "python-rtmidi[osc2midi]"

Linux

For the C++ compiler and the pthread library install the build-essential package on debian-based systems.

Then you'll need Python development headers and libraries. On Linux, install the python-dev package. If you use the official installers from python.org you should already have these.

To get ALSA support, you must install development files for the libasound library (debian package: libasound-dev). For JACK support, install the libjack development files (libjack-dev or libjack-jackd2-dev).

OS X

Install the latest Xcode or g++ from MacPorts or homebrew (untested). CoreMIDI support comes with installing Xcode. For JACK support, install JACK for OS X with the full installer.

Note

If you have a version of OS X and Xcode which still supports building binaries for PPC, you'll have to tell distribute to build the package only for i386 and x86_64 architectures:

env ARCHFLAGS="-arch i386 -arch x86_64" python setup.py install

Windows

On Windows you'll need Visual Studio 2008 (Express) to build python-rtmidi for Python <= 3.2 or Visual Studio 2010 (Express) for Python 3.3 if you use the official Python binary distributions for Windows.

Please see the detailed instructions for Windows.