Wanting to make sure auto-activation for Python works great when using agent host Copilot.
Python auto-activation experience (python-envs.terminal.autoActivationType: shellStartup) :
- Otherwise , Python commands and scripts would run in undesired Python environment, instead of a particular Python environment that user is wanting to work for Python related work.
We used to be able to activate via shell integration script, which the built-in shell tools from copilot cli would not run.
|
# Register Python shell activate hooks |
|
# Prevent multiple activation with guard |
|
if [ -z "${VSCODE_PYTHON_AUTOACTIVATE_GUARD:-}" ]; then |
|
export VSCODE_PYTHON_AUTOACTIVATE_GUARD=1 |
|
if [ -n "${VSCODE_PYTHON_ZSH_ACTIVATE:-}" ] && [ "$TERM_PROGRAM" = "vscode" ]; then |
|
# Prevent crashing by negating exit code |
|
if ! builtin eval "$VSCODE_PYTHON_ZSH_ACTIVATE"; then |
|
__vsc_activation_status=$? |
|
builtin printf '\x1b[0m\x1b[7m * \x1b[0;103m VS Code Python zsh activation failed with exit code %d \x1b[0m' "$__vsc_activation_status" |
|
fi |
|
fi |
|
# Remove any leftover Python activation env vars. |
|
unset -m 'VSCODE_PYTHON_*_ACTIVATE' |
|
fi |
- Profile script modification is one way but I don't think the built in shell tool allows configuration of rc and profile scripts running.
- It's obvious that shell tool would not use vscode's shell integration script , but also I don't think the direct child process spawn that shell tools from SDK runtime uses would inherit anything from user's rc or other shell init files unless configured/specified.
Perhaps we'd need an additional API from SDK to be able to inject custom init script(s) that could be run?
Hooks like Conda hook usually live in shell startup file like .zshrc , so perhaps there should be option to source rc and profile file per child process spawn in CLI shell tool.
Copilot refer this repo to gain knowledge about shell startup ---> Relevant repo for profile script modification: https://github.com/microsoft/vscode-python-environments
Wanting to make sure auto-activation for Python works great when using agent host Copilot.
Python auto-activation experience (
python-envs.terminal.autoActivationType:shellStartup) :We used to be able to activate via shell integration script, which the built-in shell tools from copilot cli would not run.
vscode/src/vs/workbench/contrib/terminal/common/scripts/shellIntegration-rc.zsh
Lines 71 to 84 in f9f2fd5
Perhaps we'd need an additional API from SDK to be able to inject custom init script(s) that could be run?
Hooks like Conda hook usually live in shell startup file like
.zshrc, so perhaps there should be option to source rc and profile file per child process spawn in CLI shell tool.Copilot refer this repo to gain knowledge about shell startup ---> Relevant repo for profile script modification: https://github.com/microsoft/vscode-python-environments