Tts: Cannot compile due to cython compiling error

Created on 19 Oct 2020  路  5Comments  路  Source: mozilla/TTS

Hi,

I tried to install, followed the readme. However it fails:
obraz

Compiling ./TTS/tts/layers/glow_tts/monotonic_align/core.pyx because it depends on /home/lukasz/projects/TTS/venv/lib/python3.8/site-packages/Cython/Includes/cpython/type.pxd.
Compiling ./venv/lib/python3.8/site-packages/Cython/Utility/CppConvert.pyx because it changed.
Compiling ./venv/lib/python3.8/site-packages/Cython/Utility/TestCythonScope.pyx because it changed.
Compiling ./venv/lib/python3.8/site-packages/Cython/Utility/MemoryView.pyx because it changed.
Compiling ./venv/lib/python3.8/site-packages/Cython/Utility/CpdefEnums.pyx because it changed.
Compiling ./venv/lib/python3.8/site-packages/Cython/Utility/CConvert.pyx because it changed.
Compiling ./venv/lib/python3.8/site-packages/Cython/Utility/TestCyUtilityLoader.pyx because it changed.
Compiling ./venv/lib/python3.8/site-packages/Cython/Runtime/refnanny.pyx because it changed.
Compiling ./venv/lib/python3.8/site-packages/numpy/random/_examples/cython/extending_distributions.pyx because it changed.
Compiling ./venv/lib/python3.8/site-packages/numpy/random/_examples/cython/extending.pyx because it changed.
[ 1/10] Cythonizing ./venv/lib/python3.8/site-packages/Cython/Runtime/refnanny.pyx
[ 2/10] Cythonizing ./venv/lib/python3.8/site-packages/Cython/Utility/CConvert.pyx

Error compiling Cython file:
------------------------------------------------------------
...
    PyTypeObject *Py_TYPE(obj)
    bint PyMapping_Check(obj)
    object PyErr_Format(exc, const char *format, ...)

@cname("{{funcname}}")
cdef {{struct_type}} {{funcname}}(obj) except *:
    ^
------------------------------------------------------------

venv/lib/python3.8/site-packages/Cython/Utility/CConvert.pyx:11:5: Expected an identifier, found '{'

Error compiling Cython file:
------------------------------------------------------------
...
    PyTypeObject *Py_TYPE(obj)
    bint PyMapping_Check(obj)
    object PyErr_Format(exc, const char *format, ...)

@cname("{{funcname}}")
cdef {{struct_type}} {{funcname}}(obj) except *:
     ^
------------------------------------------------------------

venv/lib/python3.8/site-packages/Cython/Utility/CConvert.pyx:11:6: Syntax error in C variable declaration
Traceback (most recent call last):
  File "setup.py", line 123, in <module>
    ext_modules=find_cython_extensions(),
  File "setup.py", line 64, in find_cython_extensions
    exts = cythonize(find_pyx(path), language_level=3)
  File "/home/lukasz/projects/TTS/venv/lib/python3.8/site-packages/Cython/Build/Dependencies.py", line 1102, in cythonize
    cythonize_one(*args)
  File "/home/lukasz/projects/TTS/venv/lib/python3.8/site-packages/Cython/Build/Dependencies.py", line 1225, in cythonize_one
    raise CompileError(None, pyx_file)
Cython.Compiler.Errors.CompileError: ./venv/lib/python3.8/site-packages/Cython/Utility/CConvert.pyx

I stepped back and found the last working commit, which is: f9001a4bdd8a169da8b4eefd481461f370def8f9

Later commits (10258724d135656da526d5f6b5aaaeee787e4f04) include new cython files indeed

Tested on docker https://github.com/synesthesiam and it fails too

Suggestions?

Most helpful comment

This happens because the venv is inside the repo directory and setup.py cythonizes all cython files inside the repo directory, so it will try to cythonize the cython source code itself in ./.venv/lib.
You can see it in the logs:

[ 1/10] Cythonizing ./venv/lib/python3.8/site-packages/Cython/Runtime/refnanny.pyx
[ 2/10] Cythonizing ./venv/lib/python3.8/site-packages/Cython/Utility/CConvert.pyx

Simply create your venv outside of the repo directory and it will work.

All 5 comments

This seems to be a problem with virtualenv.

Few days ago it fixed by itself and I cannot reproduce the bug. I did not even update the repo. :shrug:
Maybe it is dependent package bug?

Closing then...

i have the same Error and i also use Virtualenv so that might really be a venv problem

This happens because the venv is inside the repo directory and setup.py cythonizes all cython files inside the repo directory, so it will try to cythonize the cython source code itself in ./.venv/lib.
You can see it in the logs:

[ 1/10] Cythonizing ./venv/lib/python3.8/site-packages/Cython/Runtime/refnanny.pyx
[ 2/10] Cythonizing ./venv/lib/python3.8/site-packages/Cython/Utility/CConvert.pyx

Simply create your venv outside of the repo directory and it will work.

@xBelladonna Thank you for debugging of the issue! 馃殌 Indeed, I was juggling with venv path here and there :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

xoxoxo13102020 picture xoxoxo13102020  路  5Comments

haqkiemdaim picture haqkiemdaim  路  9Comments

PetrochukM picture PetrochukM  路  9Comments

floatingatoll picture floatingatoll  路  3Comments

erogol picture erogol  路  11Comments