Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build fails with latest Cython (3.0.0) #233

Closed
hofaflo opened this issue Jul 18, 2023 · 1 comment
Closed

Build fails with latest Cython (3.0.0) #233

hofaflo opened this issue Jul 18, 2023 · 1 comment

Comments

@hofaflo
Copy link
Contributor

hofaflo commented Jul 18, 2023

With yesterday's Cython release, building pyedflib seems to fail. Executing pip install -e . (Ubuntu 22.04.2, Python 3.10.9) produces the output shown below. Capping Cython to "cython<3.0.0" in pyproject.toml makes it work again, but I don't know if that's the best course of action :D

Obtaining file:///home/florian/coding/pyedflib
  Installing build dependencies ... done
  Checking if build backend supports build_editable ... done
  Getting requirements to build editable ... error
  error: subprocess-exited-with-error
  
  × Getting requirements to build editable did not run successfully.
  │ exit code: 1
  ╰─> [227 lines of output]
      /tmp/pip-build-env-i1rg6twi/overlay/lib/python3.10/site-packages/Cython/Compiler/Main.py:381: FutureWarning: Cython directive 'language_level' not set, using '3str' for now (Py3). This has changed from earlier releases! File: /home/florian/coding/pyedflib/pyedflib/_extensions/_pyedflib.pyx
        tree = Parsing.p_module(s, pxd, full_module_name)
      warning: pyedflib/_extensions/edf.pxi:27: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
      [... lots of repetitions ...]
      warning: pyedflib/_extensions/edf.pxi:88: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:
      ------------------------------------------------------------
      ...
      
      #from c_edf cimport *
      import locale
      import os
      import warnings
      cimport c_edf
              ^
      ------------------------------------------------------------
      
      pyedflib/_extensions/_pyedflib.pyx:24:8: 'c_edf.pxd' not found
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
          needed according the montage and filter settings, then display the data.
      
          """
      
      
          cdef c_edf.edf_hdr_struct hdr
               ^
      ------------------------------------------------------------
      
      pyedflib/_extensions/_pyedflib.pyx:136:9: 'edf_hdr_struct' is not a type identifier
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
      
      cpdef int set_technician(int handle, char *technician):
          return c_edf.edf_set_technician(handle, technician)
      
      cdef class EdfAnnotation:
          cdef c_edf.edf_annotation_struct annotation
               ^
      ------------------------------------------------------------
      
      pyedflib/_extensions/_pyedflib.pyx:449:9: 'edf_annotation_struct' is not a type identifier
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
              self.file_name = file_name
      
              return self.check_open_ok(result)
      
          def read_annotation(self):
              cdef c_edf.edf_annotation_struct annot
                   ^
      ------------------------------------------------------------
      
      pyedflib/_extensions/_pyedflib.pyx:211:13: 'edf_annotation_struct' is not a type identifier
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
                  return output_buf.value
              else:
                  output_buf_size = needed
      
      def lib_version():
          return c_edf.edflib_version()
                      ^
      ------------------------------------------------------------
      
      pyedflib/_extensions/_pyedflib.pyx:117:16: cimported module has no attribute 'edflib_version'
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
                      raise e
      
      
          def __dealloc__(self):
              if self.hdr.handle >= 0:
                  c_edf.edfclose_file(self.hdr.handle)
                       ^
      ------------------------------------------------------------
      
      pyedflib/_extensions/_pyedflib.pyx:170:17: cimported module has no attribute 'edfclose_file'
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
          def open(self, file_name, annotations_mode=EDFLIB_READ_ALL_ANNOTATIONS, check_file_size=EDFLIB_CHECK_FILE_SIZE):
              """
              open(file_name, annotations_mode, check_file_size)
              """
              file_name_str = file_name.encode('utf_8','strict')
              result = c_edf.edfopen_file_readonly(file_name_str, &self.hdr, annotations_mode, check_file_size)
                            ^
      ------------------------------------------------------------
      
      pyedflib/_extensions/_pyedflib.pyx:204:22: cimported module has no attribute 'edfopen_file_readonly'
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
          def open(self, file_name, annotations_mode=EDFLIB_READ_ALL_ANNOTATIONS, check_file_size=EDFLIB_CHECK_FILE_SIZE):
              """
              open(file_name, annotations_mode, check_file_size)
              """
              file_name_str = file_name.encode('utf_8','strict')
              result = c_edf.edfopen_file_readonly(file_name_str, &self.hdr, annotations_mode, check_file_size)
                            ^
      ------------------------------------------------------------
      
      pyedflib/_extensions/_pyedflib.pyx:204:22: Compiler crash in AnalyseExpressionsTransform
      
      ModuleNode.body = StatListNode(_pyedflib.pyx:5:0)
      StatListNode.stats[20] = StatListNode(_pyedflib.pyx:119:5)
      StatListNode.stats[0] = CClassDefNode(_pyedflib.pyx:119:5,
          as_name = 'CyEdfReader',
          class_name = 'CyEdfReader',
          doc = '\n    This provides a simple interface to read EDF, EDF+, and probably is ok with\n    BDF and BDF+ files\n    Note that edflib.c is encapsulated so there is no direct access to the file\n    from here unless I add a raw interface or something\n\n    EDF/BDF+ files are arranged into N signals sampled at rate Fs. The data is actually stored in chunks called    "datarecords" which have a file specific size.\n\n    A typical way to use this to read an EEG file would be to choose a certain\n    number of seconds per page to display. Then figureout how many data records\n    that is. Then read in that many data records at a time. Transform the data as\n    needed according the montage and filter settings, then display the data.\n\n    ',
          module_name = '',
          punycode_class_name = 'CyEdfReader',
          visibility = 'private')
      CClassDefNode.body = StatListNode(_pyedflib.pyx:120:4)
      StatListNode.stats[6] = DefNode(_pyedflib.pyx:199:4,
          doc = '\n        open(file_name, annotations_mode, check_file_size)\n        ',
          is_cyfunction = True,
          modifiers = [...]/0,
          name = 'open',
          np_args_idx = [...]/0,
          num_required_args = 2,
          outer_attrs = [...]/2,
          py_wrapper_required = True,
          reqd_kw_flags_cname = '0',
          used = True)
      File 'ExprNodes.py', line 5844, in infer_type: SimpleCallNode(_pyedflib.pyx:204:44,
          result_is_used = True,
          use_managed_ref = True)
      File 'ExprNodes.py', line 7288, in infer_type: AttributeNode(_pyedflib.pyx:204:22,
          attribute = 'edfopen_file_readonly',
          is_attribute = 1,
          needs_none_check = True,
          result_is_used = True,
          use_managed_ref = True)
      
      Compiler crash traceback from this point on:
        File "/tmp/pip-build-env-i1rg6twi/overlay/lib/python3.10/site-packages/Cython/Compiler/ExprNodes.py", line 7288, in infer_type
          if node.entry.type and node.entry.type.is_cfunction:
      AttributeError: 'NoneType' object has no attribute 'type'
      Compiling pyedflib/_extensions/_pyedflib.pyx because it changed.
      [1/1] Cythonizing pyedflib/_extensions/_pyedflib.pyx
      Traceback (most recent call last):
        File "/home/florian/coding/pyedflib/.venv310/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/home/florian/coding/pyedflib/.venv310/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/home/florian/coding/pyedflib/.venv310/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 132, in get_requires_for_build_editable
          return hook(config_settings)
        File "/tmp/pip-build-env-i1rg6twi/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 450, in get_requires_for_build_editable
          return self.get_requires_for_build_wheel(config_settings)
        File "/tmp/pip-build-env-i1rg6twi/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 341, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=['wheel'])
        File "/tmp/pip-build-env-i1rg6twi/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 323, in _get_build_requires
          self.run_setup()
        File "/tmp/pip-build-env-i1rg6twi/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 338, in run_setup
          exec(code, locals())
        File "<string>", line 265, in <module>
        File "/tmp/pip-build-env-i1rg6twi/overlay/lib/python3.10/site-packages/Cython/Build/Dependencies.py", line 1134, in cythonize
          cythonize_one(*args)
        File "/tmp/pip-build-env-i1rg6twi/overlay/lib/python3.10/site-packages/Cython/Build/Dependencies.py", line 1301, in cythonize_one
          raise CompileError(None, pyx_file)
      Cython.Compiler.Errors.CompileError: pyedflib/_extensions/_pyedflib.pyx
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build editable did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.
@hofaflo
Copy link
Contributor Author

hofaflo commented Jul 24, 2023

Resolved in #234, thanks @skjerns!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant