Skip to content

Commit

Permalink
Add Get-AllPackageInfoFromRepo
Browse files Browse the repository at this point in the history
  • Loading branch information
chidozieononiwu committed Mar 2, 2021
1 parent f84913b commit b0d789a
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
49 changes: 49 additions & 0 deletions eng/scripts/Language-Settings.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,55 @@ $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 = @()
$searchPath = "sdk/*/*/setup.py"
if ($serviceDirectoryName)
{
$searchPath = "sdk/${serviceDirectoryName}/*/setup.py"
}
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('$searchPath')")
}
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()
$setupPyDir = $setupInfo[3].Trim(")' ")
$pkgDirectoryPath = Resolve-Path (Join-Path -Path $RepoRoot $setupPyDir)
$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
11 changes: 11 additions & 0 deletions eng/scripts/get_package_properties.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
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(search_path):
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)))

0 comments on commit b0d789a

Please sign in to comment.