Skip to content

allow python venv path as env var w/ PythonProcessOptions#12817

Merged
l0lawrence merged 16 commits intoAzure:mainfrom
l0lawrence:pythoncheckruninenv
Nov 12, 2025
Merged

allow python venv path as env var w/ PythonProcessOptions#12817
l0lawrence merged 16 commits intoAzure:mainfrom
l0lawrence:pythoncheckruninenv

Conversation

@l0lawrence
Copy link
Member

@l0lawrence l0lawrence commented Nov 10, 2025

User would need to set environment variable AZSDKTOOLS_PYTHON_VENV_PATH to be their desired venv path otherwise we default back to the python path if it is not set -- as we develop this can turn into creating a venv + installing the required dependencies for the verifySetup step

@l0lawrence l0lawrence added the azsdk-cli Issues related to Azure/azure-sdk-tools::tools/azsdk-cli label Nov 10, 2025
@l0lawrence l0lawrence marked this pull request as ready for review November 10, 2025 17:02
@l0lawrence l0lawrence requested a review from a team as a code owner November 10, 2025 17:02
Copilot AI review requested due to automatic review settings November 10, 2025 17:02
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for specifying a Python virtual environment path when running package validation checks. This allows users to run Python-specific checks (like snippet updates, linting, and formatting) using tools from a specific virtual environment instead of relying on system-wide installations.

Key changes:

  • Added a new --python-venv-path command-line option to the package check tool
  • Implemented logic to resolve Python and tool executables from the specified virtual environment
  • Updated method signatures to pass the Python venv path through the call chain

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
PackageCheckTool.cs Added --python-venv-path option and plumbed it through command handling to the Python language checks
PythonLanguageSpecificChecks.cs Implemented venv path resolution for Python executables and tools, with fallback to system Python
CheckAllToolTests.cs Updated test calls to match the new method signature (removed explicit CancellationToken.None parameter)
Comments suppressed due to low confidence (1)

tools/azsdk-cli/Azure.Sdk.Tools.Cli/Services/Languages/PythonLanguageSpecificChecks.cs:1

  • The new Python venv path functionality lacks test coverage. Consider adding tests that verify: (1) the venv path is correctly set when provided, (2) Python and tool executables are resolved from the venv directory, (3) fallback to system Python occurs when executables are not found in venv, and (4) the DirectoryNotFoundException is thrown when an invalid venv path is provided. Other language-specific checks in the codebase have dedicated test files (e.g., DotNetLanguageSpecificChecksTests.cs, JavaLanguageSpecificChecksTests.cs).
using Azure.Sdk.Tools.Cli.Helpers;

@l0lawrence l0lawrence changed the title python venv path for linting python venv path as env var Nov 10, 2025
@l0lawrence l0lawrence changed the title python venv path as env var allow python venv path as env var w/ PythonProcessOptions Nov 10, 2025
Copy link
Member

@timovv timovv left a comment

Choose a reason for hiding this comment

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

Looks good

Copy link
Member

@richardpark-msft richardpark-msft left a comment

Choose a reason for hiding this comment

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

Seems basically okay, but it's lacking some maintainability - there's hardly any comments explaining things, there's a global variable in there, and there's no tests.

I think it's worth putting in the time here when it's still fresh on your mind.

Copy link
Member

@richardpark-msft richardpark-msft left a comment

Choose a reason for hiding this comment

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

Talked with @l0lawrence about the environment variable - it's a simple workaround to allow advanced users to use venvs, if they want, but it's not the mainline scenario we expect developers to use.

Approving.

@l0lawrence l0lawrence merged commit 58e4a7e into Azure:main Nov 12, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

azsdk-cli Issues related to Azure/azure-sdk-tools::tools/azsdk-cli

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants