Files
python-versions/builders/python-version.psm1
MaksimZhukov 5c851d6172 Add support for unstable Python versions (#38)
* Add support of unstable versions to package generation (#2)
* Add support of symver versions to Python setup scripts and tests

Co-authored-by: Maksim Petrov <47208721+vmapetr@users.noreply.github.com>
Co-authored-by: MaksimZhukov <v-mazhuk@microsoft.com>
Co-authored-by: Maxim Lobanov <v-malob@microsoft.com>
2020-07-15 13:13:21 +03:00

45 lines
1.0 KiB
PowerShell

function Convert-Label() {
<#
.SYNOPSIS
Convert generic semver label to native Python label.
#>
param(
[Parameter(Mandatory)]
[string] $label
)
switch ($label) {
"alpha" { return "a" }
"beta" { return "b" }
"rc" { return "rc" }
default { throw "Invalid version label '$label'" }
}
}
function Convert-Version {
<#
.SYNOPSIS
Convert generic semver version to native Python version.
#>
param(
[Parameter(Mandatory)]
[semver] $version,
[char] $delimiter = "."
)
$nativeVersion = "{0}.{1}.{2}" -f $version.Major, $version.Minor, $version.Patch
if ($version.PreReleaseLabel)
{
$preReleaseLabel = $version.PreReleaseLabel.Split($delimiter)
$preReleaseLabelName = Convert-Label -Label $preReleaseLabel[0]
$preReleaseLabelVersion = $preReleaseLabel[1]
$nativeVersion += "${preReleaseLabelName}${preReleaseLabelVersion}"
}
return $nativeVersion
}