I'm working on a project that uses whoosh. I wish to leave the source tree of whoosh in-place and be able to import from higher levels.
The location of the actual whoosh module is:
project\libs\whoosh\src\whoosh
I wish to import as:
import libs.whoosh
import libs.whoosh.index
etc.
It is simple enough to convert each subdirectory into a python module by placing a __init__.py
file that imports the next subdirectory.
The issue, however, is that whoosh's __init__.py
does not expose any of its submodules. Therefore import libs.whoosh.index
only works when whoosh is in the system path; this is a constraint, I do not wish to manipulate the system path nor install whoosh into site-packages.
Ordinarily (when whoosh is on the system path), it seems whoosh's internal imports are named fully; ie, from project\libs\whoosh\src\whoosh\index.py
:
from whoosh import __version__
from whoosh.legacy import toc_loaders
from whoosh.compat import pickle, string_type
from whoosh.fields import ensure_schema
legacy, compat and fields are all siblings to index. Importing whoosh through a chain of whoosh\src\whoosh
breaks its import scheme.
How do I go about this without:
- installing whoosh
- manipulating the system path