Skip to content

Commit

Permalink
Add GetPackageInstallNotes function
Browse files Browse the repository at this point in the history
  • Loading branch information
chidozieononiwu committed Dec 12, 2020
1 parent 9f75f65 commit d366d5d
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions eng/scripts/Language-Settings.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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(?<PackageName>.*)==(?<Version>.*)"

function Get-python-PackageInfoFromRepo ($pkgPath, $serviceDirectory, $pkgName)
{
Expand All @@ -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
Expand All @@ -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"]
Expand Down Expand Up @@ -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.
Expand All @@ -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)) {
Expand Down Expand Up @@ -180,28 +185,31 @@ 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"
return ($existingVersion.releases | Get-Member -MemberType NoteProperty).Name
}
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}"
}

0 comments on commit d366d5d

Please sign in to comment.