f2py: Exposing parameters from "used" modules f2py: Exposing parameters from "used" modules python python

f2py: Exposing parameters from "used" modules


I have found a temporary solution to this problem, but it is not optimal. I will continue to work through the f2py source so that I can better understand it and fix the problem within the code itself. Until then, this is my solution which was inspired by chatcannon's comment to the issue I posted to nympy's github.

There are several ways to approach this problem from a temporary standpoint including a couple of ways of modifying the .pyf files. I don't want to have to modify the .pyf files as it becomes very cumbersome as part of a larger package. To avoid this, I added f2py directives to my f90 source.

Taking the example from my original question:

MODULE test    INTEGER, PARAMETER :: a = 1END MODULE testMODULE test2    USE test    INTEGER, PARAMETER :: b = 2END MODULE test2

simply add an f2py directive in test2 to show f2py how to define test2.a:

MODULE test    INTEGER, PARAMETER :: a = 1END MODULE testMODULE test2    USE test    !f2py integer, parameter :: a  ! THIS EXPOSES `a` in `test2`    INTEGER, PARAMETER :: b = 2END MODULE test2

Importing from the resulting test.so correctly exposes test2.a:

In [1]: import testIn [2]: print test.test.a1In [3]: print test.test.b---------------------------------------------------------------------------AttributeError                            Traceback (most recent call last).../test_solution/<ipython-input-3-798b14f59815> in <module>()----> 1 print test.test.bAttributeError: bIn [4]: print test.test2.a1In [5]: print test.test2.b2