scm: fix LD_LIBRARY_PATH if running from a bundle

Signed-off-by: Ruslan Kuprieiev <[email protected]>
This commit is contained in:
Ruslan Kuprieiev
2018-08-07 04:27:35 +03:00
parent e2e7649afe
commit e4b8cf2e0e
2 changed files with 17 additions and 6 deletions
+7
View File
@@ -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)
+10 -6
View File
@@ -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