Skip to content

Commit 3b715eb

Browse files
committed
feat: switch to meson / mesonpep517 build system
Signed-off-by: Christopher Arndt <chris@chrisarndt.de>
1 parent 348a8f5 commit 3b715eb

22 files changed

+387
-443
lines changed

.flake8

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[flake8]
2+
ignore = E116, E265, E266, E731, W504
3+
max-line-length = 100
4+
exclude = docs,.tox,.git

.gitignore

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,10 @@ src/_rtmidi.cpp
88
# C extensions
99
*.so
1010

11-
# Generated documentation
12-
#INSTALL.rst
13-
1411
# Packages
1512
*.egg
1613
*.egg-info
1714
dist/
18-
build/
1915
*.eggs/
2016
eggs/
2117
parts/
@@ -49,6 +45,8 @@ output/*/index.html
4945

5046
# Sphinx
5147
docs/_build
48+
# docs build artifact
49+
rtmidi/version.py
5250

5351
# Geany project
5452
python-rtmidi.geany

MANIFEST.in

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
1-
include fill_template.py
2-
include LICENSE.txt
31
include Makefile
2+
include *.md
43
include requirements-dev.txt
5-
include tox.ini
6-
include *.rst
7-
include src/_rtmidi.pyx
84
include src/_rtmidi.cpp
9-
include src/pyinit.h
5+
include src/_rtmidi.pyx
106
include src/rtmidi/RtMidi.cpp
117
include src/rtmidi/RtMidi.h
8+
include tox.ini
129

1310
exclude .appveyor.yml
11+
exclude .gitignore
12+
exclude .gitmodules
1413
exclude .travis.yml
15-
exclude *.rst.in
1614

1715
graft examples
1816
graft tests
@@ -22,4 +20,4 @@ prune ci
2220
recursive-exclude * __pycache__
2321
recursive-exclude * *.py[co]
2422

25-
recursive-include docs *.rst *.inc conf.py Makefile make.bat
23+
recursive-include docs *.md *.rst *.inc conf.py Makefile make.bat

Makefile

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
.PHONY: clean-pyc clean-build clean coverage docs dist lint release release_upload requirements test
22

3-
PYTHON ?= python
3+
BUILDDIR ?= builddir
4+
PREFIX ?= /usr/local
5+
PYTHON ?= python3
46
SOURCES = src/_rtmidi.pyx src/rtmidi/RtMidi.cpp
57

68
help:
@@ -19,16 +21,20 @@ help:
1921
@echo "test - run tests on every supported Python version with tox"
2022

2123
build: $(SOURCES)
22-
$(PYTHON) setup.py build_ext --inplace
24+
if [[ -d "$(BUILDDIR)" ]]; then \
25+
meson setup --reconfigure "--prefix=$(PREFIX)" --buildtype=plain $(BUILDDIR); \
26+
else \
27+
meson setup "--prefix=$(PREFIX)" --buildtype=plain $(BUILDDIR); \
28+
fi
29+
meson compile -C $(BUILDDIR)
2330

2431
check-docs:
25-
pydocstyle rtmidi src
32+
$(PYTHON) -m pydocstyle rtmidi
2633

2734
clean: clean-build clean-docs clean-pyc
2835
rm -fr htmlcov/
2936

3037
clean-build:
31-
rm -fr build/
3238
rm -fr dist/
3339
rm -fr *.egg-info
3440
rm -fr rtmidi/*.so
@@ -44,37 +50,39 @@ clean-pyc:
4450
find . -name __pycache__ -type d -exec rm -rf {} +
4551

4652
coverage:
47-
coverage run --source rtmidi setup.py test
48-
coverage report -m
49-
coverage html
50-
xdg-open htmlcov/index.html
53+
$(PYTHON) -mcoverage run --source rtmidi test
54+
$(PYTHON) -mcoverage report -m
55+
$(PYTHON) -mcoverage html
56+
-xdg-open htmlcov/index.html
5157

5258
dist: clean release
5359
ls -l dist
5460

55-
docs: release
61+
docs: build
62+
cp -f $(BUILDDIR)/rtmidi/_rtmidi.*.so rtmidi/
63+
cp -f $(BUILDDIR)/rtmidi/version.py rtmidi/
5664
rm -f docs/rtmidi.rst
5765
rm -f docs/modules.rst
58-
$(PYTHON) setup.py build_ext --inplace
59-
sphinx-apidoc -o docs/ rtmidi rtmidi/release.py
66+
sphinx-apidoc -o docs rtmidi
6067
cat docs/api.rst.inc >> docs/rtmidi.rst
6168
$(MAKE) -C docs clean
6269
$(MAKE) -C docs html
63-
xdg-open docs/_build/html/index.html
70+
-rm -f rtmidi/*.so rtmidi/version.py
71+
-xdg-open docs/_build/html/index.html
6472

6573
lint:
66-
flake8 rtmidi tests examples
74+
$(PYTHON) -m flake8 rtmidi tests examples
6775

68-
release: clean
69-
$(PYTHON) setup.py release
76+
release:
77+
$(PYTHON) -m build
7078

7179
release_upload: release
72-
twine upload --skip-existing dist/*.tar.gz
80+
$(PYTHON) -m twine upload --skip-existing dist/*.tar.gz dist/*.whl
7381

7482
requirements-dev.txt: requirements-dev.in
7583
pip-compile --quiet --resolver=backtracking --no-emit-index-url "$<" > "$@"
7684

7785
requirements: requirements-dev.txt
7886

7987
test:
80-
PYTHONPATH=examples $(PYTHON) setup.py test
88+
pytest -v tests

deploy.sh

Lines changed: 0 additions & 13 deletions
This file was deleted.

docs/conf.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
# All configuration values have a default; values that are commented out
1414
# serve to show the default.
1515

16-
import configparser
1716
import sys
1817
import os
1918

@@ -34,8 +33,6 @@
3433

3534

3635
meta = {}
37-
setupcfg = configparser.ConfigParser()
38-
setupcfg.read(os.path.join(project_root, 'setup.cfg'))
3936
version = os.path.join(project_root, 'rtmidi', 'version.py')
4037
exec(compile(open(version).read(), version, 'exec'), {}, meta)
4138

@@ -61,8 +58,9 @@
6158
master_doc = 'index'
6259

6360
# General information about the project.
64-
project = setupcfg['metadata']['name']
65-
copyright = u'2012 - 2022, %s' % setupcfg['metadata']['author']
61+
project = 'python-rtmidi'
62+
author = 'Christopher Arndt'
63+
copyright = f'2012 - 2022, {author}'
6664

6765
# The version info for the project you're documenting, acts as replacement
6866
# for |version| and |release|, also used in various other places throughout
@@ -216,8 +214,8 @@
216214
# [howto/manual]).
217215
latex_documents = [
218216
('index', 'rtmidi.tex',
219-
u'python-rtmidi Documentation',
220-
setupcfg['metadata']['author'], 'manual'),
217+
'python-rtmidi Documentation',
218+
author, 'manual'),
221219
]
222220

223221
# The name of an image file (relative to this directory) to place at
@@ -247,8 +245,8 @@
247245
# (source start file, name, description, authors, manual section).
248246
man_pages = [
249247
('index', 'rtmidi',
250-
u'python-rtmidi Documentation',
251-
[setupcfg['metadata']['author']], 1)
248+
f'{project} Documentation',
249+
author, 1)
252250
]
253251

254252
# If true, show URL addresses after external links.
@@ -262,10 +260,10 @@
262260
# dir menu entry, description, category)
263261
texinfo_documents = [
264262
('index', 'rtmidi',
265-
u'python-rtmidi Documentation',
266-
setupcfg['metadata']['author'],
267-
setupcfg['metadata']['name'],
268-
setupcfg['metadata']['description'],
263+
f'{project} Documentation',
264+
author,
265+
project,
266+
'',
269267
'Miscellaneous'),
270268
]
271269

fill_template.py

Lines changed: 0 additions & 73 deletions
This file was deleted.

meson.build

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
project(
2+
'python-rtmidi',
3+
'cpp',
4+
version: '1.5.0rc1',
5+
license: 'MIT',
6+
default_options: [
7+
'warning_level=2'
8+
],
9+
meson_version: '>=0.53.0'
10+
)
11+
12+
# Dependencies
13+
cpp = meson.get_compiler('cpp')
14+
jack2_dep = dependency('jack', version:'>=1.9.11', required: false)
15+
jack1_dep = dependency('jack', version:'>=0.125.0, <1.0', required: false)
16+
alsa_dep = dependency('alsa', required: false)
17+
thread_dep = dependency('threads')
18+
coremidi_dep = dependency('threads', required: false)
19+
winmm_dep = dependency('threads', required: false)
20+
21+
if not jack2_dep.found() and jack1_dep.found()
22+
jack_dep = jack1_dep
23+
elif jack2_dep.found()
24+
jack_dep = jack2_dep
25+
else
26+
warning('No version of JACK found, which is recent enough (jack2>=1.9.11 or jack1>=0.125.0)')
27+
endif
28+
29+
pymod = import('python')
30+
python = pymod.find_installation(
31+
get_option('python'),
32+
required: true
33+
)
34+
35+
# Installation directories
36+
prefix = get_option('prefix')
37+
bindir = join_paths(prefix, get_option('bindir'))
38+
39+
# Build jack_mix_box and generate _jack_mixer extension source
40+
subdir('src')
41+
42+
# Build & install C extension module and Python package
43+
subdir('rtmidi')
44+
45+
if not get_option('wheel')
46+
meson.add_install_script('meson_postinstall.py')
47+
endif
48+
49+
summary({
50+
'Debug messages (verbose)': get_option('verbose'),
51+
'Build for wheel': get_option('wheel'),
52+
'ALSA support': target_machine.system() == 'linux' and alsa_dep.found() and get_option('alsa'),
53+
'CoreMIDI support': target_machine.system() == 'darwin' and coremidi_dep.found() and get_option('coremidi'),
54+
'JACK support': jack_dep.found() and get_option('jack'),
55+
'Window MM support': target_machine.system() == 'windows' and winmm_dep.found() and get_option('winmm'),
56+
}, section: 'Configuration')

meson_options.txt

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
option('alsa',
2+
type: 'boolean',
3+
value: true,
4+
description: 'Enable ALSA MIDI support'
5+
)
6+
option('coremidi',
7+
type: 'boolean',
8+
value: true,
9+
description: 'Enable CoreMIDI support'
10+
)
11+
option('jack',
12+
type: 'boolean',
13+
value: true,
14+
description: 'Enable JACK MIDI support'
15+
)
16+
option('python',
17+
type: 'string',
18+
value: 'python3',
19+
description: 'Set name (or path) of Python interpreter'
20+
)
21+
option('verbose',
22+
type: 'boolean',
23+
value: false,
24+
description: 'Turn on debug logging (for development)'
25+
)
26+
option('wheel',
27+
type: 'boolean',
28+
value: false,
29+
description: 'Turn on build mode for creating a Python wheel (should not be used directly)'
30+
)
31+
option('winmm',
32+
type: 'boolean',
33+
value: true,
34+
description: 'Enable Windows MultiMedia support'
35+
)

0 commit comments

Comments
 (0)