Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -449,16 +449,21 @@ endif

endif # emscripten

portmidi_dep = dependency('portmidi', required: false)
if not portmidi_dep.found() and not plat.startswith('emscripten')
portmidi_dep = declare_dependency(
include_directories: pg_inc_dirs,
dependencies: cc.find_library(
'portmidi',
dirs: pg_lib_dirs,
required: get_option('midi'),
),
)
midi_opt = get_option('midi')
# Start from a not-found dependency so pypm is only built when portmidi is
# actually available and the midi option allows it.
portmidi_dep = dependency('', required: false)
if not midi_opt.disabled()
portmidi_dep = dependency('portmidi', required: false)
if not portmidi_dep.found() and not plat.startswith('emscripten')
portmidi_lib = cc.find_library('portmidi', dirs: pg_lib_dirs, required: midi_opt)
Comment thread
coderabbitai[bot] marked this conversation as resolved.
if portmidi_lib.found()
portmidi_dep = declare_dependency(
include_directories: pg_inc_dirs,
dependencies: portmidi_lib,
)
endif
endif
endif

portmidi_deps = [portmidi_dep]
Expand Down
9 changes: 8 additions & 1 deletion src_py/midi.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,14 @@

import pygame
import pygame.locals
import pygame.pypm as _pypm

try:
import pygame.pypm as _pypm
except ImportError as e:
raise ImportError(
"pygame.midi is not available because pygame was built without portmidi "
"support (the midi build option was disabled or portmidi was not found)"
) from e

# For backward compatibility.
MIDIIN = pygame.locals.MIDIIN
Expand Down