mirror of https://github.com/pypa/pip
Address issue #1130: make pip ignore GIT_DIR and GIT_WORK_TREE.
This commit is contained in:
parent
035a2a720b
commit
3498b19a8b
|
@ -0,0 +1,2 @@
|
|||
Allow pip to work if the ``GIT_DIR`` and ``GIT_WORK_TREE`` environment
|
||||
variables are set.
|
|
@ -627,7 +627,14 @@ def unpack_file(filename, location, content_type, link):
|
|||
def call_subprocess(cmd, show_stdout=True, cwd=None,
|
||||
on_returncode='raise',
|
||||
command_desc=None,
|
||||
extra_environ=None, spinner=None):
|
||||
extra_environ=None, unset_environ=None, spinner=None):
|
||||
"""
|
||||
Args:
|
||||
unset_environ: an iterable of environment variable names to unset
|
||||
prior to calling subprocess.Popen().
|
||||
"""
|
||||
if unset_environ is None:
|
||||
unset_environ = []
|
||||
# This function's handling of subprocess output is confusing and I
|
||||
# previously broke it terribly, so as penance I will write a long comment
|
||||
# explaining things.
|
||||
|
@ -664,6 +671,8 @@ def call_subprocess(cmd, show_stdout=True, cwd=None,
|
|||
env = os.environ.copy()
|
||||
if extra_environ:
|
||||
env.update(extra_environ)
|
||||
for name in unset_environ:
|
||||
env.pop(name, None)
|
||||
try:
|
||||
proc = subprocess.Popen(
|
||||
cmd, stderr=subprocess.STDOUT, stdin=None, stdout=stdout,
|
||||
|
|
|
@ -166,6 +166,8 @@ class VersionControl(object):
|
|||
dirname = ''
|
||||
# List of supported schemes for this Version Control
|
||||
schemes = () # type: Tuple[str, ...]
|
||||
# Iterable of environment variable names to pass to call_subprocess().
|
||||
unset_environ = ()
|
||||
default_arg_rev = None # type: Optional[str]
|
||||
|
||||
def __init__(self, url=None, *args, **kwargs):
|
||||
|
@ -422,7 +424,8 @@ class VersionControl(object):
|
|||
return call_subprocess(cmd, show_stdout, cwd,
|
||||
on_returncode,
|
||||
command_desc, extra_environ,
|
||||
spinner)
|
||||
unset_environ=self.unset_environ,
|
||||
spinner=spinner)
|
||||
except OSError as e:
|
||||
# errno.ENOENT = no such file or directory
|
||||
# In other words, the VCS executable isn't available
|
||||
|
|
|
@ -27,6 +27,9 @@ class Git(VersionControl):
|
|||
schemes = (
|
||||
'git', 'git+http', 'git+https', 'git+ssh', 'git+git', 'git+file',
|
||||
)
|
||||
# Prevent the user's environment variables from interfering with pip:
|
||||
# https://github.com/pypa/pip/issues/1130
|
||||
unset_environ = ('GIT_DIR', 'GIT_WORK_TREE')
|
||||
default_arg_rev = 'origin/HEAD'
|
||||
|
||||
def __init__(self, url=None, *args, **kwargs):
|
||||
|
|
Loading…
Reference in New Issue