11# Installation
22
33** python-rtmidi** uses a modern [ PEP 517] compliant Python build system based
4- on [ meson] and [ mesonpep517 ] and can be installed from the Python Package Index
4+ on [ meson] and [ meson-python ] and can be installed from the Python Package Index
55via [ pip] . Since it is a Python C(++)-extension, a C++ compiler and build
66environment as well as some system-dependent libraries are needed to install,
77unless wheel packages with pre-compiled binaries are available for your system.
@@ -40,88 +40,96 @@ below for moe information.
4040
4141## Pre-compiled Binaries
4242
43- Pre-compiled binary wheels of the latest python-rtmidi version for Windows and
44- macOS / OS X are available on PyPI for several major Python versions. If you
43+ Pre-compiled binary wheels of the latest python-rtmidi version for Windows,
44+ macOS and Linux are available on PyPI for all supported Python versions. If you
4545install python-rtmidi via pip (see above), these wheels will be selected by pip
46- automatically, if you have a compatible Python and Windows or macOS version.
46+ automatically, if you have a compatible Python and OS version and processor
47+ architecture.
4748
48- The Windows binary wheels are compiled with Windows MultiMedia API support and
49- are available in 32-bit and 64-bit versions. The macOS / OS X binary wheels are
50- compiled with CoreMIDI support and are only available in 64-bit versions for OS
51- X 10.6 and later. If you need JACK support on OS X, you need to compile
52- python-rtmidi yourself (see the [ macOS] section below for details).
49+ * Windows binary wheels are compiled with Windows MultiMedia API support and
50+ are available for x86_64 (aka amd64).
5351
52+ * macOS / OS X binary wheels are compiled with CoreMIDI support and are
53+ available for OS X intel (10.9+) and arm64 (aka M1/M2/Apple silicon, 11.0+).
5454
55- ## From Source
56-
57- To compile python-rtmidi from source and install it manually without pip, you
58- can either download a source distribution archive or check out the sources from
59- the Git repository.
60-
61- While the steps to get the sources differ, the actual compilation and
62- installation steps consist of the same standard meson commands in both cases:
55+ If you need JACK support on OS X, you need to compile python-rtmidi yourself
56+ (see the [ macOS] section below for details).
6357
64- ``` console
65- meson setup --prefix=/usr --buildtype=plain builddir
66- meson compile -C builddir
67- meson install -C builddir
68- ```
58+ * Linux binary wheels are available for x64_64 and aarch64,
6959
70- The ` meson setup ` command recognizes several options to control which
71- OS-dependent MIDI backends will be supported by the python-rtmidi extension
72- binary it produces, plus other options to control compilation of the RtMidi C++
73- library:
7460
75- | Option | Linux | macOS | Windows | Note |
76- | ------------------ | ----- | ----- | ------- | -------------------------------------------------------- |
77- | ` -Dalsa=false ` | x | n/a | n/a | Don't compile in support for ALSA backend. |
78- | ` -Djack=false ` | x | x | n/a | Don't compile in support for JACK backend. |
79- | ` -Dcoremidi=false ` | n/a | x | n/a | Don't compile in support for CoreMIDI backend. |
80- | ` -Dwinmm=false ` | n/a | n/a | x | Don't compile in support for Windows MultiMedia backend. |
81- | ` -Dverbose=true ` | x | x | x | Don't suppress RtMidi warnings to stderr. |
61+ ## From Source
8262
83- Support for each OS dependent MIDI backend is only enabled when the required
84- library and header files are actually present on the system.
63+ To compile python-rtmidi from source and install it manually without pip, you
64+ can either download a source distribution archive or check out the sources from
65+ the Git repository. While the steps to get the sources differ, the actual
66+ compilation and installation steps consist of the same commands in both cases.
8567
8668
8769### From the Source Distribution
8870
8971To download the python-rtmidi source distribution archive for the current
90- version, extract and install it, use the following commands:
72+ version and extract it, use the following commands:
9173
9274``` console
9375pip download python-rtmidi
9476tar -xzf python-rtmidi-1.X.Y.tar.gz
9577cd python-rtmidi-1.X.Y
96- meson setup --prefix=/usr --buildtype=plain builddir
97- meson compile -C builddir
98- meson install -C builddir
9978```
10079
101- On Linux or macOS / OS X, if you want to install python-rtmidi into the
102- system-wide Python library directory, you may have to prefix the last command
103- with ` sudo ` , e.g.:
80+ Then follow the commands shown in the section [ buildinstall] .
81+
82+
83+ ### From the Source Code Repository
84+
85+ Alternatively, you can check out the python-rtmidi source code from the Git
86+ repository and then install it from your working copy.
10487
10588``` console
106- sudo meson install -C builddir
89+ (rtmidi)$ git clone --recursive https://github.com/SpotlightKid/python-rtmidi.git
90+ (rtmidi)$ cd python-rtmidi
10791```
10892
109- The recommended way, though, is to install python-rtmidi only for your current
110- user (which ` installer ` does by default) or into a virtual environment:
93+ Then follow the commands shown in the section [ buildinstall] .
94+
95+
96+ (buildinstall)=
97+ ### Build and Install
98+
99+ #### Using the PEP 517 build method (recommended)
100+
101+ The recommended way is to build python-rtmidi via the standard PEP 517 build
102+ method and install it only for your current user (which ` installer ` does by
103+ default) or into a virtual environment.
104+
105+ If you don't already have the ` build ` and ` installer ` Python packages
106+ installed, install them with:
111107
112108``` console
109+ pip install build installer
110+ ```
111+
112+ Then build and install python-rtmidi:
113+
114+ ``` console
115+ python -m build --wheel
113116python -m installer dist/*.whl
114117```
115118
119+ This will download all the required build tools, install them in a temporary
120+ virtual environment, build a wheel, and install it.
116121
117- ### From the Source Code Repository
118122
119- Alternatively, you can check out the python-rtmidi source code from the Git
120- repository and then install it from your working copy. Since the repository
121- does not include the C++ module source code pre-compiled from the Cython
122- source, you'll also need to install Cython >= 0.28, either via pip or from its
123- Git repository. Using virtualenv / virtualenvwrapper is strongly recommended in
124- this scenario:
123+ ### Using meson directly
124+
125+ If you can't or don't want to use the standard PEP 517 build method, you can
126+ also use meson directly, but then you'll need to make sure all the required
127+ build tools are installed.
128+
129+ If you are installing from a Git repository checkout, since this does not
130+ include the C++ module source code pre-compiled from the Cython source, you'll
131+ also need to install Cython >= 0.29, either via pip or from its Git repository.
132+ Using virtualenv / virtualenvwrapper is strongly recommended in this scenario:
125133
126134Make a virtual environment:
127135
@@ -130,24 +138,46 @@ mkvirtualenv rtmidi
130138(rtmidi)$ cdvirtualenv
131139```
132140
133- Install Cython from PyPI:
141+ Install meson and ninja and, if neccessary, Cython from PyPI:
142+
143+ ``` console
144+ (rtmidi)$ pip install Cython meson ninja
145+ ```
134146
135147``` console
136- (rtmidi)$ pip install Cython meson ninja wheel
148+ meson setup --prefix=/usr -Dbuildtype=plain builddir
149+ meson compile -C builddir
150+ meson install -C builddir
137151```
138152
139- Then install python-rtmidi:
153+ On Linux or macOS, if you want to install python-rtmidi into the system-wide
154+ Python library directory, you may have to prefix the last command with ` sudo ` ,
155+ e.g.:
140156
141157``` console
142- (rtmidi)$ git clone --recursive https://github.com/SpotlightKid/python-rtmidi.git
143- (rtmidi)$ cd python-rtmidi
144- (rtmidi)$ meson setup --prefix=/usr --buildtype=plain builddir
145- (rtmidi)$ meson compile -C builddir
146- (rtmidi)$ meson install -C builddir
158+ sudo meson install -C builddir
147159```
148160
161+ The ` meson setup ` command recognizes several options to control which
162+ OS-dependent MIDI backends will be supported by the python-rtmidi extension
163+ binary it produces, plus other options to control compilation of the RtMidi C++
164+ library:
165+
166+ | Option | Linux | macOS | Windows | Note |
167+ | ------------------ | ----- | ----- | ------- | -------------------------------------------------------- |
168+ | ` -Dalsa=false ` | x | n/a | n/a | Don't compile in support for ALSA backend. |
169+ | ` -Djack=false ` | x | x | n/a | Don't compile in support for JACK backend. |
170+ | ` -Dcoremidi=false ` | n/a | x | n/a | Don't compile in support for CoreMIDI backend. |
171+ | ` -Dwinmm=false ` | n/a | n/a | x | Don't compile in support for Windows MultiMedia backend. |
172+ | ` -Dverbose=true ` | x | x | x | Don't suppress RtMidi warnings to stderr. |
173+ | ` -Dpython=python3 ` | x | x | x | Set name (or path) of Python interpreter. |
174+
175+ Support for each OS dependent MIDI backend is only enabled when the required
176+ library and header files are actually present on the system.
177+
178+
149179(requirements)=
150- #### Requirements
180+ ## Requirements
151181
152182Naturally, you'll need a C++ compiler and a build environment. See the
153183platform-specific hints below.
@@ -166,7 +196,7 @@ appropriate compilations flags automatically.
166196- Windows: MultiMedia (MM)
167197
168198
169- ## Linux
199+ ### Linux
170200
171201First you need a C++ compiler and the pthread library. Install the
172202` build-essential ` package on debian-based systems to get these.
@@ -182,24 +212,15 @@ you are using Jack2, install `libjack-jackd2-dev`).
182212
183213
184214(macos)=
185- ## macOS (OS X)
215+ ### macOS (OS X)
186216
187217Install the latest Xcode version or ` g++ ` from MacPorts or homebrew (untested).
188- CoreMIDI support comes with installing Xcode. For JACK support, install
189- [ JackOSX] with the installer or build JACK from source.
190-
191- ** Note:**
192-
193- * If you have a very old version of OS X and Xcode which still supports building
194- binaries for PPC, you'll have to tell distribute to build the package only for
195- i386 and x86_64 architectures:*
196-
197- ``` console
198- env ARCHFLAGS=\"-arch i386 -arch x86_64\" python setup.py install
199- ```
218+ CoreMIDI support comes with installing Xcode. For JACK support, install JACK
219+ with the [ macOS installer] provided on the JACK web site or build JACK from
220+ source.
200221
201222
202- ## Windows
223+ ### Windows
203224
204225Please see the detailed instructions for Windows in ` install-windows ` .
205226
@@ -212,9 +233,9 @@ installing python-rtmidi in an uncommon or not-yet-covered environment.
212233
213234
214235[ Cython ] : http://cython.org/
215- [ JackOSX ] : http://jackaudio.org/downloads/
236+ [ macOS installer ] : http://jackaudio.org/downloads/
216237[ meson ] : https://mesonbuild.com/
217- [ mesonpep517 ] : https://thiblahute.gitlab.io/mesonpep517/
238+ [ meson-python ] : https://github.com/mesonbuild/meson-python
218239[ pep 517 ] : https://peps.python.org/pep-0517/
219240[ pip ] : https://pypi.python.org/pypi/pip
220241[ PyPI page ] : http://python.org/pypi/python-rtmidi#downloads
0 commit comments