local and global import of bob modules not possible
Created by: siebenkopf
I am afraid to say that the namespace issue inside bob still seems to be unsolved, at least partially. I just want to verify with you guys that you can reproduce the following issue.
Assume that you have a script example.py
like follows:
import bob.io.base
def main():
# use bob.io.base
h = bob.io.base.HDF5File("xxx.hdf5", 'w')
# import another bob module
import bob.ip.base
if __name__ == '__main__':
main()
Now, when I try to execute that script (given that I have the according bob modules installed in my python path):
$ python example.py
...
UnboundLocalError: local variable 'bob' referenced before assignment
I have traced the issue down to the fact that I am import
ing one of the bob
modules after I use another one. When I import both in the beginning of the file, or before I use them the first time, everything is fine. Even if I do a relative import later (e.g., from bob.ip.base import LBP
) it works.
I am not sure if this is intended behavior, or if other modules have the same issue. Maybe it has something to do with the fact that the site
package hack, which we have introduced earlier into bob.buildout
to make it work with the old namespace issue, is still in the code?