Skip to content

Use configured env for activation command - #10916

Merged
radoering merged 2 commits into
python-poetry:mainfrom
puneetdixit200:fix-env-activate-configured-env
Jun 20, 2026
Merged

radoering merged 2 commits into
python-poetry:mainfrom
puneetdixit200:fix-env-activate-configured-env

Conversation

@puneetdixit200

Copy link
Copy Markdown
Contributor

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
Contributor 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
Contributor 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
Contributor 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
Contributor 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
Contributor 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
Contributor Author

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

@radoering
radoering force-pushed the fix-env-activate-configured-env branch from c579549 to dd2d301 Compare June 20, 2026 10:03
@radoering
radoering enabled auto-merge (squash) June 20, 2026 10:52
@radoering
radoering merged commit 7f5d3be into python-poetry:main Jun 20, 2026
52 checks passed
@github-actions

Copy link
Copy Markdown

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Jul 21, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

2 participants