missionpinball/mpf-mc

Install error Python 3.8 / Cython 0.29.10

PouueT opened this issue · 3 comments

Context:

  • Fresh development install in Linux Ubuntu 20.04
  • Python 3.8 virtual environnent
  • cython 0.29.21
  • pip3 install -e mpf is OK

But pip3 install -e mpf-mc result with errors, example :

122 | PyAPI_FUNC(PyCodeObject *) PyCode_New(
    |    
                    ^~~~~~~~~~

  /tmp/pip-install-7s88whfo/mpf-mc/mpfmc/core/audio/sound_file.c:318:11: error: too many arguments to function ‘PyCode_New'
318 |           PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
    | 
                              ^~~~~~~~~~

In fact, the problem is related to Python 3.8 / Cython API changes : cython/cython@761f996
https://bugs.python.org/issue37221
https://docs.python.org/3.8/c-api/code.html ( PyCode_New(...) )

As of today, Cython master branch close to release tag 0.29.21 looks likes this, Line 488 :
https://github.com/cython/cython/blob/master/Cython/Utility/ModuleSetupCode.c

List of MPF-MC concerned files :

$ git grep PyCode_New\(a,\ 0
mpfmc/core/audio/audio_interface.c:          PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
mpfmc/core/audio/playlist_controller.c:          PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
mpfmc/core/audio/track.c:          PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
mpfmc/core/audio/track_sound_loop.c:          PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
mpfmc/core/audio/track_standard.c:          PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
mpfmc/uix/bitmap_font/bitmap_font.c:          PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)

Quick and dirty fix for test purpose (Tested OK) :
Remove '0' arg :

-          PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
+         PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)

@qcapen @jabdoa2 , I guess real problems comes from being able to cythonize / regenarate those files with local cythons.
(And what to decide to keep in master branch for pre generated files ?)

By default, with setup.py, we have skip_cython True and uses pre cythonized c sources.
It doesn't look like cythonizing sources with a local cython install works:
$ export USE_CYTHON=y
modify setup.py MAX_CYTHON_STRING = '0.29.21'
-> skipping '/xxxxxxx/mpf-mc/mpfmc/core/audio/sound_file.c' Cython extension (up-to-date)

Side note :
Currently, in mpf-debian-installer-dev.zip -> install-mpf-dependencies :
pip3 install -I Cython==0.27.3
Maybe we can update the install shell script to have a working package combination (with python 3.5 to 3.X) ?

@qcapen any thoughts on this?

@PouueT I see that Quinn commited the change to dev. Could you test if that works for you?