pyproj icon indicating copy to clipboard operation
pyproj copied to clipboard

A question about pyproj/_datadir.pyx

Open Frmcio opened this issue 4 months ago • 2 comments

performance hint: pyproj/_datadir.pyx:80:5: Exception check on 'pyproj_log_function' will always require the GIL to be acquired. Possible solutions: 1. Declare 'pyproj_log_function' as 'noexcept' if you control the definition and you're sure you don't want the function to raise exceptions. 2. Use an 'int' return type on 'pyproj_log_function' to allow an error code to be returned.

  Error compiling Cython file:
  ------------------------------------------------------------
  ...
  
  cdef void pyproj_context_initialize(PJ_CONTEXT* context) except *:
      """
      Setup the context for pyproj
      """
      proj_log_func(context, NULL, pyproj_log_function)
                                   ^
  ------------------------------------------------------------
  
  pyproj/_datadir.pyx:129:33: Cannot assign type 'void (void *, int, const char *) except * nogil' to 'PJ_LOG_FUNCTION' (alias of 'void (*)(void *, int, const char *) noexcept'). Exception values are incompatible. Suggest adding 'noexcept' to the type of 'pyproj_log_function'.

This is my report when I install the sat-bundleadjust. But I find the error. I check the _datadir.pyx and find the 'pyproj_log_function' has been declared as 'noexcept'. WHY the error compiling occur.

Frmcio avatar Apr 13 '24 08:04 Frmcio

The signature of the function is determined by PROJ:

https://github.com/OSGeo/PROJ/blob/356e255022cea47bf242bc9e6345a1e87ab1031d/src/proj.h#L383

https://github.com/pyproj4/pyproj/blob/24a7b7f2f05839761c3a6c23de860948a1a9d0f1/pyproj/proj.pxi#L29

I remember trying to make it use noexcept and moving on when it didn't work with some things I tried. Feel free to tinker and see if you can get it to work a different way.

snowman2 avatar Apr 13 '24 13:04 snowman2