Skip to content

Commit bd77fef

Browse files
committed
fix: local venv is not used under some circumstances
E.g., 1. There is an ".python-version" file but no "pyenv" is installed. 2. "pyenv which python" will raises an exception. 3. `python_path` is an empty string and `None` is returned. But actually we want to test all direct subdirs later and shouldn't return `None` here. Signed-off-by: Jun-Fei Cherng <jfcherng@realtek.com>
1 parent bbe0291 commit bd77fef

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

plugin.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -222,21 +222,25 @@ def binary_from_python_path(path: str | Path) -> Path | None:
222222
continue
223223
print(f"{cls.name()}: INFO: {config_file} detected. Run subprocess command: {command}")
224224
try:
225-
stdout, stderr = subprocess.Popen(
226-
command,
227-
cwd=workspace_folder,
228-
shell=True,
229-
startupinfo=get_default_startupinfo(),
230-
stdout=subprocess.PIPE,
231-
stderr=subprocess.PIPE,
232-
universal_newlines=True,
233-
).communicate()
225+
stdout, stderr = map(
226+
str.rstrip,
227+
subprocess.Popen(
228+
command,
229+
cwd=workspace_folder,
230+
shell=True,
231+
startupinfo=get_default_startupinfo(),
232+
stdout=subprocess.PIPE,
233+
stderr=subprocess.PIPE,
234+
universal_newlines=True,
235+
).communicate(),
236+
)
234237
if stderr:
235-
print(f"{cls.name()}: INFO: subprocess stderr: {stderr.strip()}")
236-
python_path = stdout.strip()
238+
print(f"{cls.name()}: INFO: subprocess stderr: {stderr}")
239+
python_path = stdout
237240
if post_processing:
238241
python_path = post_processing(python_path)
239-
return Path(python_path) if python_path else None
242+
if python_path:
243+
return Path(python_path)
240244
except FileNotFoundError:
241245
print(f"{cls.name()}: WARN: subprocess failed with file not found: {command[0]}")
242246
except PermissionError as e:

0 commit comments

Comments
 (0)