I have a git repo, core
, which I would like to use as a submodule within other git repos, e.g. example
. core
contains python files within which are classes that I would like to import into example
. I have a set up which is working, however, now if I try to use core
as a standalone repository I get an import error.
The file structure of core
looks like:
core
__init__.py
myfile.py
myotherfile.py
mynotebook.ipynb
Where myfile.py
looks like:
from .myotherfile import MyOtherFileClass
class MyFileClass():
def __init__():
mofc = MyOtherFileClass()
And myotherfile.py
looks like:
class MyOtherFileClass():
def __init__():
#dostuff
The file structure of example
looks like:
example
> core (submodule)
examplenotebook.ipynb
Where examplenotebook.ipynb
contains:
from core.myfile import MyFileClass
mfc = MyFileClass()
The above all seems to be working ok using the github submodule feature.
mynotebook.ipynb
looks like:
from myfile import MyFileClass
This returns an error at from .myotherfile import MyOtherFileClass
within myfile
. The error is ImportError: attempted relative import with no known parent package
.
Have I set this up in the right way? Is this an acceptable way to work with submodules?