[Packaging] Fix #34103: az version: Bind relocated Windows launchers to the installed interpreter - #34122
Conversation
|
Hi Aditya Pujara (@a0x1ab), |
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
Avoid the RuntimeWarning caused by the current launcher execution path.
Review effort: Lite
Findings: None
What changed in this PR
Fixes relocated Windows az launchers so they use the installed interpreter.
Changes:
- Adds and packages the
az-clilauncher. - Updates
az.batand process detection. - Adds packaging, relocation, and launcher regression tests.
| File | Reviewed changes |
|---|---|
src/azure-cli/setup.py |
Registers the helper console entry point. |
src/azure-cli/setup.cfg |
Includes the launcher in wheel builds. |
src/azure-cli/MANIFEST.in |
Includes the launcher in source distributions. |
src/azure-cli/azure/cli/_launcher.py |
Runs the CLI through the bound interpreter; currently emits a RuntimeWarning on invocation. |
src/azure-cli/azure_cli_bdist_wheel.py |
Supports multiple extra build sources. |
src/azure-cli/az.bat |
Delegates to the bound launcher with explicit errors. |
src/azure-cli-core/azure/cli/core/util.py |
Skips launcher processes during parent detection. |
src/azure-cli-core/azure/cli/core/tests/test_util.py |
Tests launcher process traversal. |
src/azure-cli-core/azure/cli/core/tests/test_launchers.py |
Tests packaging and launcher relocation scenarios. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
/azp run |
|
Azure Pipelines: Successfully started running 3 pipeline(s). |
Live test skipped⏭️ Skipping the live test for this revision because the only test file(s) changed are These |
There was a problem hiding this comment.
Confirmed launcher defect: the console entry point imports azure.cli._launcher, which imports the azure.cli package before runpy.run_module("azure.cli", run_name="main") executes it. Python therefore emits a RuntimeWarning that azure.cli is already present in sys.modules before execution. Run the actual azure.cli.main module instead, preserving argv, exit status, finalization, installer identity, and the bound interpreter. Add focused regression coverage asserting launcher stderr has no RuntimeWarning while retaining the existing finalization assertion.
…nchers to the installed interpreter
|
🔔 Routing this PR to @Azure/act-platform-engineering-squad. |
37b4d7e to
521104b
Compare
Live test skipped⏭️ Skipping the live test for this revision because the only test file(s) changed are These |
There was a problem hiding this comment.
Review: infrastructure timeout; no source change requested
Non-blocking COMMENT: no confirmed source or policy defect was found, but Python 3.12 validation remains incomplete.
Reviewed head: 521104bab644c92c4505ab49ae56dc60dd286075. The sensitive-information gate passed, and no outstanding formal human change request was found.
Summary
- Failure groups: 0 PR-related, 1 not PR-related, 0 uncertain.
- The canceled Python 3.12 job and failed aggregate check represent the same underlying timeout, not two findings.
- No live-test failure occurred: the dispatcher returned a reused neutral skip, not a passing test run.
Upstream CI
Completed snapshot: 48/50 passed, 1 failed, 1 canceled, 0 pending; one failed build/check group.
Azure.azure-cli
- Result: failure
- Failure details:
- Unit Test for Core Python312 (Not PR-related)
- Evidence: The job running on agent pool-ubuntu-2204 4 ran longer than the maximum time of 10 minutes. For more information, see https://go.microsoft.com/fwlink/?linkid=2077134
- Next action: Re-run the timed-out job. If it times out again at the same setup or checkout step, escalate to the pipeline owner instead of changing unrelated PR source.
- Verify: Re-run
Unit Test for Core Python312and confirm the job completes within its limit. - Attribution: The task timeline records checkout from 14:40:58.640 to 14:49:46.890 UTC—8m48s of the 10-minute job budget.
azdev setupwas then canceled, with the message “The operation was canceled.” Theazdev testtask was skipped, so neither changed test file ran in this job. The diff does not modify checkout, agent-pool, or pipeline configuration. This is a checkout/setup budget exhaustion, not evidence of a launcher assertion or source regression.
- Unit Test for Core Python312 (Not PR-related)
Test validation
-
Live test: Skipped: no runnable changed test files were found.
-
Regression coverage: Not applicable to the changed files.
-
Skip detail: The reused neutral result says “PR changes only azure-cli-core unit tests (not runnable by azdev --live)”. This describes the changed tests' live-test eligibility, not the entire PR scope. No workflow was dispatched during this review.
-
Focused coverage inspected:
src/azure-cli-core/azure/cli/core/tests/test_launchers.pychecks installed and relocated launchers, interpreter identity despite an unrelated Python on PATH, arguments/quoting, empty arguments, nonzero exit status, CLI finalization, missing helper/interpreter failures, and wheel/sdist contents.src/azure-cli-core/azure/cli/core/tests/test_util.pycovers the added launcher/virtualenv parent-process chain. -
Recording scope: No outgoing service request or response mapping changed; no recording update is indicated. The command-module coverage detector reports no gap, but its “not applicable” result is not proof of Windows launcher validation.
Review skills
All seven deterministic skills were accounted for; no deterministic findings or confirmed semantic defects were found.
| Skill | Result |
|---|---|
| Release artifact validator | Not applicable per helper; packaging History Notes are present and generated HISTORY files are unchanged. |
| Generated code ownership checker | Not applicable; no generated output changes. |
| Command and help convention checker | Not applicable; no command-module/help changes. |
| Test semantic-strength reviewer | Reviewed: assertions check actual interpreter/prefix, forwarded arguments, module execution, exit status and negative paths rather than merely successful import. |
| No-silent-user-intent reviewer | Not applicable per helper; launcher argument forwarding is covered by the focused tests above. |
| Scope-consistency reviewer | Reviewed: the nine changed files align with interpreter-bound Windows launchers, their packaging, parent-shell detection and regression tests. |
| Domain edge-case reviewer | Not applicable per helper; launcher error, quoting and exit paths were inspected with the test-strength target. |
Next action and validation limits
No source change is requested and no implementation repair job is warranted. Have the Azure Pipelines owner rerun Unit Test for Core Python312 and confirm azdev setup, azdev test and test-result publication complete. If checkout again consumes most of the budget, escalate build 352874 and its linked job to the pipeline/agent-pool owner rather than modifying unrelated source.
For focused Windows assurance, rerun TestInstalledLaunchers in src/azure-cli-core/azure/cli/core/tests/test_launchers.py on a Windows worker with cmd.exe and PowerShell; exercise its uv install/upgrade case when uv is available. Also rerun the parent-process cases in src/azure-cli-core/azure/cli/core/tests/test_util.py. Upstream CI is authoritative; no local tests or builds were run.
The learned human-review guidance lookup was unavailable; this assessment uses the deterministic checks and current source/task evidence directly.
Classifier limitation: This is not a test-only diff: it also changes src/azure-cli-core/azure/cli/core/util.py, src/azure-cli/az.bat, src/azure-cli/azure/cli/_launcher.py and packaging files. The deterministic coverage/risk classifiers did not identify those as production components. Their low-confidence output below must not be read as evidence that Windows installation behavior is unchanged or fully validated.
Risk assessment
0/100 · Low · Low confidence
The Low rating reflects the detected change scope with no elevated security, reliability, customer, operational, dependency, sovereign-cloud, generated-output, or cross-component signal.
- Change scope: 9 changed files, 452 changed lines (
+435/-17), including 0 production files. - Affected components: No production component was identified.
- Risk drivers: No elevated risk signal was detected.
- Regression evidence: No production-code regression-test signal applies.
- Confidence: Low because no production changed-line evidence was available.
- Required review: No additional owning-squad review signal was detected.
🤖 PR Validation — ️✔️ All clear
Related command
az versionDescription
Fixes #34103.
Bind relocated Windows launchers to the installed interpreter.
Testing Guide
az version.src/azure-cli-core/azure/cli/core/tests/test_launchers.py,src/azure-cli-core/azure/cli/core/tests/test_util.py.History Notes
[Packaging]
az version: Bind relocated Windows launchers to the installed interpreterThis checklist is used to make sure that common guidelines for a pull request are followed.
The PR title and description has followed the guideline in Submitting Pull Requests.
I adhere to the Command Guidelines.
I adhere to the Error Handling Guidelines.