From a2fc4a0a1d92caf00eaf2e4a6982286b20dbfd4d Mon Sep 17 00:00:00 2001 From: Gabriel Brammer Date: Wed, 5 Jan 2022 10:31:16 +0100 Subject: [PATCH 1/2] Add path to subprocess call --- wfc3tools/calwf3.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/wfc3tools/calwf3.py b/wfc3tools/calwf3.py index 44b41ec..7e9e512 100644 --- a/wfc3tools/calwf3.py +++ b/wfc3tools/calwf3.py @@ -1,7 +1,8 @@ from __future__ import print_function # STDLIB -import os.path +import os +import sys import subprocess from .version import __version_date__, __version__ @@ -60,10 +61,18 @@ def calwf3(input=None, output=None, printtime=False, save_tmp=False, if output: call_list.append(str(output)) + # Prepend environment bin directory to PATH if necessary + env_bin = os.path.join(sys.exec_prefix, 'bin') + if (env_bin not in os.getenv('PATH')) & os.path.exists(env_bin): + _path = ':'.join([env_bin, os.getenv('PATH')]) + else: + _path = os.getenv('PATH') + proc = subprocess.Popen( call_list, stderr=subprocess.STDOUT, stdout=subprocess.PIPE, + env={'PATH':_path} ) if log_func is not None: From 926c4f8e65b27a4f8be4c9901b800b0aac21b330 Mon Sep 17 00:00:00 2001 From: Gabriel Brammer Date: Wed, 5 Jan 2022 10:58:38 +0100 Subject: [PATCH 2/2] add iref to subprocess env --- wfc3tools/calwf3.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wfc3tools/calwf3.py b/wfc3tools/calwf3.py index 7e9e512..64edfef 100644 --- a/wfc3tools/calwf3.py +++ b/wfc3tools/calwf3.py @@ -72,7 +72,8 @@ def calwf3(input=None, output=None, printtime=False, save_tmp=False, call_list, stderr=subprocess.STDOUT, stdout=subprocess.PIPE, - env={'PATH':_path} + env={'PATH':_path, + 'iref':os.getenv('iref')} ) if log_func is not None: