libremidi icon indicating copy to clipboard operation
libremidi copied to clipboard

A python package on the way?

Open pissalou opened this issue 10 months ago • 12 comments

Hello Jean-Michaël, I noticed the recent addition of python bindings to the project. Is your intention to also build python packages in github actions and publish them to pypi.org? I think that would be of great value and would happily look into making a workflow for it if you agree.

pissalou avatar Jan 15 '25 12:01 pissalou

Hello ! Yes, and help for the GH workflow especially for submitting to PyPI would be amazing!

jcelerier avatar Jan 15 '25 14:01 jcelerier

I'm currently adding a GH workflow in https://github.com/celtera/libremidi/pull/140

jcelerier avatar Mar 01 '25 18:03 jcelerier

python workflow merged !

jcelerier avatar Mar 03 '25 21:03 jcelerier

Hello Jean-Michael, I have tried to import the pyd file generated by the workflow on windows 10 but it is failing: `Python 3.13.2 (tags/v3.13.2:4f8bb39, Feb 4 2025, 15:23:48) [MSC v.1942 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information.

import sys import os import dlltracer os.add_dll_directory('C:\Windows\System32') <AddedDllDirectory('C:\Windows\System32')> with dlltracer.Trace(out=sys.stdout): ... import pylibremidi ... LoadLibrary C:\Windows\System32\kernel.appcore.dll LoadLibrary C:\code\jambuddy\pylibremidi.pyd LoadLibrary C:\Windows\System32\winmm.dll Failed \Device\HarddiskVolume3\Windows\System32\winmm.dll Failed \Device\HarddiskVolume3\code\jambuddy\pylibremidi.pyd Traceback (most recent call last): File "", line 2, in import pylibremidi ImportError: DLL load failed while importing pylibremidi: The specified module could not be found.`

I suspect it is because the project is compile with --config Debug and I do not have the vc++ debug DLLs, I will try again with the --config flipped to Release to confirm this hypothesis.

pissalou avatar Mar 05 '25 13:03 pissalou

this could definitely be a cause indeed, the MSVC toolchain does not support mixing debug and release DLLs

jcelerier avatar Mar 09 '25 10:03 jcelerier

just tried on msvc and seems to be alright there:

Image

jcelerier avatar Mar 12 '25 11:03 jcelerier

I observed the same on my windows machine: even though the project was compiled against cpython 3.13.2, importing the dll on python 3.11.0 goes fine. What is more surprising is that it does not work when I try to import the same dll on python 3.13.2 (the exact same version the project is compiled against), I either get "DLL load failed" as mentioned earlier when compiling with --config Debug or import pylibremidi just hangs forever when compiled with --config Release. I did not get the chance to test this on Linux yet but hopefully I will be able to run some more tests on ubuntu as well.

pissalou avatar Mar 12 '25 11:03 pissalou

I'll try with python 3.13.2 to see what happens

jcelerier avatar Mar 12 '25 13:03 jcelerier

Okay, indeed here I'm getting a stall when doing import pylibremidi on 3.13

jcelerier avatar Mar 12 '25 14:03 jcelerier

Also with 3.12, and also with msys's clang & python & .... 3.11 works fine everywhere.

jcelerier avatar Mar 12 '25 14:03 jcelerier

I think I got a fix, it was some static variable that triggered too-early-loading of winrt

jcelerier avatar Mar 12 '25 14:03 jcelerier

Image :)

jcelerier avatar Mar 12 '25 14:03 jcelerier