Never modify sys.path by EliahKagan · Pull Request #1720 · gitpython-developers/GitPython · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions README.md
29 changes: 0 additions & 29 deletions git/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,11 @@
# flake8: noqa
# @PydevCodeAnalysisIgnore
from git.exc import * # @NoMove @IgnorePep8
import os
import os.path as osp
import sys

from typing import List, Optional, Sequence, Tuple, Union, TYPE_CHECKING
from git.types import PathLike

__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

from gitdb.util import to_hex_sha

try:
Expand All @@ -62,8 +35,6 @@ def _init_externals() -> None:
except GitError as _exc:
raise ImportError("%s: %s" % (_exc.__class__.__name__, _exc)) from _exc

# } END imports

# __all__ must be statically defined by py.typed support
# __all__ = [name for name, obj in locals().items() if not (name.startswith("_") or inspect.ismodule(obj))]
__all__ = [
Expand Down
24 changes: 22 additions & 2 deletions test/test_installation.py