From d48afa8d7abf925fd8d7cd55ed08783faf8cffec Mon Sep 17 00:00:00 2001 From: Chidozie Ononiwu Date: Thu, 25 Feb 2021 13:29:32 -0800 Subject: [PATCH] Add Get-AllPackageInfoFromRepo --- eng/scripts/Language-Settings.ps1 | 44 +++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/eng/scripts/Language-Settings.ps1 b/eng/scripts/Language-Settings.ps1 index 7dff11c4541c..85178f0691d6 100644 --- a/eng/scripts/Language-Settings.ps1 +++ b/eng/scripts/Language-Settings.ps1 @@ -5,6 +5,50 @@ $packagePattern = "*.zip" $MetadataUri = "https://raw.githubusercontent.com/Azure/azure-sdk/master/_data/releases/latest/python-packages.csv" $BlobStorageUrl = "https://azuresdkdocs.blob.core.windows.net/%24web?restype=container&comp=list&prefix=python%2F&delimiter=%2F" +function Get-AllPackageInfoFromRepo +{ + $allPackageProps = @() + Push-Location $RepoRoot + $allSetupProps = $null + try{ + pip install packaging==20.4 -q -I + $allSetupProps = (python -c "import sys; import glob; import os; sys.path.append(os.path.join('scripts', 'devops_tasks')); from common_tasks import get_package_properties; \ + obj=[get_package_properties(os.path.dirname(p)) for p in glob.glob('sdk/*/*/setup.py', recursive=True) \ + if os.path.basename(os.path.dirname(p)) != 'azure-mgmt' and os.path.basename(os.path.dirname(p)) != 'azure' and os.path.basename(os.path.dirname(p)) != 'azure-storage']; \ + print(obj)") + } + catch + { + # This is soft error and failure is expected for python metapackages + LogError "Failed to get all package properties" + } + Pop-Location + $allMatches = $allSetupProps | Select-String '\(.*?\)' -AllMatches + foreach ($matchInfo in $allMatches.Matches) + { + $matchValue = $matchInfo.Value -Split " " + $packageName = $matchValue[0].Trim("(',") + $packageVersion = $matchValue[1].Trim("',") + $isNewSdk = $matchValue[2].Trim("',") + $pkgDirectoryPath = Resolve-Path (Join-Path -Path $RepoRoot ($matchValue[3].Trim(")',"))) + $serviceDirectoryName = Split-Path (Split-Path -Path $pkgDirectoryPath -Parent) -Leaf + if ($packageName -match "mgmt") + { + $sdkType = "mgmt" + } + else + { + $sdkType = "client" + } + $pkgProp = [PackageProps]::new($packageName, $packageVersion, $pkgDirectoryPath, $serviceDirectoryName) + $pkgProp.IsNewSdk = $isNewSdk + $pkgProp.SdkType = $sdkType + $pkgProp.ArtifactName = $packageName + $allPackageProps += $pkgProp + } + return $allPackageProps +} + function Get-python-PackageInfoFromRepo ($pkgPath, $serviceDirectory, $pkgName) { $packageName = $pkgName.Replace('_', '-')