GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Never modify sys.path · EliahKagan/GitPython@00aee49

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • git
    • __init__.py
  • test
    • test_installation.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎git/__init__.py‎

Copy file name to clipboardExpand all lines: git/__init__.py
-29Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,38 +6,11 @@
66
# flake8: noqa
77
# @PydevCodeAnalysisIgnore
88
from git.exc import * # @NoMove @IgnorePep8
9-
import os
10-
import os.path as osp
11-
import sys
12-
139
from typing import List, Optional, Sequence, Tuple, Union, TYPE_CHECKING
1410
from git.types import PathLike
1511

1612
__version__ = "git"
1713

18-
19-
# { Initialization
20-
def _init_externals() -> None:
21-
"""Initialize external projects by putting them into the path"""
22-
if __version__ == "git" and "PYOXIDIZER" not in os.environ:
23-
sys.path.insert(1, osp.join(osp.dirname(__file__), "ext", "gitdb"))
24-
25-
try:
26-
import gitdb
27-
except ImportError as e:
28-
raise ImportError("'gitdb' could not be found in your PYTHONPATH") from e
29-
# END verify import
30-
31-
32-
# } END initialization
33-
34-
35-
#################
36-
_init_externals()
37-
#################
38-
39-
# { Imports
40-
4114
from gitdb.util import to_hex_sha
4215

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

65-
# } END imports
66-
6738
# __all__ must be statically defined by py.typed support
6839
# __all__ = [name for name, obj in locals().items() if not (name.startswith("_") or inspect.ismodule(obj))]
6940
__all__ = [
Collapse file

‎test/test_installation.py‎

Copy file name to clipboardExpand all lines: test/test_installation.py
+22-2Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def setUp_venv(self, rw_dir):
2525
@with_rw_directory
2626
def test_installation(self, rw_dir):
2727
self.setUp_venv(rw_dir)
28+
2829
result = subprocess.run(
2930
[self.pip, "install", "."],
3031
stdout=subprocess.PIPE,
@@ -35,12 +36,32 @@ def test_installation(self, rw_dir):
3536
result.returncode,
3637
msg=result.stderr or result.stdout or "Can't install project",
3738
)
38-
result = subprocess.run([self.python, "-c", "import git"], stdout=subprocess.PIPE, cwd=self.sources)
39+
40+
result = subprocess.run(
41+
[self.python, "-c", "import git"],
42+
stdout=subprocess.PIPE,
43+
cwd=self.sources,
44+
)
3945
self.assertEqual(
4046
0,
4147
result.returncode,
4248
msg=result.stderr or result.stdout or "Selftest failed",
4349
)
50+
51+
result = subprocess.run(
52+
[self.python, "-c", "import gitdb; import smmap"],
53+
stdout=subprocess.PIPE,
54+
cwd=self.sources,
55+
)
56+
self.assertEqual(
57+
0,
58+
result.returncode,
59+
msg=result.stderr or result.stdout or "Dependencies not installed",
60+
)
61+
62+
# Even IF gitdb or any other dependency is supplied during development
63+
# by inserting its location into PYTHONPATH or otherwise patched into
64+
# sys.path, make sure it is not wrongly inserted as the *first* entry.
4465
result = subprocess.run(
4566
[self.python, "-c", "import sys;import git; print(sys.path)"],
4667
stdout=subprocess.PIPE,
@@ -53,4 +74,3 @@ def test_installation(self, rw_dir):
5374
syspath[0],
5475
msg="Failed to follow the conventions for https://docs.python.org/3/library/sys.html#sys.path",
5576
)
56-
self.assertTrue(syspath[1].endswith("gitdb"), msg="Failed to add gitdb to sys.path")

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.