From 8eb5780cc7ccb3f67438ccff0f97e8745feb6ce9 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Mon, 22 Jun 2020 22:10:40 +0200 Subject: [PATCH] pythonPackages.mido: init at 1.2.9 --- .../python-modules/mido/default.nix | 39 +++++++++++++++++++ .../mido/libportmidi-cdll.patch | 19 +++++++++ pkgs/top-level/python-packages.nix | 2 + 3 files changed, 60 insertions(+) create mode 100644 pkgs/development/python-modules/mido/default.nix create mode 100644 pkgs/development/python-modules/mido/libportmidi-cdll.patch diff --git a/pkgs/development/python-modules/mido/default.nix b/pkgs/development/python-modules/mido/default.nix new file mode 100644 index 000000000000..8312ea783cb4 --- /dev/null +++ b/pkgs/development/python-modules/mido/default.nix @@ -0,0 +1,39 @@ +{ stdenv, lib, buildPythonPackage, fetchPypi, substituteAll +, portmidi, pygame, python-rtmidi, rtmidi-python +, pytest +}: + +buildPythonPackage rec { + pname = "mido"; + version = "1.2.9"; + + src = fetchPypi { + inherit pname version; + sha256 = "1k3sgkxc7j49bapib3b5jnircb1yhyyd8mi0mbfd78zgix9db9y4"; + }; + + patches = [ + (substituteAll { + src = ./libportmidi-cdll.patch; + libportmidi = "${portmidi.out}/lib/libportmidi${stdenv.targetPlatform.extensions.sharedLibrary}"; + }) + ]; + + propagatedBuildInputs = [ + pygame + python-rtmidi + rtmidi-python + ]; + + checkInputs = [ pytest ]; + checkPhase = '' + py.test . -rs -q + ''; + + meta = with lib; { + description = "MIDI Objects for Python"; + homepage = "https://mido.readthedocs.io"; + license = licenses.mit; + maintainers = with maintainers; [ hexa ]; + }; +} diff --git a/pkgs/development/python-modules/mido/libportmidi-cdll.patch b/pkgs/development/python-modules/mido/libportmidi-cdll.patch new file mode 100644 index 000000000000..455064f12b9a --- /dev/null +++ b/pkgs/development/python-modules/mido/libportmidi-cdll.patch @@ -0,0 +1,19 @@ +diff --git a/mido/backends/portmidi_init.py b/mido/backends/portmidi_init.py +index 84bb128..5efcdaa 100644 +--- a/mido/backends/portmidi_init.py ++++ b/mido/backends/portmidi_init.py +@@ -10,13 +10,7 @@ from ctypes import (CDLL, CFUNCTYPE, POINTER, Structure, c_char_p, + create_string_buffer, byref) + import ctypes.util + +-dll_name = '' +-if sys.platform == 'darwin': +- dll_name = ctypes.util.find_library('libportmidi.dylib') +-elif sys.platform in ('win32', 'cygwin'): +- dll_name = 'portmidi.dll' +-else: +- dll_name = 'libportmidi.so' ++dll_name = '@libportmidi@' + + lib = CDLL(dll_name) + diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 53731efcfb6c..6b0ab50d0d92 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -3196,6 +3196,8 @@ in { midiutil = callPackage ../development/python-modules/midiutil {}; + mido = callPackage ../development/python-modules/mido { }; + misaka = callPackage ../development/python-modules/misaka {}; mlrose = callPackage ../development/python-modules/mlrose { };