From d96e0b715ad35ada89ac1f0511d6fa192333a4bf 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 | 43 +++++++++++++++++++++++++++ eng/scripts/get_package_properties.py | 12 ++++++++ 2 files changed, 55 insertions(+) create mode 100644 eng/scripts/get_package_properties.py diff --git a/eng/scripts/Language-Settings.ps1 b/eng/scripts/Language-Settings.ps1 index 7dff11c4541c2..0472018c9b76c 100644 --- a/eng/scripts/Language-Settings.ps1 +++ b/eng/scripts/Language-Settings.ps1 @@ -5,6 +5,49 @@ $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 ($serviceDirectoryName="*") +{ + $allPackageProps = @() + Push-Location $RepoRoot + $allSetupProps = $null + try + { + pip install packaging==20.4 -q -I + $allSetupProps = (python -c "import sys; import os; sys.path.append(os.path.join('eng', 'scripts')); \ + import get_package_properties; get_package_properties.get_all_package_properties('$serviceDirectoryName')") + } + catch + { + # This is soft error and failure is expected for python metapackages + LogError "Failed to get all package properties" + } + Pop-Location + + foreach ($line in $allSetupProps) + { + $setupInfo = $line -Split "," + $packageName = $setupInfo[0].Trim("(' ") + $packageVersion = $setupInfo[1].Trim("' ") + $isNewSdk = $setupInfo[2].Trim() + $pkgDirectoryPath = Resolve-Path (Join-Path -Path $RepoRoot ($setupInfo[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('_', '-') diff --git a/eng/scripts/get_package_properties.py b/eng/scripts/get_package_properties.py new file mode 100644 index 0000000000000..caf48979a7533 --- /dev/null +++ b/eng/scripts/get_package_properties.py @@ -0,0 +1,12 @@ +import sys +import glob +import os + +sys.path.append(os.path.join('scripts', 'devops_tasks')) +from common_tasks import get_package_properties + +def get_all_package_properties(service_directory_name): + search_path = 'sdk/{0}/*/setup.py'.format(service_directory_name) + for p in glob.glob(search_path, 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(get_package_properties(os.path.dirname(p))) \ No newline at end of file