Files
python-versions/builders/build-python.ps1
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

76 lines
2.3 KiB
PowerShell

using module "./builders/win-python-builder.psm1"
using module "./builders/ubuntu-python-builder.psm1"
using module "./builders/macos-python-builder.psm1"
<#
.SYNOPSIS
Generate Python artifact.
.DESCRIPTION
Main script that creates instance of PythonBuilder and builds of Python using specified parameters.
.PARAMETER Version
Required parameter. The version with which Python will be built.
.PARAMETER Architecture
Optional parameter. The architecture with which Python will be built. Using x64 by default.
.PARAMETER Platform
Required parameter. The platform for which Python will be built.
#>
param(
[Parameter (Mandatory=$true)][semver] $Version,
[Parameter (Mandatory=$true)][string] $Platform,
[string] $Architecture = "x64"
)
Import-Module (Join-Path $PSScriptRoot "../helpers" | Join-Path -ChildPath "common-helpers.psm1") -DisableNameChecking
Import-Module (Join-Path $PSScriptRoot "../helpers" | Join-Path -ChildPath "nix-helpers.psm1") -DisableNameChecking
Import-Module (Join-Path $PSScriptRoot "../helpers" | Join-Path -ChildPath "win-helpers.psm1") -DisableNameChecking
Import-Module (Join-Path $PSScriptRoot "python-version.psm1") -DisableNameChecking
function Get-PythonBuilder {
<#
.SYNOPSIS
Wrapper for class constructor to simplify importing PythonBuilder.
.DESCRIPTION
Create instance of PythonBuilder with specified parameters.
.PARAMETER Version
The version with which Python will be built.
.PARAMETER Architecture
The architecture with which Python will be built.
.PARAMETER Platform
The platform for which Python will be built.
#>
param(
[semver] $Version,
[string] $Architecture,
[string] $Platform
)
if ($Platform -match 'win32') {
$builder = [WinPythonBuilder]::New($Version, $Architecture, $Platform)
} elseif ($Platform -match 'linux') {
$builder = [UbuntuPythonBuilder]::New($Version, $Architecture, $Platform)
} elseif ($Platform -match 'darwin') {
$builder = [macOSPythonBuilder]::New($Version, $Architecture, $Platform)
} else {
Write-Host "##vso[task.logissue type=error;] Invalid platform: $Platform"
exit 1
}
return $builder
}
### Create Python builder instance, and build artifact
$Builder = Get-PythonBuilder -Version $Version -Architecture $Architecture -Platform $Platform
$Builder.Build()