diff --git a/dvc/scm.py b/dvc/scm.py index 72dc2185c..eadaf9943 100644 --- a/dvc/scm.py +++ b/dvc/scm.py @@ -2,6 +2,7 @@ import os from dvc.exceptions import DvcException from dvc.logger import Logger +from dvc.utils import fix_env class SCMError(DvcException): @@ -87,6 +88,12 @@ class Git(Base): except InvalidGitRepositoryError: raise SCMError('{} is not a git repository'.format(root_dir)) + # NOTE: fixing LD_LIBRARY_PATH for binary built by PyInstaller. + # http://pyinstaller.readthedocs.io/en/stable/runtime-information.html + env = fix_env(None) + lp = env.get('LD_LIBRARY_PATH', None) + self.repo.git.update_environment(LD_LIBRARY_PATH=lp) + @staticmethod def is_repo(root_dir): git_dir = os.path.join(root_dir, Git.GIT_DIR) diff --git a/dvc/utils.py b/dvc/utils.py index 10aa15716..822f93d98 100644 --- a/dvc/utils.py +++ b/dvc/utils.py @@ -2,6 +2,7 @@ Helpers for other modules. """ import os +import sys import math import json import shutil @@ -144,11 +145,14 @@ def fix_env(env): else: env = env.copy() - lp_key = 'LD_LIBRARY_PATH' - lp_orig = env.get(lp_key + '_ORIG') - if lp_orig is not None: - env[lp_key] = lp_orig - else: - env.pop(lp_key, None) + # NOTE: Check if we are in a bundle + # https://pythonhosted.org/PyInstaller/runtime-information.html + if getattr(sys, 'frozen', False): + lp_key = 'LD_LIBRARY_PATH' + lp_orig = env.get(lp_key + '_ORIG', None) + if lp_orig is not None: + env[lp_key] = lp_orig + else: + env.pop(lp_key, None) return env