Skip to content

Use configured env for activation command#10916

Open
puneetdixit200 wants to merge 1 commit into
python-poetry:mainfrom
puneetdixit200:fix-env-activate-configured-env
Open

Use configured env for activation command#10916
puneetdixit200 wants to merge 1 commit into
python-poetry:mainfrom
puneetdixit200:fix-env-activate-configured-env

Conversation

@puneetdixit200

Copy link
Copy Markdown

Resolves: #10423

  • Added tests for changed code.
  • Updated documentation for changed code.

env activate now uses the environment selected during command setup instead of resolving a fresh environment. This preserves the compatible virtualenv chosen when the active Python does not satisfy the project constraint, and avoids looking at the incompatible active VIRTUAL_ENV again.

Tests:

  • ./.bootstrap-venv/bin/python -m pytest tests/console/commands/env/test_activate.py -q
  • UV_CACHE_DIR=$PWD/.uv-cache uvx ruff==0.15.12 check src/poetry/console/commands/env/activate.py tests/console/commands/env/test_activate.py
  • UV_CACHE_DIR=$PWD/.uv-cache uvx ruff==0.15.12 format --check src/poetry/console/commands/env/activate.py tests/console/commands/env/test_activate.py
  • git diff --check

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@puneetdixit200 puneetdixit200 force-pushed the fix-env-activate-configured-env branch from 22bda55 to 51ed260 Compare May 23, 2026 15:05
@puneetdixit200

Copy link
Copy Markdown
Author

Rebased this branch on current main; no code changes beyond the rebase.

Verified:

  • python3 -m py_compile src/poetry/console/commands/env/activate.py tests/console/commands/env/test_activate.py
  • git diff --check

@puneetdixit200 puneetdixit200 force-pushed the fix-env-activate-configured-env branch from 51ed260 to 42b9962 Compare May 24, 2026 15:02
@puneetdixit200

Copy link
Copy Markdown
Author

Rebased again on current main (448eadfa). No code changes beyond the rebase.

Verified locally:

  • python3 -m py_compile src/poetry/console/commands/env/activate.py tests/console/commands/env/test_activate.py
  • git diff --check upstream/main...HEAD

@puneetdixit200 puneetdixit200 force-pushed the fix-env-activate-configured-env branch from 94d2305 to 378e64e Compare May 28, 2026 17:03
@puneetdixit200

Copy link
Copy Markdown
Author

Rebased onto current main; no code changes beyond replaying the existing patch.

New head: 378e64e56275.

Verified locally:

  • python3 -m py_compile src/poetry/console/commands/env/activate.py tests/console/commands/env/test_activate.py
  • git diff --check upstream/main...HEAD

@puneetdixit200

Copy link
Copy Markdown
Author

Checked the fresh CI after the rebase. The only red job is Windows (Python 3.10) / pytest, failing tests/utils/env/test_env.py::test_call_does_not_block_on_full_pipe[sys.stderr]; the status job is just aggregating that failure.

That test is outside this PR's diff (src/poetry/console/commands/env/activate.py and tests/console/commands/env/test_activate.py). I tried to rerun failed jobs, but GitHub rejected it with Must have admin rights to Repository, so I cannot trigger the rerun from here.

@puneetdixit200 puneetdixit200 force-pushed the fix-env-activate-configured-env branch from 378e64e to c579549 Compare June 2, 2026 16:53
@puneetdixit200

Copy link
Copy Markdown
Author

Rebased onto current main; no code changes beyond replaying the existing env activation patch.

New head: c579549ece7d.

Verified locally:

  • .venv/bin/python -m pytest tests/console/commands/env/test_activate.py -q (12 passed, 3 skipped)
  • .venv/bin/python -m pytest tests/utils/env/test_env.py::test_call_does_not_block_on_full_pipe -q (2 passed)
  • .venv/bin/python -m py_compile src/poetry/console/commands/env/activate.py tests/console/commands/env/test_activate.py
  • git diff --check upstream/main...HEAD

@puneetdixit200

Copy link
Copy Markdown
Author

Fresh checks on c579549ece7d are green now. The Tests workflow completed successfully: 48 passed checks and 4 expected skipped checks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Discovered shell 'bash' doesn't have an activator in virtual environment

1 participant