Problem
The extension does not honor the POETRY_VIRTUALENVS_IN_PROJECT environment variable when determining whether a .venv directory in a project should be treated as a Poetry environment.
Expected Behavior
When POETRY_VIRTUALENVS_IN_PROJECT=true (or 1) is set, Poetry creates virtualenvs in the project's .venv directory. The extension should recognize these as Poetry environments.
Current Behavior
The extension doesn't check this environment variable, so .venv directories in Poetry projects may not be correctly identified as Poetry environments.
PET Server Reference
The PET server properly handles this in pet-poetry/src/env_variables.rs:
poetry_virtualenvs_in_project: env
.get_env_var("POETRY_VIRTUALENVS_IN_PROJECT".to_string())
.map(|v| v == "1" || v.to_lowercase() == "true"),
And in pet-poetry/src/environment_locations.rs:
fn should_use_local_venv_as_poetry_env(
global: &Option<Config>,
local: &Option<Config>,
env: &EnvVariables,
) -> bool {
// Given preference to env variable.
if let Some(poetry_virtualenvs_in_project) = env.poetry_virtualenvs_in_project {
return poetry_virtualenvs_in_project;
}
// ...
}
Suggested Fix
Add support in poetryUtils.ts to:
- Check
process.env.POETRY_VIRTUALENVS_IN_PROJECT
- Consider
.venv as a Poetry env when this is set and the parent has pyproject.toml with [tool.poetry]
Related
This is similar to how poetry.toml local config with virtualenvs.in-project = true should work.
Affected File
src/managers/poetry/poetryUtils.ts
Problem
The extension does not honor the
POETRY_VIRTUALENVS_IN_PROJECTenvironment variable when determining whether a.venvdirectory in a project should be treated as a Poetry environment.Expected Behavior
When
POETRY_VIRTUALENVS_IN_PROJECT=true(or1) is set, Poetry creates virtualenvs in the project's.venvdirectory. The extension should recognize these as Poetry environments.Current Behavior
The extension doesn't check this environment variable, so
.venvdirectories in Poetry projects may not be correctly identified as Poetry environments.PET Server Reference
The PET server properly handles this in
pet-poetry/src/env_variables.rs:And in
pet-poetry/src/environment_locations.rs:Suggested Fix
Add support in
poetryUtils.tsto:process.env.POETRY_VIRTUALENVS_IN_PROJECT.venvas a Poetry env when this is set and the parent haspyproject.tomlwith[tool.poetry]Related
This is similar to how
poetry.tomllocal config withvirtualenvs.in-project = trueshould work.Affected File
src/managers/poetry/poetryUtils.ts