Skip to content

Commit

Permalink
Remove the gitdb and smmap Git repo submodules
Browse files Browse the repository at this point in the history
This removes the gitdb Git submodule, and thus also *its* submodule
smmap, from the GitPython repository. It also removes the code that
was in place to put git/ext/ into the PYTHONPATH, substantially
simplifying the git package's top-level __init__.py, and slightly
simplifying a script and the CI workflows.

Instead of using Git submodules, the PyPI packages for the gitdb
and smmap dependencies should be used instead, which now happens
automatically. For the occasional cases where having them as Git
submodules was useful, they can be installed with pip from other
sources: GitHub or other remote repository URLs, or local
directories. Installing them editably (with -e / --editable) from a
local directory should achieve the full effect of being able to
have local changes to them reflected immediately in the operation
of GitPython during local development.

Thus this does not remove or diminish GitPython's dependence on
gitdb and smmap, it just no longer obtains them as Git submodules.
Using them from PyPI allows GitPython to be developed and tested
against the versions of them that it uses in production, obtaining
its dependencies how they are usually obtained in production.

This pertains only to Git submodules for GitPython's dependencies.
It does not change the organization of Python packages/modules: the
top-level git package/module continues to have all the same
subpackages/submodules it did before, and this holds recursively.

(This also does not remove, and should in no way affect,
GitPython's ability to *work with* Git submodules, which is
independent of whether GitPython's own repository has them.)
  • Loading branch information
EliahKagan committed Oct 20, 2023
1 parent 44102f3 commit b3d7793
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 30 deletions.
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

21 changes: 0 additions & 21 deletions git/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,6 @@

__version__ = "git"


# { Initialization
def _init_externals() -> None:
"""Initialize external projects by putting them into the path"""
if __version__ == "git" and "PYOXIDIZER" not in os.environ:
sys.path.insert(1, osp.join(osp.dirname(__file__), "ext", "gitdb"))

try:
import gitdb
except ImportError as e:
raise ImportError("'gitdb' could not be found in your PYTHONPATH") from e
# END verify import


# } END initialization


#################
_init_externals()
#################

# { Imports

try:
Expand Down
1 change: 0 additions & 1 deletion git/ext/gitdb
Submodule gitdb deleted from 8ec239
3 changes: 0 additions & 3 deletions init-tests-after-clone.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ git reset --hard HEAD~1
# Point the master branch where we started, so we test the correct code.
git reset --hard __testing_point__

# The tests need submodules, including a submodule with a submodule.
git submodule update --init --recursive

# The tests need some version tags. Try to get them even in forks. This fetches
# other objects too. So, locally, we always do it, for a consistent experience.
if ! ci || no_version_tags; then
Expand Down
24 changes: 22 additions & 2 deletions test/test_installation.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def setUp_venv(self, rw_dir):
@with_rw_directory
def test_installation(self, rw_dir):
self.setUp_venv(rw_dir)

result = subprocess.run(
[self.pip, "install", "."],
stdout=subprocess.PIPE,
Expand All @@ -35,12 +36,32 @@ def test_installation(self, rw_dir):
result.returncode,
msg=result.stderr or result.stdout or "Can't install project",
)
result = subprocess.run([self.python, "-c", "import git"], stdout=subprocess.PIPE, cwd=self.sources)

result = subprocess.run(
[self.python, "-c", "import git"],
stdout=subprocess.PIPE,
cwd=self.sources,
)
self.assertEqual(
0,
result.returncode,
msg=result.stderr or result.stdout or "Selftest failed",
)

result = subprocess.run(
[self.python, "-c", "import gitdb; import smmap"],
stdout=subprocess.PIPE,
cwd=self.sources,
)
self.assertEqual(
0,
result.returncode,
msg=result.stderr or result.stdout or "Dependencies not installed",
)

# Even IF gitdb or any other dependency is supplied during development
# by inserting its location into PYTHONPATH or otherwise patched into
# sys.path, make sure it is not wrongly inserted as the *first* entry.
result = subprocess.run(
[self.python, "-c", "import sys;import git; print(sys.path)"],
stdout=subprocess.PIPE,
Expand All @@ -53,4 +74,3 @@ def test_installation(self, rw_dir):
syspath[0],
msg="Failed to follow the conventions for https://docs.python.org/3/library/sys.html#sys.path",
)
self.assertTrue(syspath[1].endswith("gitdb"), msg="Failed to add gitdb to sys.path")

0 comments on commit b3d7793

Please sign in to comment.