Pim Reijersen Pim Reijersen - 2 months ago 15
Git Question

Import submodule with missing __init__

I used the following command to add an existing project as submodule to my project.

git submodule add https://github.com/...

However, the submodule root does not contain an
file. Is it possible to import the features from this submodule without making changes to it?

Contents of .gitmodules:

[submodule "name"]
path = name
url = https://github.com/name


I believe the solution is to add your submodule to your project, and than add a symbolic link into the actual package next to the submodule (or where ever it makes sense to put it)

So you'll have

  - submodule
    - package
    - setup.py
  - my_awesome_script.py
  - package (symbolic link to submodule/package)

then you can just import it through the symbolic link.

import package


Source: http://stackoverflow.com/a/15676423/5784822