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

BUG: cythonizing firedrake/cython/dmcommon.pyx fails with cython 3.0+ #3081

Closed
francesco-ballarin opened this issue Aug 29, 2023 · 3 comments
Assignees
Labels

Comments

@francesco-ballarin
Copy link
Member

Describe the bug
Cythonizing firedrake/cython/dmcommon.pyx fails with cython 3.0+

Steps to Reproduce
Upgrade cython to 3.0+ and try to install firedrake

Expected behavior
A successful cythonization

Error message

      [1/1] Cythonizing firedrake/cython/dmcommon.pyx
      warning: firedrake/cython/petschdr.pxi:8:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: firedrake/cython/petschdr.pxi:160:48: The keyword 'nogil' should appear at the end of the function signature line. Placing it before 'except' or 'noexcept' will be disallowed in a future version of Cython.
      warning: firedrake/cython/dmcommon.pyx:993:42: Buffer unpacking not optimized away.
      warning: firedrake/cython/dmcommon.pyx:993:42: Buffer unpacking not optimized away.
      warning: firedrake/cython/dmcommon.pyx:2265:4: Buffer unpacking not optimized away.
      warning: firedrake/cython/dmcommon.pyx:2265:4: Buffer unpacking not optimized away.
      warning: firedrake/cython/dmcommon.pyx:2657:4: Buffer unpacking not optimized away.
      warning: firedrake/cython/dmcommon.pyx:2657:4: Buffer unpacking not optimized away.
      warning: firedrake/cython/dmcommon.pyx:2658:4: Buffer unpacking not optimized away.
      warning: firedrake/cython/dmcommon.pyx:2658:4: Buffer unpacking not optimized away.
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
                      dim1 -= 1
                      break
              else:
                  raise RuntimeError("Found inconsistent fiat_cone and plex_cone")
          assert dim1 == 0
          return (2**dim) * eo + io
                               ^
      ------------------------------------------------------------
      
      firedrake/cython/dmcommon.pyx:989:25: Cannot assign type 'double' to 'PetscInt'
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
                      cfacets[k].global_u = v[1]
                      cfacets[k].global_v = v[0]
                  cfacets[k].local_facet = f
                  k += 1
          CHKERR(PetscFree(facet_ranks))
          qsort(cfacets, offsets[0][nranks[0]], sizeof(CommFacet), &CommFacet_cmp)
                                                                   ^
      ------------------------------------------------------------
      
      firedrake/cython/dmcommon.pyx:2374:61: Cannot assign type 'int (*)(void *, void *) except? -1 nogil' to 'int (*)(const void *, const void *) noexcept nogil'. Exception values are incompatible. Suggest adding 'noexcept' to type 'int (void *, void *) except? -1 nogil'.
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
              CHKERR(DMGetLabel(dm.dm, "ghost_region", &label))
              get_chart(dm.dm, &pStart, &pEnd)
              for p in range(nleaves):
                  CHKERR(DMLabelSetValue(label, ilocal[p], 1))
              CHKERR(DMLabelCreateIndex(label, pStart, pEnd))
          CHKERR(DMPlexSetAdjacencyUser(dm.dm, DMPlexGetAdjacency_Facet_Support, NULL))
                                               ^
      ------------------------------------------------------------
      
      firedrake/cython/dmcommon.pyx:3154:41: Cannot assign type 'int (PetscDM, PetscInt, PetscInt *, PetscInt *, void *) except? -1 nogil' to 'int (*)(PetscDM, PetscInt, PetscInt *, PetscInt *, void *) noexcept nogil'. Exception values are incompatible. Suggest adding 'noexcept' to type 'int (PetscDM, PetscInt, PetscInt *, PetscInt *, void *) except? -1 nogil'.
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
                              for vi in range(nface_vertices):
                                  if cell_closure[cell,v] == face_vertices[vi]:
                                      incident = 1
                                      break
                              if incident == 0:
                                  face_indices[nfaces] += v * 10**(1-fi)
                                              ^
      ------------------------------------------------------------
      
      firedrake/cython/dmcommon.pyx:633:40: Cannot assign type 'double' to 'PetscInt'
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
                  if plex_cone_copy[2 * j] == fiat_cone[2 * i] or plex_cone_copy[2 * j + 1] == fiat_cone[2 * i]:
                      if plex_cone_copy[2 * j] == fiat_cone[2 * i] and plex_cone_copy[2 * j + 1] == fiat_cone[2 * i + 1]:
                          # io += (2**(dim - 1 - i)) * 0
                          pass
                      elif plex_cone_copy[2 * j + 1] == fiat_cone[2 * i] and plex_cone_copy[2 * j] == fiat_cone[2 * i + 1]:
                          io += (2**(dim - 1 - i)) * 1
                          ^
      ------------------------------------------------------------
      
      firedrake/cython/dmcommon.pyx:977:20: Cannot assign type 'double' to 'PetscInt'
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/firedrake-src/setup.py", line 68, in <module>
          setup(name='firedrake',
        File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 108, in setup
          return distutils.core.setup(**attrs)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/usr/lib/python3/dist-packages/setuptools/_distutils/core.py", line 185, in setup
          return run_commands(dist)
                 ^^^^^^^^^^^^^^^^^^
        File "/usr/lib/python3/dist-packages/setuptools/_distutils/core.py", line 201, in run_commands
          dist.run_commands()
        File "/usr/lib/python3/dist-packages/setuptools/_distutils/dist.py", line 969, in run_commands
          self.run_command(cmd)
        File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 1213, in run_command
          super().run_command(command)
        File "/usr/lib/python3/dist-packages/setuptools/_distutils/dist.py", line 988, in run_command
          cmd_obj.run()
        File "/usr/lib/python3/dist-packages/setuptools/command/install.py", line 68, in run
          return orig.install.run(self)
                 ^^^^^^^^^^^^^^^^^^^^^^
        File "/usr/lib/python3/dist-packages/setuptools/_distutils/command/install.py", line 698, in run
          self.run_command('build')
        File "/usr/lib/python3/dist-packages/setuptools/_distutils/cmd.py", line 318, in run_command
          self.distribution.run_command(command)
        File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 1213, in run_command
          super().run_command(command)
        File "/usr/lib/python3/dist-packages/setuptools/_distutils/dist.py", line 988, in run_command
          cmd_obj.run()
        File "/usr/lib/python3/dist-packages/setuptools/_distutils/command/build.py", line 132, in run
          self.run_command(cmd_name)
        File "/usr/lib/python3/dist-packages/setuptools/_distutils/cmd.py", line 318, in run_command
          self.distribution.run_command(command)
        File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 1213, in run_command
          super().run_command(command)
        File "/usr/lib/python3/dist-packages/setuptools/_distutils/dist.py", line 988, in run_command
          cmd_obj.run()
        File "/usr/lib/python3/dist-packages/setuptools/_distutils/command/build_ext.py", line 346, in run
          self.build_extensions()
        File "/usr/lib/python3/dist-packages/setuptools/_distutils/command/build_ext.py", line 468, in build_extensions
          self._build_extensions_serial()
        File "/usr/lib/python3/dist-packages/setuptools/_distutils/command/build_ext.py", line 494, in _build_extensions_serial
          self.build_extension(ext)
        File "/usr/local/lib/python3.11/dist-packages/Cython/Distutils/build_ext.py", line 122, in build_extension
          new_ext = cythonize(
                    ^^^^^^^^^^
        File "/usr/local/lib/python3.11/dist-packages/Cython/Build/Dependencies.py", line 1134, in cythonize
          cythonize_one(*args)
        File "/usr/local/lib/python3.11/dist-packages/Cython/Build/Dependencies.py", line 1301, in cythonize_one
          raise CompileError(None, pyx_file)
      Cython.Compiler.Errors.CompileError: firedrake/cython/dmcommon.pyx
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

Environment:

  • cython 3.0+

Additional Info
None

@francesco-ballarin
Copy link
Member Author

This is to let you know that Google Colab will upgrade to Cython 3.0+ in the next few days, see
googlecolab/backend-info@bddc676

Once that upgrade is live I can probably try to downgrade to Cython 0.29 in my build environment, but this may come at the risk of breaking the firedrake installation in the runtime environment.

@connorjward
Copy link
Contributor

This is fixed by #3290. Was fairly straightforward.

@francesco-ballarin
Copy link
Member Author

francesco-ballarin commented Jun 19, 2024

#3546 has fixed this.

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

Successfully merging a pull request may close this issue.

3 participants