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:
- 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
Investigation
I did my own investigation, and found out that
the formatter is run using this:
|
.exec(executionInfo, { cwd, throwOnStdErr: false, token }, document.uri) |
|
return pythonExecutionService.execModule(executionInfo.moduleName!, executionInfo.args, options); |
|
const result = await this.deps.exec(executable.command, executable.args, opts); |
|
public execObservable(file: string, args: string[], options: SpawnOptions = {}): ObservableExecutionResult<string> { |
So I guess you spawn the process. Don't know why it doesn't pickup the environment variables the bash Python wrapper defines.
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-shellcommand in the terminal for instance.I can run
python -m blackin 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/pythonthat 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 blackfor instance.Feature I would like
I would like the Python extension to either:
or
terminal.integrated.automationShellInvestigation
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.