Skip to content

KuYaki/gitmodules_example_a

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gitmodules_example_a

This is the first example for the gitmodules project.

Dependencies

This project is assumed to be used with the gitmodules dependency

pip install gitmodules

Also gitmodules_example_b and gitmodules_example_c should be updated as well

git submodule update --recursive --init

Description

gitmodules_example_c can be executed as a main script but if you will try to import it in any other project as a git submodule you will be forced to append its path to the sys.path:

# in b.py from gitmodules_example_b
import sys
sys.path.append("gitmodules_example_c")
from gitmodules_example_c import c

The same problem will occurs if you will try to import gitmodules_example_b into any other project. But even if you will append it via sys.path.append problem will not be solved for gitmodules_example_c:

# in a.py from gitmodules_example_a
import sys
sys.path.append("gitmodules_example_b")
from gitmodules_example_b import b

And you will be forced to append all the submodules for b as well:

# in a.py from gitmodules_example_a
import sys
import os
sys.path.append("gitmodules_example_b")
sys.path.append(os.path.join("gitmodules_example_b", "gitmodules_example_c"))
from gitmodules_example_b import b

Or you can simply use gitmodules instead:

# in a.py from gitmodules_example_a
import gitmodules
from gitmodules_example_b import b

This method allows you to import git submodule as an ordinary module or as a standard library. So that if you will decide to upload your git submodules to PyPi you will not be forced to change your scripts.

About

This is the first example for the gitmodules project

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages