Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Get-AllPackageInfoFromRepo #16947

Merged
merged 5 commits into from
Mar 4, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions eng/scripts/Language-Settings.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,58 @@ $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 ($serviceDirectory)
{
$allPackageProps = @()
$searchPath = "sdk/*/*/setup.py"
if ($serviceDirectory)
{
$searchPath = "sdk/${serviceDirectory}/*/setup.py"
}

$allPkgPropLines = $null
try
{
Push-Location $RepoRoot
pip install packaging==20.4 -q -I
$allPkgPropLines = python "eng\scripts\get_package_properties.py" -s $searchPath
}
catch
{
# This is soft error and failure is expected for python metapackages
LogError "Failed to get all package properties"
}
finally
{
Pop-Location
}

foreach ($line in $allPkgPropLines)
{
$pkgInfo = ($line -Split ",").Trim("()' ")
$packageName = $pkgInfo[0]
$packageVersion = $pkgInfo[1]
$isNewSdk = $pkgInfo[2]
$setupPyDir = $pkgInfo[3]
$pkgDirectoryPath = Resolve-Path (Join-Path -Path $RepoRoot $setupPyDir)
$serviceDirectoryName = Split-Path (Split-Path -Path $pkgDirectoryPath -Parent) -Leaf
chidozieononiwu marked this conversation as resolved.
Show resolved Hide resolved
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('_', '-')
Expand Down
16 changes: 16 additions & 0 deletions eng/scripts/get_package_properties.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import argparse
import sys
import glob
import os

sys.path.append(os.path.join('scripts', 'devops_tasks'))
from common_tasks import get_package_properties

if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Get package version details from the repo')
parser.add_argument('-s', '--search_path', required=True, help='The scope of the search')
args = parser.parse_args()

for p in glob.glob(args.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)))