I assume that this question has been addressed somewhere, but I have spent an inordinate amount of time looking around for the answer including digging into the source code a bi
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 = 1
END MODULE test
MODULE test2
USE test
INTEGER, PARAMETER :: b = 2
END MODULE test2
simply add an f2py directive in test2 to show f2py how to define test2.a
:
MODULE test
INTEGER, PARAMETER :: a = 1
END MODULE test
MODULE test2
USE test
!f2py integer, parameter :: a ! THIS EXPOSES `a` in `test2`
INTEGER, PARAMETER :: b = 2
END MODULE test2
Importing from the resulting test.so
correctly exposes test2.a
:
In [1]: import test
In [2]: print test.test.a
1
In [3]: print test.test.b
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
.../test_solution/ in ()
----> 1 print test.test.b
AttributeError: b
In [4]: print test.test2.a
1
In [5]: print test.test2.b
2