{Extension} insert extension directory in head of sys.path#12778
{Extension} insert extension directory in head of sys.path#12778fengzhou-msft wants to merge 1 commit intoAzure:devfrom
Conversation
|
add to S167 |
|
hi @fengzhou-msft when user is using venv, it's by design all packages should be loaded from venv, right? Will sync with you offline on this. |
|
I debugged into ext_dir is like 'C:\\Users\\xxx\\.azure\\cliextensions\\support'.
In that case, if two extensions contain the same SDK but with different versions, it will still has conflict. Another concern is that allowing extensions to override SDKs from venv may cause a security breach - a malicious extension can inject tampered SDKs to intercept the calls thus overriding the behavior, also impacting other command modules that rely on the SDKs. So as an ultimate solution, the extension should vendor the SDK by putting it under |
Description of PR (Mandatory)
(Why this PR? What is changed? What is the effect? etc. A high-quality description can accelerate the review process)
Fix #12062.
The extension directory was appended to the sys.path, and the virtual env site-package directory was in front of it. So CLI will load the SDK installed in the virtual env instead of the one in extension directory. Now we put extension directory in front position of sys.path to be loaded priorly.
Testing Guide
(Example commands with explanations)
History Notes:
(Fill in the following template if multiple notes are needed, otherwise PR title will be used for history note.)
[Component Name 1] (BREAKING CHANGE:) (az command:) make some customer-facing change.
[Component Name 2] (BREAKING CHANGE:) (az command:) make some customer-facing change.
This 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.