Skip to content

Commit

Permalink
Handle metapackages that cannot be installed (#16788)
Browse files Browse the repository at this point in the history
* Handle metapackages that cannot be installed and Set package properties and reduce python calls to get package properties
  • Loading branch information
praveenkuttappan authored Feb 18, 2021
1 parent 1a31b56 commit b9fe720
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions eng/scripts/Language-Settings.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,43 @@ $MetadataUri = "https://raw.githubusercontent.com/Azure/azure-sdk/master/_data/r
$BlobStorageUrl = "https://azuresdkdocs.blob.core.windows.net/%24web?restype=container&comp=list&prefix=python%2F&delimiter=%2F"

function Get-python-PackageInfoFromRepo ($pkgPath, $serviceDirectory, $pkgName)
{
pip install packaging==20.4 -q -I
$pkgName = $pkgName.Replace('_', '-')
{
$packageName = $pkgName.Replace('_', '-')
$pkgDirName = Split-Path $pkgPath -Leaf
if ($pkgDirName -ne $packageName)
{
# Common code triggers this function against each directory but we can skip if it doesn't match package name
return $null
}

if (Test-Path (Join-Path $pkgPath "setup.py"))
{
$setupLocation = $pkgPath.Replace('\','/')
pushd $RepoRoot
$setupProps = (python -c "import sys; import os; sys.path.append(os.path.join('scripts', 'devops_tasks')); from common_tasks import get_package_properties; obj=get_package_properties('$setupLocation'); print('{0},{1},{2}'.format(obj[0], obj[1], obj[2]));") -split ","
$setupProps = $null
try{
pip install packaging==20.4 -q -I
$setupProps = (python -c "import sys; import os; sys.path.append(os.path.join('scripts', 'devops_tasks')); from common_tasks import get_package_properties; obj=get_package_properties('$setupLocation'); print('{0},{1},{2}'.format(obj[0], obj[1], obj[2]));") -split ","
}
catch
{
# This is soft error and failure is expected for python metapackages
Write-Host "Failed to parse package properties for " $packageName
}
popd
if (($setupProps -ne $null) -and ($setupProps[0] -eq $pkgName))
if (($setupProps -ne $null) -and ($setupProps[0] -eq $packageName))
{
$pkgProp = [PackageProps]::new($setupProps[0], $setupProps[1], $pkgPath, $serviceDirectory)
if ($pkgName -match "mgmt")
if ($packageName -match "mgmt")
{
$pkgProp.SdkType = "mgmt"
}
else
{
$pkgProp.SdkType = "client"
}
$pkgProp.IsNewSdk = $setupProps[3]
$pkgProp.IsNewSdk = $setupProps[2]
$pkgProp.ArtifactName = $pkgName
return $pkgProp
}
}
Expand Down

0 comments on commit b9fe720

Please sign in to comment.