I'm using a git-submodule in my python project.
The submodule project looks like this:
-submodule_project
- __init__.py
- debug_util.py
- parsing_util
- __init__.py
- parse.py
- consts.py
parse.py imports debug_util.py.
This structure works fine as the submodule is an independent project.
My project is built like this:
-project
- __init__.py
- file1.py
- some_dir
- __init__.py
- main.py
So once I use the submodule as a git submodule in my project, the parse.py raises ImportError. This happens once the line which imports the debug_util.py is ran.
Just to clarify: main.py imports parse.py, which imports debug_util.py
Can you explain me what i'm doing wrong, and what are the available solutions to fix this?
Here's my .gitmodules file:
[submodule "submodule_project"]
path = submodule_project
url = ../submodule_project.git
Thanks in advance for all of you!
Git Submodules are very annoying to work with (at least they were last time I played around with them). I'd recommend against using submodules and simply using python's own dependency management. So your submodule_project would have its own unique name and get packaged up in releases like myparser-1.2.1, and then your main project would depend on that package from its setup.py.
Problems with git submodules (from the git documentation):
git submodule init to initialize your local configuration file, and git submodule update to fetch all the data from that project and check out the appropriate commit listed in your superprojectsubmodule update --init to repopulate it.Problems with git submodules (my own observations):
master, but it's not working correctly and now you've got merge commits that aren't upstream.update and init one level deep submodules, but what if one of your submodules also uses submodules?You also don't mention how and where you set up the submodule from the top level project. It might be more helpful if you pasted the .gitmodules file from the top level project.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With