patrickkidd / pyrtmidi

Realtime MIDI I/O for python.
157 stars 14 forks source link

Compilation faild with MinGW on Windows #19

Open GalaxySnail opened 4 years ago

GalaxySnail commented 4 years ago

Discription

$ pip install rtmidi
    ...
    D:\msys2-64\mingw64\bin\gcc.exe -mdll -O -Wall -DMS_WIN64 -D__WINDOWS_MM__= -DPK_WINDOWS=1 -If:\mypython\ms2mmleditor\.venv-mmlparser\include -ID:\Python38\include -ID:\Python38\include -c cpp_src\RtMidi.cpp -o build\temp.win-amd64-3.8\Release\cpp_src\rtmidi.o /EHsc
    gcc: error: /EHsc: No such file or directory
    error: command 'D:\\msys2-64\\mingw64\\bin\\gcc.exe' failed with exit status 1

Then I downloaded this package and modified setup.py:

$ pip download rtmidi
$ tar -xzvf rtmidi-2.3.4.tar.gz
elif OSNAME == 'Windows':
    define_macros = [('__WINDOWS_MM__', ''),
                     ('PK_WINDOWS', '1')]
    # library_dirs = ['C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib']
    libraries = ['winmm', 'python34']
    # extra_compile_args = ['/EHsc']

(btw, I don't know why it is "python34")

$ tar -czvf rtmidi-2.3.4.tar.gz rtmidi-2.3.4
$ pip install rtmidi-2.3.4.tar.gz
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Processing f:\mypython\ms2mmleditor\rtmidi-2.3.4.tar.gz
Installing collected packages: rtmidi
    Running setup.py install for rtmidi ... done
Successfully installed rtmidi-2.3.4

This time I installed successfully, but got an ImportError:

Python 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 23:11:46) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import rtmidi
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "F:\mypython\ms2mmlEditor\.venv-mmlparser\lib\site-packages\rtmidi\__init__.py", line 1, in <module>
    from ._rtmidi import *
ImportError: DLL load failed while importing _rtmidi: 找不到指定的模块。

So I have no idea how to install pyrtmidi without MSVC.

Environment

OS: Microsoft Windows 10 Home (v10.0.18363) 64bit Python: Python 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 23:11:46) [MSC v.1916 64 bit (AMD64)] on win32 (Installed with exe)

$ cat "D:\Python38\Lib\distutils\distutils.cfg"
[build]
compiler=mingw32

$ gcc --version
gcc.exe (Rev1, Built by MSYS2 project) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
ghost commented 4 years ago

This can be resolved by setting python34 to python38, not entirely sure how setup.py files work, but i'm assuming removing python34 from the list would be fine.