Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4ba76d6

Browse filesBrowse files
Xavier VergesByron
Xavier Verges
authored andcommitted
Do not break convention when updating sys.path
1 parent 7cd47ae commit 4ba76d6
Copy full SHA for 4ba76d6

File tree

Expand file treeCollapse file tree

2 files changed

+7
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+7
-1
lines changed

‎git/__init__.py

Copy file name to clipboardExpand all lines: git/__init__.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
def _init_externals():
2020
"""Initialize external projects by putting them into the path"""
2121
if __version__ == 'git' and 'PYOXIDIZER' not in os.environ:
22-
sys.path.insert(0, osp.join(osp.dirname(__file__), 'ext', 'gitdb'))
22+
sys.path.insert(1, osp.join(osp.dirname(__file__), 'ext', 'gitdb'))
2323

2424
try:
2525
import gitdb

‎test/test_installation.py

Copy file name to clipboardExpand all lines: test/test_installation.py
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# This module is part of GitPython and is released under
22
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
33

4+
import ast
45
import os
56
import subprocess
67
from test.lib import TestBase
@@ -27,3 +28,8 @@ def test_installation(self, rw_dir):
2728
self.assertEqual(0, result.returncode, msg=result.stderr or result.stdout or "Can't build - setup.py failed")
2829
result = subprocess.run([self.python, '-c', 'import git'], stdout=subprocess.PIPE, cwd=self.sources)
2930
self.assertEqual(0, result.returncode, msg=result.stderr or result.stdout or "Selftest failed")
31+
result = subprocess.run([self.python, '-c', 'import sys;import git; print(sys.path)'], stdout=subprocess.PIPE, cwd=self.sources)
32+
syspath = result.stdout.decode('utf-8').splitlines()[0]
33+
syspath = ast.literal_eval(syspath)
34+
self.assertEqual('', syspath[0], msg='Failed to follow the conventions for https://docs.python.org/3/library/sys.html#sys.path')
35+
self.assertTrue(syspath[1].endswith('gitdb'), msg='Failed to add gitdb to sys.path')

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.