Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit00aee49

Browse files
committed
Never modify sys.path
This removes the logic that, under some (most) circumstances whennot using a version from PyPI, would insert the location of thegitdb git-submodule near the front of sys.path.(As noted in#1717, the specific way this was being done was notcausing the git-submodule's version of gitdb to actually be used.But it was still modifying sys.path, which this now prevents.)The installation test, which had verified the insertion intosys.path, is modified accordingly, except that for now the checkthat the very first sys.path entry is undisturbed is kept in place.
1 parentdf777fd commit00aee49

File tree

2 files changed

+22
-31
lines changed

2 files changed

+22
-31
lines changed

‎git/__init__.py

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,38 +6,11 @@
66
# flake8: noqa
77
# @PydevCodeAnalysisIgnore
88
fromgit.excimport*# @NoMove @IgnorePep8
9-
importos
10-
importos.pathasosp
11-
importsys
12-
139
fromtypingimportList,Optional,Sequence,Tuple,Union,TYPE_CHECKING
1410
fromgit.typesimportPathLike
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"notinos.environ:
23-
sys.path.insert(1,osp.join(osp.dirname(__file__),"ext","gitdb"))
24-
25-
try:
26-
importgitdb
27-
exceptImportErrorase:
28-
raiseImportError("'gitdb' could not be found in your PYTHONPATH")frome
29-
# END verify import
30-
31-
32-
# } END initialization
33-
34-
35-
#################
36-
_init_externals()
37-
#################
38-
39-
# { Imports
40-
4114
fromgitdb.utilimportto_hex_sha
4215

4316
try:
@@ -62,8 +35,6 @@ def _init_externals() -> None:
6235
exceptGitErroras_exc:
6336
raiseImportError("%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__= [

‎test/test_installation.py

Lines 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
deftest_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.stderrorresult.stdoutor"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.stderrorresult.stdoutor"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.stderrorresult.stdoutor"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)

[8]ページ先頭

©2009-2025 Movatter.jp