From 119548e2a1a7aba9506bbcc807a07cbccf0b6bf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Redzy=C5=84ski?= Date: Mon, 30 Sep 2019 14:28:36 +0200 Subject: [PATCH] utils: fix_env: dont delete LD_LIBRARY_PATH from env (#2541) * utils: fix_env: dont delete LD_LIBRARY_PATH from env * utils: add related issue to comment on why there is empty LD_LIBRARY_PATH * Update dvc/utils/__init__.py Co-Authored-By: Ruslan Kuprieiev * scm: git: move LD_LIBRARY_PATH fix to Git.clone method --- dvc/scm/git/__init__.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/dvc/scm/git/__init__.py b/dvc/scm/git/__init__.py index 55bef9beb..d449d1c33 100644 --- a/dvc/scm/git/__init__.py +++ b/dvc/scm/git/__init__.py @@ -8,8 +8,8 @@ import logging from funcy import cached_property from dvc.exceptions import GitHookAlreadyExistsError -from dvc.utils.compat import str, open -from dvc.utils import fix_env, relpath +from dvc.utils.compat import str, open, cast_bytes_py2 +from dvc.utils import fix_env, relpath, is_binary from dvc.scm.base import ( Base, SCMError, @@ -64,11 +64,24 @@ class Git(Base): def clone(url, to_path, rev=None): import git + ld_key = "LD_LIBRARY_PATH" + + env = fix_env(None) + if is_binary() and ld_key not in env.keys(): + # In fix_env, we delete LD_LIBRARY_PATH key if it was empty before + # PyInstaller modified it. GitPython, in git.Repo.clone_from, uses + # env to update its own internal state. When there is no key in + # env, this value is not updated and GitPython re-uses + # LD_LIBRARY_PATH that has been set by PyInstaller. + # See [1] for more info. + # [1] https://github.com/gitpython-developers/GitPython/issues/924 + env[cast_bytes_py2(ld_key)] = "" + try: tmp_repo = git.Repo.clone_from( url, to_path, - env=fix_env(None), # needed before we can fix it in __init__ + env=env, # needed before we can fix it in __init__ no_single_branch=True, ) tmp_repo.close()