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 27, 2021
1 parent f84913b commit d96e0b7
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
43 changes: 43 additions & 0 deletions eng/scripts/Language-Settings.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,49 @@ $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 = @()
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('$serviceDirectoryName')")
}
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()
$pkgDirectoryPath = Resolve-Path (Join-Path -Path $RepoRoot ($setupInfo[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
12 changes: 12 additions & 0 deletions eng/scripts/get_package_properties.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
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(service_directory_name):
search_path = 'sdk/{0}/*/setup.py'.format(service_directory_name)
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 d96e0b7

Please sign in to comment.