autowrap icon indicating copy to clipboard operation
autowrap copied to clipboard

Handling of wrap-ignore with derived classes is wonky

Open poshul opened this issue 5 months ago • 8 comments

wrap-ignore on SpectrumAccessTransforming breaks building of it's derived classes, this is wrong. There's pretty clearly a bug here in autowrap's handling of derived classes where the parent is wrap-ignored, but it's not a regression from previous behavior since earlier autowrap seems to have just ignored the annotation.

poshul avatar Jul 11 '25 08:07 poshul

Btw: What is the error? I still have not seen a log of what is actually wrong.

jpfeuffer avatar Jul 11 '25 09:07 jpfeuffer

Error compiling Cython file:
------------------------------------------------------------
...
from ._pyopenms_19 cimport MRMRTNormalizer
from ._pyopenms_19 cimport Sample
from ._pyopenms_19 cimport ModificationsDB
from ._pyopenms_20 cimport MSSpectrum
from ._pyopenms_20 cimport Acquisition
from ._pyopenms_20 cimport SpectrumAccessTransforming
^
------------------------------------------------------------

pyopenms/_pyopenms_21.pxd:1147:0: 'pyopenms/_pyopenms_20/SpectrumAccessTransforming.pxd' not found

Error compiling Cython file:
------------------------------------------------------------
...
from ._pyopenms_19 cimport MRMRTNormalizer
from ._pyopenms_19 cimport Sample
from ._pyopenms_19 cimport ModificationsDB
from ._pyopenms_20 cimport MSSpectrum
from ._pyopenms_20 cimport Acquisition
from ._pyopenms_20 cimport SpectrumAccessTransforming
^
------------------------------------------------------------

etc...

pyopenms/_pyopenms_21.pxd:1147:0: 'pyopenms/_pyopenms_20/SpectrumAccessTransforming.pxd' not found
Created all 32 pyopenms.cpps

poshul avatar Jul 11 '25 09:07 poshul

Hmmm the whole file is not there? IS it because the file would be empty with the only class in the file being ignored? This is one guess.

jpfeuffer avatar Jul 11 '25 09:07 jpfeuffer

the generated pxd file contains:

from SpectrumAccessTransforming cimport SpectrumAccessTransforming as _SpectrumAccessTransforming

...
from ._pyopenms_20 cimport SpectrumAccessTransforming

...
cdef class SpectrumAccessQuadMZTransforming:
    """
    Cython implementation of _SpectrumAccessQuadMZTransforming

    Original C++ documentation is available `here <http://www.openms.de/current_doxygen/html/classOpenMS_1_1SpectrumAccessQuadMZTransforming.html>`_
      -- Inherits from ['SpectrumAccessTransforming']
    """
    cdef shared_ptr[_SpectrumAccessQuadMZTransforming] inst
 

poshul avatar Jul 11 '25 09:07 poshul

Hmmm the whole file is not there? IS it because the file would be empty with the only class in the file being ignored? This is one guess.

I'm confused about the error, because I'm not sure why it should be looking for a specific SpectrumAccessTransforming file at that point in the build, all of the stuff from the original pxds is already put into the _pyopen_XX.pxd. And as far as I can tell none of the other cimports that are properly in the _pyopenms_XX.pxds look for the original pxd file.

poshul avatar Jul 11 '25 10:07 poshul

Hmmm the whole file is not there? IS it because the file would be empty with the only class in the file being ignored? This is one guess.

So, even if I wrap some SpectrumAccessTransforming functions (so that the class shouldn't be empty) I get the same error. adding the annotation # no-pxd-import fixes the import problem, and properly get the derived classes their imports.

So question:

  • What is the no-pxd-import annotation?
  • is ABSTRACT class an annotation? I see it several places, but it's not actually getting parsed as far as I can tell.

poshul avatar Jul 11 '25 11:07 poshul

https://github.com/OpenMS/autowrap/blob/92598a8460c1aba57c2d7812b184489eb26c498e/autowrap/CodeGenerator.py#L1952-L1955

So it looks exactly like what we need. Should be better documented if it's not in the list of annotations in the docs.

jpfeuffer avatar Jul 11 '25 15:07 jpfeuffer

Abstract class is just the reason for ignoring. it has no meaning.

jpfeuffer avatar Jul 11 '25 15:07 jpfeuffer