From 43dc30018c0b28533866b6076de27019e8f69a79 Mon Sep 17 00:00:00 2001 From: Bruce Forstall Date: Mon, 15 Nov 2021 17:32:36 -0800 Subject: [PATCH] Fix SuperPMI Python script Azure usage The on-demand Azure module load was refactored to jitutil.py, but that requires some cross-module importing to work. Do the minimal required to make this work. --- src/coreclr/scripts/jitutil.py | 7 +++++++ src/coreclr/scripts/superpmi.py | 2 ++ 2 files changed, 9 insertions(+) diff --git a/src/coreclr/scripts/jitutil.py b/src/coreclr/scripts/jitutil.py index 5bff7e304594b2..c7906124b45d4b 100644 --- a/src/coreclr/scripts/jitutil.py +++ b/src/coreclr/scripts/jitutil.py @@ -419,6 +419,13 @@ def require_azure_storage_libraries(need_azure_storage_blob=True, need_azure_ide """ Check for and import the Azure libraries. We do this lazily, only when we decide we're actually going to need them. Once we've done it once, we don't do it again. + + For this to work for cross-module usage, after you call this function, you need to add a line like: + from jitutil import BlobClient, AzureCliCredential + naming all the types you want to use. + + The full set of types this function loads: + BlobServiceClient, BlobClient, ContainerClient, AzureCliCredential """ global azure_storage_libraries_check, BlobServiceClient, BlobClient, ContainerClient, AzureCliCredential diff --git a/src/coreclr/scripts/superpmi.py b/src/coreclr/scripts/superpmi.py index dacf3a889d041d..32bc297796d3de 100755 --- a/src/coreclr/scripts/superpmi.py +++ b/src/coreclr/scripts/superpmi.py @@ -2145,6 +2145,7 @@ def list_superpmi_collections_container_via_azure_api(path_filter=lambda unused: """ require_azure_storage_libraries() + from jitutil import ContainerClient, AzureCliCredential superpmi_container_url = az_blob_storage_superpmi_container_uri @@ -2356,6 +2357,7 @@ def upload_mch(coreclr_args): """ require_azure_storage_libraries(need_azure_identity=False) + from jitutil import BlobServiceClient def upload_blob(file, blob_name): blob_client = blob_service_client.get_blob_client(container=az_superpmi_container_name, blob=blob_name)