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

Handle metapackages that cannot be installed #16788

Merged
merged 2 commits into from
Feb 18, 2021
Merged
Changes from all 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
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you intend to move this out so its only installed once?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope. It attempts to install for every package as opposed to every iteration. But we can move this completely outside too.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think an issue in that approach will be additional constraint to have python installed if anyone wants to use any other functions in this script. For now, I will leave as it is since this change alone has improved performance a lot.

$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