kanishka-linux / kawaii-player

Multimedia player, media library manager and portable media server with PC-To-PC casting feature.
GNU General Public License v3.0
623 stars 45 forks source link

Cython.Compiler.Errors.CompileError: mpv.pyx #49

Closed ezvision closed 9 months ago

ezvision commented 9 months ago

Hey, I'm on fedora and I run into this issue when running python3 setup.py sdist

full output:

[1/1] Cythonizing mpv.pyx warning: mpv.pyx:765:0: The 'DEF' statement is deprecated and will be removed in a future Cython version. Consider using global variables, constants, and in-place literals instead. See https://github.com/cython/cython/issues/4310

Error compiling Cython file:

... assert self._ctx cdef uint64_t name = id(self) self.callback = callback self.callbackthread.set(callback) with nogil: mpv_set_wakeup_callback(self._ctx, _c_callback, <void*>name) ^

mpv.pyx:681:47: Cannot assign type 'void (void ) except nogil' to 'void ()(void ) noexcept'. Exception values are incompatible. Suggest adding 'noexcept' to type 'void (void ) except nogil'.

Error compiling Cython file:

... else: raise PyMPVError("Unknown api_type %r" % api_type)

    if opengl_init_params is not None:
        self._get_proc_address = opengl_init_params["get_proc_address"]
        gl_params.get_proc_address = &_c_getprocaddress
                                     ^

mpv.pyx:866:41: Cannot assign type 'void ()(void , const char ) except? NULL nogil' to 'void ()(void , const char ) noexcept'. Exception values are incompatible. Suggest adding 'noexcept' to type 'void (void , const char *) except? NULL nogil'.

Error compiling Cython file:

...

    return RenderFrameInfo()._from_struct(&info)

def set_update_callback(self, cb):
    with nogil:
        mpv_render_context_set_update_callback(self._ctx, &_c_updatecb, <void *>cb)
                                                          ^

mpv.pyx:945:62: Cannot assign type 'void ()(void ) except nogil' to 'mpv_render_update_fn'. Exception values are incompatible. Suggest adding 'noexcept' to type 'void (void ) except nogil'. Traceback (most recent call last): File "/home/asher/pympv/setup.py", line 57, in extensions = cythonize(extensions, force=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib64/python3.12/site-packages/Cython/Build/Dependencies.py", line 1134, in cythonize cythonize_one(args) File "/usr/lib64/python3.12/site-packages/Cython/Build/Dependencies.py", line 1301, in cythonize_one raise CompileError(None, pyx_file) Cython.Compiler.Errors.CompileError: mpv.pyx

kanishka-linux commented 9 months ago

cython < 3 is needed for pympv build.

try pip install -e . as given in installation instruction (1st para) - it should work, since it will take into account pyproject.toml for the build process - which has dependencies listed for the build.

ezvision commented 9 months ago

I get this when running that:

Defaulting to user installation because normal site-packages is not writeable Obtaining file:///home/user/kawaii-player Installing build dependencies ... done Checking if build backend supports build_editable ... done Getting requirements to build editable ... done Preparing editable metadata (pyproject.toml) ... done Building wheels for collected packages: kawaii-player Building editable for kawaii-player (pyproject.toml) ... error error: subprocess-exited-with-error

× Building editable for kawaii-player (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [100 lines of output] [1/1] Cythonizing pympv/mpv.pyx running editable_wheel creating /tmp/pip-wheel-o2phgw1r/.tmp-l76_8hn4/kawaii_player.egg-info writing /tmp/pip-wheel-o2phgw1r/.tmp-l76_8hn4/kawaii_player.egg-info/PKG-INFO writing dependency_links to /tmp/pip-wheel-o2phgw1r/.tmp-l76_8hn4/kawaii_player.egg-info/dependency_links.txt writing entry points to /tmp/pip-wheel-o2phgw1r/.tmp-l76_8hn4/kawaii_player.egg-info/entry_points.txt writing top-level names to /tmp/pip-wheel-o2phgw1r/.tmp-l76_8hn4/kawaii_player.egg-info/top_level.txt writing manifest file '/tmp/pip-wheel-o2phgw1r/.tmp-l76_8hn4/kawaii_player.egg-info/SOURCES.txt' reading manifest file '/tmp/pip-wheel-o2phgw1r/.tmp-l76_8hn4/kawaii_player.egg-info/SOURCES.txt' reading manifest template 'MANIFEST.in' warning: no files found matching 'kawaii_player/kawaii-player-start' warning: no files found matching 'kawaii_player/kawaii-player' adding license file 'LICENSE' writing manifest file '/tmp/pip-wheel-o2phgw1r/.tmp-l76_8hn4/kawaii_player.egg-info/SOURCES.txt' creating '/tmp/pip-wheel-o2phgw1r/.tmp-l76_8hn4/kawaii_player-6.0.0.dist-info' creating /tmp/pip-wheel-o2phgw1r/.tmp-l76_8hn4/kawaii_player-6.0.0.dist-info/WHEEL running build_py running build_ext building 'mpv' extension creating /tmp/tmpe8s84dfb.build-temp/pympv gcc -fno-strict-overflow -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -fexceptions -fcf-protection -fexceptions -fcf-protection -fexceptions -fcf-protection -fPIC -I/usr/include/python3.12 -c pympv/mpv.c -o /tmp/tmpe8s84dfb.build-temp/pympv/mpv.o pympv/mpv.c:22:10: fatal error: Python.h: No such file or directory 22 | #include "Python.h" | ^~~~~~ compilation terminated. Traceback (most recent call last): File "/tmp/pip-build-env-dwo74zbi/overlay/lib/python3.12/site-packages/setuptools/_distutils/unixccompiler.py", line 185, in _compile self.spawn(compiler_so + cc_args + [src, '-o', obj] + extra_postargs) File "/tmp/pip-build-env-dwo74zbi/overlay/lib/python3.12/site-packages/setuptools/_distutils/ccompiler.py", line 1041, in spawn spawn(cmd, dry_run=self.dry_run, **kwargs) File "/tmp/pip-build-env-dwo74zbi/overlay/lib/python3.12/site-packages/setuptools/_distutils/spawn.py", line 70, in spawn raise DistutilsExecError( distutils.errors.DistutilsExecError: command '/usr/bin/gcc' failed with exit code 1

  During handling of the above exception, another exception occurred:

  Traceback (most recent call last):
    File "/tmp/pip-build-env-dwo74zbi/overlay/lib/python3.12/site-packages/setuptools/command/editable_wheel.py", line 156, in run
      self._create_wheel_file(bdist_wheel)
    File "/tmp/pip-build-env-dwo74zbi/overlay/lib/python3.12/site-packages/setuptools/command/editable_wheel.py", line 345, in _create_wheel_file
      files, mapping = self._run_build_commands(dist_name, unpacked, lib, tmp)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/tmp/pip-build-env-dwo74zbi/overlay/lib/python3.12/site-packages/setuptools/command/editable_wheel.py", line 268, in _run_build_commands
      self._run_build_subcommands()
    File "/tmp/pip-build-env-dwo74zbi/overlay/lib/python3.12/site-packages/setuptools/command/editable_wheel.py", line 295, in _run_build_subcommands
      self.run_command(name)
    File "/tmp/pip-build-env-dwo74zbi/overlay/lib/python3.12/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command
      self.distribution.run_command(command)
    File "/tmp/pip-build-env-dwo74zbi/overlay/lib/python3.12/site-packages/setuptools/dist.py", line 963, in run_command
      super().run_command(command)
    File "/tmp/pip-build-env-dwo74zbi/overlay/lib/python3.12/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
      cmd_obj.run()
    File "/tmp/pip-build-env-dwo74zbi/overlay/lib/python3.12/site-packages/setuptools/command/build_ext.py", line 88, in run
      _build_ext.run(self)
    File "/tmp/pip-build-env-dwo74zbi/overlay/lib/python3.12/site-packages/setuptools/_distutils/command/build_ext.py", line 345, in run
      self.build_extensions()
    File "/tmp/pip-build-env-dwo74zbi/overlay/lib/python3.12/site-packages/setuptools/_distutils/command/build_ext.py", line 467, in build_extensions
      self._build_extensions_serial()
    File "/tmp/pip-build-env-dwo74zbi/overlay/lib/python3.12/site-packages/setuptools/_distutils/command/build_ext.py", line 493, in _build_extensions_serial
      self.build_extension(ext)
    File "/tmp/pip-build-env-dwo74zbi/overlay/lib/python3.12/site-packages/setuptools/command/build_ext.py", line 249, in build_extension
      _build_ext.build_extension(self, ext)
    File "/tmp/pip-build-env-dwo74zbi/overlay/lib/python3.12/site-packages/setuptools/_distutils/command/build_ext.py", line 548, in build_extension
      objects = self.compiler.compile(
                ^^^^^^^^^^^^^^^^^^^^^^
    File "/tmp/pip-build-env-dwo74zbi/overlay/lib/python3.12/site-packages/setuptools/_distutils/ccompiler.py", line 600, in compile
      self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
    File "/tmp/pip-build-env-dwo74zbi/overlay/lib/python3.12/site-packages/setuptools/_distutils/unixccompiler.py", line 187, in _compile
      raise CompileError(msg)
  distutils.errors.CompileError: command '/usr/bin/gcc' failed with exit code 1
  /tmp/pip-build-env-dwo74zbi/overlay/lib/python3.12/site-packages/setuptools/_distutils/dist.py:988: _DebuggingTips: Problem in editable installation.
  !!

          ********************************************************************************
          An error happened while installing `kawaii-player` in editable mode.

          The following steps are recommended to help debug this problem:

          - Try to install the project normally, without using the editable mode.
            Does the error still persist?
            (If it does, try fixing the problem before attempting the editable mode).
          - If you are using binary extensions, make sure you have all OS-level
            dependencies installed (e.g. compilers, toolchains, binary libraries, ...).
          - Try the latest version of setuptools (maybe the error was already fixed).
          - If you (or your project dependencies) are using any setuptools extension
            or customization, make sure they support the editable mode.

          After following the steps above, if the problem still persists and
          you think this is related to how setuptools handles editable installations,
          please submit a reproducible example
          (see https://stackoverflow.com/help/minimal-reproducible-example) to:

              https://github.com/pypa/setuptools/issues

          See https://setuptools.pypa.io/en/latest/userguide/development_mode.html for details.
          ********************************************************************************

  !!
    cmd_obj.run()
  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: Failed building editable for kawaii-player Failed to build kawaii-player ERROR: Could not build wheels for kawaii-player, which is required to install pyproject.toml-based projects

kanishka-linux commented 9 months ago
pympv/mpv.c:22:10: fatal error: Python.h: No such file or directory

seems like python header files are not available in system path or not installed. try installing python-dev package.

please check DEBIAN control file in the repository and try to install all dependencies mentioned there first before starting the install process via pip. Fedora may have different names for dependencies which you will need to find out.

ezvision commented 9 months ago

I got it working, thanks.