Tell f2py to skip a function

Question:

I am using f2py to compile a Fortran library such that I can import it in python so that I can easily create unit tests. However, one of the functions in the module uses an allocatable array to read a matrix from a file (the size of the matrix is not know until it is read). Unfortunately, f2py does not support allocatable arrays so compilation fails.

Can I tell f2py to ignore only the problematic function using a comment in the module?

I know it is possible to skip a list of functions specified at compile time, but I was hoping there was a solution that could be implemented in the source file, like the !f2py comments that modify how parameters are treated by f2py.

Asked By: Paul Wintz

||

Answers:

In the f2py docs here it says that you can skip a function by doing this:

  f2py -h <filename.pyf> <options> <fortran files>   
      [[ only: <fortran functions>  : ]                
       [ skip: <fortran functions>  : ]]...            
      [<fortran files> ...]

where skip:"" can be used to skip any function you dont want to execute.

Answered By: hypadr1v3

There seems to be no (documented) way to add the only: and skip: options to distutils.

Answered By: user3622450
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.