SpotlightKid / python-rtmidi

Python bindings for the cross-platform MIDI I/O library RtMidi
https://spotlightkid.github.io/python-rtmidi/
Other
349 stars 65 forks source link

Python 3.11 support (src/_rtmidi.cpp:243:12: fatal error: longintrepr.h: No such file or directory) #115

Closed apinkney97 closed 1 year ago

apinkney97 commented 1 year ago

Hi, installing via pip on Python 3.11.0 on linux, I get

$ pip install python-rtmidi
Collecting python-rtmidi
  Using cached python-rtmidi-1.4.9.tar.gz (251 kB)
  Preparing metadata (setup.py) ... done
Installing collected packages: python-rtmidi
  DEPRECATION: python-rtmidi is being installed using the legacy 'setup.py install' method, because it does not have a 'pyproject.toml' and the 'wheel' package is not installed. pip 23.1 will enforce this behaviour change. A possible replacement is to enable the '--use-pep517' option. Discussion can be found at https://github.com/pypa/pip/issues/8559
  Running setup.py install for python-rtmidi ... error
  error: subprocess-exited-with-error

  × Running setup.py install for python-rtmidi did not run successfully.
  │ exit code: 1
  ╰─> [46 lines of output]
      /tmp/pip-install-7hrewfls/python-rtmidi_71d122c223504a2ebead28914de163d0/setup.py:27: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
        JACK1_MIN_VERSION = StrictVersion('0.125.0')
      /tmp/pip-install-7hrewfls/python-rtmidi_71d122c223504a2ebead28914de163d0/setup.py:28: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
        JACK2_MIN_VERSION = StrictVersion('1.9.11')
      /tmp/pip-install-7hrewfls/python-rtmidi_71d122c223504a2ebead28914de163d0/setup.py:45: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
        jv = StrictVersion(res.decode())
      Detected JACK version 1.9.20.
      JACK version is recent enough to have 'jack_port_rename' function.
      running install
      /home/alex/.pyenv/versions/3.11.0/envs/midivis/lib/python3.11/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
        warnings.warn(
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-cpython-311
      creating build/lib.linux-x86_64-cpython-311/rtmidi
      copying rtmidi/midiutil.py -> build/lib.linux-x86_64-cpython-311/rtmidi
      copying rtmidi/midiconstants.py -> build/lib.linux-x86_64-cpython-311/rtmidi
      copying rtmidi/__init__.py -> build/lib.linux-x86_64-cpython-311/rtmidi
      copying rtmidi/version.py -> build/lib.linux-x86_64-cpython-311/rtmidi
      running egg_info
      writing python_rtmidi.egg-info/PKG-INFO
      writing dependency_links to python_rtmidi.egg-info/dependency_links.txt
      writing top-level names to python_rtmidi.egg-info/top_level.txt
      reading manifest file 'python_rtmidi.egg-info/SOURCES.txt'
      reading manifest template 'MANIFEST.in'
      warning: no previously-included files found matching '.appveyor.yml'
      warning: no previously-included files found matching '.travis.yml'
      warning: no previously-included files found matching '*.rst.in'
      no previously-included directories found matching 'ci'
      warning: no previously-included files matching '__pycache__' found under directory '*'
      warning: no previously-included files matching '*.py[co]' found under directory '*'
      adding license file 'LICENSE.txt'
      adding license file 'AUTHORS.rst'
      writing manifest file 'python_rtmidi.egg-info/SOURCES.txt'
      running build_ext
      building 'rtmidi._rtmidi' extension
      creating build/temp.linux-x86_64-cpython-311
      creating build/temp.linux-x86_64-cpython-311/src
      creating build/temp.linux-x86_64-cpython-311/src/rtmidi
      gcc -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -D__RTMIDI_SILENCE_WARNINGS__ -D__LINUX_ALSA__ -D__UNIX_JACK__ -DJACK_HAS_PORT_RENAME -Isrc/rtmidi -I/home/alex/.pyenv/versions/3.11.0/envs/midivis/include -I/home/alex/.pyenv/versions/3.11.0/include/python3.11 -c src/_rtmidi.cpp -o build/temp.linux-x86_64-cpython-311/src/_rtmidi.o
      src/_rtmidi.cpp:243:12: fatal error: longintrepr.h: No such file or directory
        243 |   #include "longintrepr.h"
            |            ^~~~~~~~~~~~~~~
      compilation terminated.
      error: command '/usr/bin/gcc' failed with exit code 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> python-rtmidi

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.

This seems to be related to https://github.com/python/cpython/pull/28968, where longintrepr.h was moved to cpython/longintrepr.h.

src/_rtmidi.cpp in the .tar.gz that Pip downloads seems to be generated with Cython, so presumably needs to be re-generated with a version of Cython that's aware of this change.

For the record, I was able to successfully install from source (following the instructions from here) and otherwise everything seems to be working fine.

Bubobubobubobubo commented 1 year ago

Same issue here. Chiming in.

krixgris commented 1 year ago

Also running into the same issue. I'm getting this error on Mac OS but the same actualy error with longintrepr.h not found.

Bubobubobubobubo commented 1 year ago

It looks like #108 and #115 could be resolved by taking a look at #100. This would be greatly helpful for all python-rtmidi dependant apps developed since last year, especially those depending on mido (which in turn depends on python-rtmidi). Can I be of some help for during this update process?

liudonghua123 commented 1 year ago

I tried to build some wheels based on https://github.com/Czaki/python-rtmidi, see https://github.com/liudonghua123/python-rtmidi/releases/tag/1.4.9 .

Now python-rtmidi works on my python 3.11.

luckydonald commented 1 year ago

Note, to try the merge request of @Czaki, one can use pip install:

pip install git+https://github.com/SpotlightKid/python-rtmidi.git@eb16ab3268b29b94cd2baa6bfc777f5cf5f908ba#egg=python-rtmidi
krixgris commented 1 year ago

Note, to try the merge request of @Czaki, one can use pip install:

pip install git+https://github.com/SpotlightKid/python-rtmidi.git@eb16ab3268b29b94cd2baa6bfc777f5cf5f908ba#egg=python-rtmidi

Thank you! I am too green to realise you could do that. Tried it this morning and seems to work great.

jenishngl commented 1 year ago

Note, to try the merge request of @Czaki, one can use pip install:

pip install git+https://github.com/SpotlightKid/python-rtmidi.git@eb16ab3268b29b94cd2baa6bfc777f5cf5f908ba#egg=python-rtmidi

This doesnt seem to work for me

georgeharker commented 1 year ago

This does work for me - would be great to find a way of getting that in the mainline.

Bubobubobubobubo commented 1 year ago

Bump again. We are vendoring our own python-rtmidi-wheels externally as part of the Sardine project and it would be nice to be able to get back to using python-rtmidi without adding to the installation instructions.

rec commented 1 year ago

@jenishngl:

I used poetry to successfully install this with the command

poetry add 'git+https://github.com/SpotlightKid/python-rtmidi.git#eb16ab3268b29b94cd2baa6bfc777f5cf5f908ba' @Bubobubobubobubo

You should be able to reference that specific version in your pyproject.toml or your requirements.txt and not require that additional draggy step for your users!

SpotlightKid commented 1 year ago

Hi all, please take note of #137

brunoenten commented 1 year ago

Fixed by merging https://github.com/SpotlightKid/python-rtmidi/pull/119