@@ -135,7 +135,7 @@ def exec_cmd(args, stdout2null: bool = False, stderr2null: bool = False):
135135 raise
136136
137137
138- def run_cmd (args , cwd = None , stdout = subprocess .PIPE , ignore_stderr = False , ignore_all = False , encoding = None ):
138+ def run_cmd (args , cwd = None , stdout = subprocess .PIPE , ignore_stderr = False , ignore_all = False , encoding = None , env = None ):
139139 """
140140 Run the given command arguments.
141141
@@ -151,6 +151,7 @@ def run_cmd(args, cwd=None, stdout=subprocess.PIPE, ignore_stderr=False, ignore_
151151 logger .debug (f"Working directory: { cwd } " )
152152 logger .debug (f"Ignore stderr: { ignore_stderr } " )
153153 logger .debug (f"Ignore all: { ignore_all } " )
154+ logger .debug (f"env: { env } " )
154155
155156 serr = None
156157 if ignore_all or ignore_stderr :
@@ -160,7 +161,10 @@ def run_cmd(args, cwd=None, stdout=subprocess.PIPE, ignore_stderr=False, ignore_
160161 if ignore_all :
161162 sout = subprocess .DEVNULL
162163
163- result = subprocess .run (args , check = True , cwd = cwd , stdout = sout , stderr = serr , encoding = encoding )
164+ if env :
165+ env = os .environ | env
166+
167+ result = subprocess .run (args , check = True , cwd = cwd , stdout = sout , stderr = serr , encoding = encoding , env = env )
164168 logger .debug (f"Command finished with return code: { result .returncode } " )
165169
166170 return result
0 commit comments