mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 05:48:36 +08:00
Bugfix: make extraction of poetry_venvs_path more robust (#7920)
This commit is contained in:
parent
7c23993344
commit
76cad626ed
@ -207,19 +207,31 @@ class LocalRuntime(ActionExecutionClient):
|
||||
env['PYTHONPATH'] = f'{code_repo_path}:$PYTHONPATH'
|
||||
env['OPENHANDS_REPO_PATH'] = code_repo_path
|
||||
env['LOCAL_RUNTIME_MODE'] = '1'
|
||||
# Extract the poetry venv by parsing output of a shell command
|
||||
# Equivalent to:
|
||||
# run poetry show -v | head -n 1 | awk '{print $2}'
|
||||
poetry_venvs_path = (
|
||||
poetry_show_first_line = (
|
||||
subprocess.check_output(
|
||||
['poetry', 'show', '-v'],
|
||||
env=env,
|
||||
cwd=code_repo_path,
|
||||
text=True,
|
||||
# Redirect stderr to stdout
|
||||
# Needed since there might be a message on stderr like
|
||||
# "Skipping virtualenv creation, as specified in config file."
|
||||
# which will cause the command to fail
|
||||
stderr=subprocess.STDOUT,
|
||||
shell=False,
|
||||
)
|
||||
.splitlines()[0]
|
||||
.split(':')[1]
|
||||
.strip()
|
||||
)
|
||||
if not poetry_show_first_line.lower().startswith('found:'):
|
||||
raise RuntimeError(
|
||||
"Cannot find poetry venv path. Please check your poetry installation."
|
||||
f"First line of poetry show -v: {poetry_show_first_line}"
|
||||
)
|
||||
# Split off the 'Found:' part
|
||||
poetry_venvs_path = poetry_show_first_line.split(':')[1].strip()
|
||||
env['POETRY_VIRTUALENVS_PATH'] = poetry_venvs_path
|
||||
logger.debug(f'POETRY_VIRTUALENVS_PATH: {poetry_venvs_path}')
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user