Skip to content

Commit

Permalink
Merge pull request #5 from fi-ts/fix-subprocess-calls-on-alpine
Browse files Browse the repository at this point in the history
Fix subprocess calls on alpine.
  • Loading branch information
Gerrit91 authored Aug 18, 2020
2 parents c25eaf4 + ae3936e commit e434ff7
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions dockermake/utils/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def _run_command(cmd, shell, cwd, with_continuous_output, stdin_feed):

@staticmethod
def _with_continuous_output(cmd, shell, cwd):
process = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=shell, cwd=cwd, env=os.environ)
process = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=shell, cwd=cwd, env=System._get_exec_env())
err = None
out = ""
for line in io.TextIOWrapper(process.stdout, encoding="utf-8"):
Expand All @@ -68,13 +68,22 @@ def _with_continuous_output(cmd, shell, cwd):
@staticmethod
def _without_continuous_output(cmd, shell, cwd, stdin_feed):
process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE,
shell=shell, cwd=cwd, env=os.environ, encoding='UTF-8')
shell=shell, cwd=cwd, env=System._get_exec_env(), encoding='UTF-8')
out, err = process.communicate(input=stdin_feed)
return_code = process.returncode
out, err = System._clean_outputs(out, err)
logging.debug("Command output was: %s", out)
return out, err, return_code

@staticmethod
def _get_exec_env():
env = os.environ.copy()
# removing library paths from pyinstaller, see:
# https://pyinstaller.readthedocs.io/en/stable/runtime-information.html#ld-library-path-libpath-considerations
env.pop('LD_LIBRARY_PATH', None)
env.pop('LIBPATH', None)
return env

@staticmethod
def _clean_outputs(out, err):
if out is None:
Expand Down

0 comments on commit e434ff7

Please sign in to comment.