You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a specific setup for defining my development environment (I use Nix).
What I can do for now is create an environment, which is supposed to have Python, black, flake8, ...
This environment can be built and oaded to the shell using the nix-shell command in the terminal for instance.
I can run python -m black in this shell without issue.
Once the Python environment is built with Nix, it is defined statically, which means that I do have an executable /nix/store/somehash/bin/python that corresponds to my environment (it is actually a wrapper in bash that sets the right environment variables before starting Python).
When I use this Python wrapper, the VS Code Python extension should pickup the same environment and have no issue running for instance the formatter through python -m black for instance.
Feature I would like
I would like the Python extension to either:
properly run such a wrapped Python executable bash in order to pickup the environment variables
or
allow the Python extension to run its commands in a shell, for instance the one specified by terminal.integrated.automationShell
I just noticed that the Python extension is able to pick up on the PATH made by Python venv. Would it be possible to allow to customize the hook (e.g. in my case use nix-shell shell.nix instead of source .venv/bin/activate) ? This would also allow to support other tools that provide shells such as Poetry.
Apologies for the late response, the notification got skipped. #8870 should help you out to customize the hook. FWIW we also have #8372 to add poetry support explicitly. Please upvote these issues to bump the priority, closing in favor of that.
Current situation
I have a specific setup for defining my development environment (I use Nix).
What I can do for now is create an environment, which is supposed to have Python, black, flake8, ...
This environment can be built and oaded to the shell using the
nix-shell
command in the terminal for instance.I can run
python -m black
in this shell without issue.Once the Python environment is built with Nix, it is defined statically, which means that I do have an executable
/nix/store/somehash/bin/python
that corresponds to my environment (it is actually a wrapper in bash that sets the right environment variables before starting Python).When I use this Python wrapper, the VS Code Python extension should pickup the same environment and have no issue running for instance the formatter through
python -m black
for instance.Feature I would like
I would like the Python extension to either:
or
terminal.integrated.automationShell
Investigation
I did my own investigation, and found out that
the formatter is run using this:
vscode-python/src/client/formatters/baseFormatter.ts
Line 77 in 411d1d4
vscode-python/src/client/common/process/pythonToolService.ts
Line 52 in 411d1d4
vscode-python/src/client/common/process/pythonProcess.ts
Line 55 in 411d1d4
vscode-python/src/client/common/process/proc.ts
Line 59 in 411d1d4
So I guess you spawn the process. Don't know why it doesn't pickup the environment variables the bash Python wrapper defines.
The text was updated successfully, but these errors were encountered: