Skip to content

Commit 4e58c4d

Browse files
committed
feat: switch to meson / mesonpep517 build system
Signed-off-by: Christopher Arndt <[email protected]>
1 parent 90866f0 commit 4e58c4d

21 files changed

+362
-427
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: 0 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/

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: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.PHONY: clean-pyc clean-build clean coverage docs dist lint release release_upload requirements test
22

3-
PYTHON ?= python
3+
PYTHON ?= python3
44
SOURCES = src/_rtmidi.pyx src/rtmidi/RtMidi.cpp
55

66
help:
@@ -19,16 +19,15 @@ help:
1919
@echo "test - run tests on every supported Python version with tox"
2020

2121
build: $(SOURCES)
22-
$(PYTHON) setup.py build_ext --inplace
22+
$(PYTHON) -m build
2323

2424
check-docs:
25-
pydocstyle rtmidi src
25+
$(PYTHON) -m pydocstyle rtmidi
2626

2727
clean: clean-build clean-docs clean-pyc
2828
rm -fr htmlcov/
2929

3030
clean-build:
31-
rm -fr build/
3231
rm -fr dist/
3332
rm -fr *.egg-info
3433
rm -fr rtmidi/*.so
@@ -44,10 +43,10 @@ clean-pyc:
4443
find . -name __pycache__ -type d -exec rm -rf {} +
4544

4645
coverage:
47-
coverage run --source rtmidi setup.py test
48-
coverage report -m
49-
coverage html
50-
xdg-open htmlcov/index.html
46+
$(PYTHON) -mcoverage run --source rtmidi test
47+
$(PYTHON) -mcoverage report -m
48+
$(PYTHON) -mcoverage html
49+
-xdg-open htmlcov/index.html
5150

5251
dist: clean release
5352
ls -l dist
@@ -56,25 +55,25 @@ docs: release
5655
rm -f docs/rtmidi.rst
5756
rm -f docs/modules.rst
5857
$(PYTHON) setup.py build_ext --inplace
59-
sphinx-apidoc -o docs/ rtmidi rtmidi/release.py
58+
sphinx-apidoc -o docs rtmidi
6059
cat docs/api.rst.inc >> docs/rtmidi.rst
6160
$(MAKE) -C docs clean
6261
$(MAKE) -C docs html
63-
xdg-open docs/_build/html/index.html
62+
-xdg-open docs/_build/html/index.html
6463

6564
lint:
66-
flake8 rtmidi tests examples
65+
$(PYTHON) -m flake8 rtmidi tests examples
6766

6867
release: clean
69-
$(PYTHON) setup.py release
68+
$(PYTHON) -m build
7069

7170
release_upload: release
72-
twine upload --skip-existing dist/*.tar.gz
71+
$(PYTHON) -m twine upload --skip-existing dist/*.tar.gz dist/*.whl
7372

7473
requirements-dev.txt: requirements-dev.in
7574
pip-compile --quiet --resolver=backtracking --no-emit-index-url "$<" > "$@"
7675

7776
requirements: requirements-dev.txt
7877

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

deploy.sh

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

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+
)

meson_postinstall.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env python3
2+
3+
import sysconfig
4+
from compileall import compile_dir
5+
from os import environ, path
6+
7+
destdir = environ.get('MESON_INSTALL_DESTDIR_PREFIX', '')
8+
9+
print('Compiling Python module to bytecode...')
10+
moduledir = sysconfig.get_path('purelib', vars={'base': destdir})
11+
compile_dir(path.join(moduledir, 'rtmidi'), optimize=1)

pyproject.toml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
[build-system]
2+
# https://thiblahute.gitlab.io/mesonpep517/
3+
build-backend = "mesonpep517.buildapi"
4+
requires = [
5+
"cython",
6+
"wheel",
7+
"mesonpep517 @ git+https://gitlab.com/SpotlightKid/mesonpep517.git@rtmidi",
8+
"ninja"
9+
]
10+
11+
[project]
12+
description = "A Python binding for the RtMidi C++ library implemented using Cython."
13+
authors = [
14+
{ name="Christopher Arndt", email="[email protected]" },
15+
]
16+
readme = "README.md"
17+
requires-python = ">=3.7"
18+
classifiers = [
19+
"Development Status :: 5 - Production/Stable",
20+
"Environment :: MacOS X",
21+
"Environment :: Win32 (MS Windows)",
22+
"Environment :: Console",
23+
"Intended Audience :: Developers",
24+
"License :: OSI Approved :: MIT License",
25+
"Operating System :: Microsoft :: Windows",
26+
"Operating System :: POSIX",
27+
"Operating System :: MacOS :: MacOS X",
28+
"Programming Language :: Python",
29+
"Programming Language :: Python :: 3",
30+
"Programming Language :: Python :: 3.7",
31+
"Programming Language :: Python :: 3.8",
32+
"Programming Language :: Python :: 3.9",
33+
"Programming Language :: Python :: 3.10",
34+
"Programming Language :: Python :: 3.11",
35+
"Topic :: Multimedia :: Sound/Audio :: MIDI",
36+
"Topic :: Software Development :: Libraries :: Python Modules",
37+
]
38+
keywords = [
39+
"MIDI",
40+
"multimedia",
41+
"music",
42+
"rtmidi",
43+
]
44+
meson-python-option-name = "python"
45+
meson-options = [
46+
"-Dwheel=true",
47+
"--buildtype=plain"
48+
]
49+
50+
[project.license]
51+
file = "LICENSE.md"
52+
53+
[project.urls]
54+
"Bug Tracker" = "https://github.com/SpotlightKid/python-rtmidi/issues"
55+
"Documentation" = "https://spotlightkid.github.io/python-rtmidi/"
56+
"Download" = "https://pypi.python.org/pypi/python-rtmidi"
57+
"Homepage" = "https://github.com/SpotlightKid/python-rtmidi"
58+
"Source" = "https://gitlab.com/SpotlightKid/python-rtmidi/"
59+
60+
[tool.black]
61+
line-length = 99
62+
target-version = [
63+
"py37",
64+
"py38",
65+
"py39",
66+
"py310",
67+
"py311",
68+
]
69+
70+
[tool.isort]
71+
line_length = 99
72+
profile = "black"
73+
74+
[tool.pydocstyle]
75+
match = '(?!test_).*\.pyx?'
76+
match_dir = '(src|rtmidi)'
77+
add_ignore = [
78+
"D412"
79+
]

0 commit comments

Comments
 (0)