From d366d5dc920a0eb81b7e8dac761899159cdc258f Mon Sep 17 00:00:00 2001 From: Chidozie Ononiwu Date: Mon, 7 Dec 2020 15:55:37 -0800 Subject: [PATCH] Add GetPackageInstallNotes function --- eng/scripts/Language-Settings.ps1 | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/eng/scripts/Language-Settings.ps1 b/eng/scripts/Language-Settings.ps1 index bb88e710ca8c6..aabeb97a02485 100644 --- a/eng/scripts/Language-Settings.ps1 +++ b/eng/scripts/Language-Settings.ps1 @@ -3,6 +3,7 @@ $PackageRepository = "PyPI" $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" +$PACKAGE_INSTALL_NOTES_REGEX = "pip\sinstall\s(?.*)==(?.*)" function Get-python-PackageInfoFromRepo ($pkgPath, $serviceDirectory, $pkgName) { @@ -23,7 +24,8 @@ function Get-python-PackageInfoFromRepo ($pkgPath, $serviceDirectory, $pkgName) } # Returns the pypi publish status of a package id and version. -function IsPythonPackageVersionPublished($pkgId, $pkgVersion) { +function IsPythonPackageVersionPublished($pkgId, $pkgVersion) +{ try { $existingVersion = (Invoke-RestMethod -MaximumRetryCount 3 -RetryIntervalSec 10 -Method "Get" -uri "https://pypi.org/pypi/$pkgId/$pkgVersion/json").info.version @@ -48,7 +50,8 @@ function IsPythonPackageVersionPublished($pkgId, $pkgVersion) { } # Parse out package publishing information given a python sdist of ZIP format. -function Get-python-PackageInfoFromPackageFile ($pkg, $workingDirectory) { +function Get-python-PackageInfoFromPackageFile ($pkg, $workingDirectory) +{ $pkg.Basename -match $SDIST_PACKAGE_REGEX | Out-Null $pkgId = $matches["package"] @@ -109,7 +112,8 @@ function Publish-python-GithubIODocs ($DocLocation, $PublicArtifactLocation) } } -function Get-python-GithubIoDocIndex() { +function Get-python-GithubIoDocIndex() +{ # Update the main.js and docfx.json language content UpdateDocIndexFiles -appTitleLang Python # Fetch out all package metadata from csv file. @@ -125,7 +129,8 @@ function Get-python-GithubIoDocIndex() { # Updates a python CI configuration json. # For "latest", the version attribute is cleared, as default behavior is to pull latest "non-preview". # For "preview", we update to >= the target releasing package version. -function Update-python-CIConfig($pkgs, $ciRepo, $locationInDocRepo, $monikerId=$null){ +function Update-python-CIConfig($pkgs, $ciRepo, $locationInDocRepo, $monikerId=$null) +{ $pkgJsonLoc = (Join-Path -Path $ciRepo -ChildPath $locationInDocRepo) if (-not (Test-Path $pkgJsonLoc)) { @@ -180,7 +185,8 @@ function Update-python-CIConfig($pkgs, $ciRepo, $locationInDocRepo, $monikerId=$ Set-Content -Path $pkgJsonLoc -Value $jsonContent } -function GetExistingPackageVersions ($PackageName, $GroupId=$null) { +function GetExistingPackageVersions ($PackageName, $GroupId=$null) +{ try { $existingVersion = Invoke-RestMethod -Method GET -Uri "https://pypi.python.org/pypi/${PackageName}/json" @@ -188,20 +194,22 @@ function GetExistingPackageVersions ($PackageName, $GroupId=$null) { } catch { - LogError "Failed to retieve package versions. `n$_" + LogError "Failed to retrieve package versions. `n$_" return $null } } -function SetPackageVersion ($PackageName, $Version, $ServiceName, $ReleaseDate, $BuildType=$null, $GroupName=$null) { +function SetPackageVersion ($PackageName, $Version, $ServiceDirectory, $ReleaseDate, $BuildType=$null, $GroupId=$null) +{ if($null -eq $ReleaseDate) { $ReleaseDate = Get-Date -Format "yyyy-MM-dd" } pip install -r "$EngDir/versioning/requirements.txt" -q -I - python "$EngDir/versioning/version_set.py" --package-name $PackageName --new-version $Version --service $ServiceName --release-date $ReleaseDate + python "$EngDir/versioning/version_set.py" --package-name $PackageName --new-version $Version --service $ServiceDirectory --release-date $ReleaseDate } -function GetPackageInstallNotes ($package, $version) { - return npm install $package +function GetPackageInstallNote ($PackageName, $Version, $GroupId=$null) +{ + return "pip install ${PackageName}==${Version}" }