Skip to content

Commit

Permalink
Add Get-AllPackageInfoFromRepo
Browse files Browse the repository at this point in the history
  • Loading branch information
chidozieononiwu committed Feb 25, 2021
1 parent f84913b commit d48afa8
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions eng/scripts/Language-Settings.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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('_', '-')
Expand Down

0 comments on commit d48afa8

Please sign in to comment.