-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
I found it very ugly to do this tricky work.
What this package does is to check the init.py when importing EVERY package, If the file does not exist (means it may be a namespaced package), it creates the file. Many problems come with it.
- The package dir may not be writable, which will cause an
IOError, and further anImportError. This makes it failed to import the package, and very hard to debug. - It will search the dirs that is not a package. For example,
usr/lib/python2.7/config. - It produced error when importing
pycryptoin my environment. I don't know why.
I suggest to use sitedir to import namespaced packages. When calling plugin code, plugin site dirs will be inserted into PYTHONPATH in dispatch module, we can just add the two dirs to sitedir in plugin __init__.py. Python will look for the .pth files in site dirs and make it possible to import namespaced packages.
Example:
import sys
import site
site.addsitedir(sys.path[0])
site.addsitedir(sys.path[1])
Metadata
Metadata
Assignees
Labels
No labels