Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
d406362
Add support of unstable versions to package generation (#2)
vmapetr Jul 13, 2020
5ca4852
Add support of symver versions to Python setup scripts and tests
Jul 13, 2020
81b6d42
Fix tests
Jul 13, 2020
6e5b81d
Fix test naming
Jul 13, 2020
41419c2
Fix comments
Jul 13, 2020
b5418c7
Merge pull request #3 from akv-platform/v-mazhuk/add-support-of-unsta…
MaksimZhukov Jul 14, 2020
f27be64
Update git submodule
Jul 14, 2020
d7a830f
Merge pull request #4 from akv-platform/v-mazhuk/update-submodule
MaksimZhukov Jul 14, 2020
8c6df38
Update config json
Jul 14, 2020
ea17357
Increase numbers
Jul 14, 2020
21eb922
Update regex
Jul 14, 2020
c1b394d
Merge pull request #6 from akv-platform/v-mazhuk/update-config
MaksimZhukov Jul 14, 2020
0a0379d
add tests
Jul 14, 2020
a680a6a
Merge branch 'master' into v-malob/add-test
Jul 14, 2020
4a9f1d3
Update ManifestConfig.Tests.ps1
Jul 14, 2020
b7df796
Update manifest-config-validation.yml
Jul 14, 2020
7421f80
Update manifest-config-validation.yml
Jul 14, 2020
c01f4df
Update manifest-config-validation.yml
Jul 14, 2020
ef80514
Merge pull request #7 from akv-platform/v-malob/add-test
MaksimZhukov Jul 14, 2020
1e03927
Update submodules
Jul 14, 2020
937576a
Merge pull request #8 from akv-platform/v-mazhuk/update-git-modules
Jul 14, 2020
8652615
Fix comments
Jul 15, 2020
790458a
Update manifest-config-validation.yml
Jul 15, 2020
f14d9ad
Update ManifestConfig.Tests.ps1
Jul 15, 2020
aad13bc
Change branch
Jul 15, 2020
da2b215
Merge pull request #9 from akv-platform/v-mazhuk/fix-pr-comments
MaksimZhukov Jul 15, 2020
26a3fbb
Remove redundant string
Jul 15, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/manifest-config-validation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Manifest config tests
on:
pull_request:
branches:
- main
paths-ignore:
- 'versions-manifest.json'

jobs:
RunTests:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: true

- name: Install Pester
shell: pwsh
run: |
Install-Module Pester -Force -Scope CurrentUser

- name: Run tests
shell: pwsh
run: |
Import-Module Pester
Invoke-Pester -Configuration @{
Run = @{
Path = "tests/ManifestConfig.Tests.ps1"
Exit = $true
}
}
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "helpers"]
path = helpers
url = https://github.com/actions/versions-package-tools
branch = master
branch = main
1 change: 1 addition & 0 deletions azure-pipelines/templates/build-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
targetType: filePath
filePath: './builders/build-python.ps1'
arguments: '-Version $(VERSION) -Platform $(Platform) -Architecture $(Architecture)'
pwsh: true

- task: PublishPipelineArtifact@1
displayName: 'Publish Artifact: Python $(VERSION)'
Expand Down
2 changes: 2 additions & 0 deletions azure-pipelines/templates/test-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ jobs:
pool:
name: Azure Pipelines
vmImage: $(VmImage)
variables:
TestRunTitle: 'python-$(Platform)-$(Architecture)'
steps:
- checkout: self
submodules: true
Expand Down
10 changes: 5 additions & 5 deletions builders/build-python.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@ Required parameter. The platform for which Python will be built.
#>

param(
[Parameter (Mandatory=$true)][Version] $Version,
[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 {
<#
Expand All @@ -49,13 +50,12 @@ function Get-PythonBuilder {

#>

param (
[version] $Version,
param(
[semver] $Version,
[string] $Architecture,
[string] $Platform
)

$Platform = $Platform.ToLower()
if ($Platform -match 'win32') {
$builder = [WinPythonBuilder]::New($Version, $Architecture, $Platform)
} elseif ($Platform -match 'linux') {
Expand All @@ -71,5 +71,5 @@ function Get-PythonBuilder {
}

### Create Python builder instance, and build artifact
$Builder = Get-PythonBuilder -Version $Version -Architecture $Architecture -Platform $Platform
$Builder = Get-PythonBuilder -Version $Version -Architecture $Architecture -Platform $Platform
$Builder.Build()
2 changes: 1 addition & 1 deletion builders/macos-python-builder.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class macOSPythonBuilder : NixPythonBuilder {
#>

macOSPythonBuilder(
[version] $version,
[semver] $version,
[string] $architecture,
[string] $platform
) : Base($version, $architecture, $platform) { }
Expand Down
11 changes: 5 additions & 6 deletions builders/nix-python-builder.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,12 @@ class NixPythonBuilder : PythonBuilder {
[string] $OutputArtifactName

NixPythonBuilder(
[version] $version,
[semver] $version,
[string] $architecture,
[string] $platform
) : Base($version, $architecture, $platform) {
$this.InstallationTemplateName = "nix-setup-template.sh"
$this.InstallationScriptName = "setup.sh"

$this.OutputArtifactName = "python-$Version-$Platform-$Architecture.tar.gz"
}

Expand All @@ -50,8 +49,10 @@ class NixPythonBuilder : PythonBuilder {
#>

$base = $this.GetBaseUri()
$versionName = $this.GetBaseVersion()
$nativeVersion = Convert-Version -version $this.Version

return "${base}/$($this.Version)/Python-$($this.Version).tgz"
return "${base}/${versionName}/Python-${nativeVersion}.tgz"
}

[string] GetPythonBinary() {
Expand Down Expand Up @@ -95,9 +96,7 @@ class NixPythonBuilder : PythonBuilder {
$installationTemplateContent = Get-Content -Path $installationTemplateLocation -Raw

$variablesToReplace = @{
"{{__VERSION_MAJOR__}}" = $this.Version.Major;
"{{__VERSION_MINOR__}}" = $this.Version.Minor;
"{{__VERSION_BUILD__}}" = $this.Version.Build;
"{{__VERSION_FULL__}}" = $this.Version;
}
$variablesToReplace.keys | ForEach-Object { $installationTemplateContent = $installationTemplateContent.Replace($_, $variablesToReplace[$_]) }

Expand Down
22 changes: 16 additions & 6 deletions builders/python-builder.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class PythonBuilder {

#>

[version] $Version
[semver] $Version
[string] $Architecture
[string] $Platform
[string] $HostedToolcacheLocation
Expand All @@ -38,17 +38,17 @@ class PythonBuilder {
[string] $ArtifactFolderLocation
[string] $InstallationTemplatesLocation

PythonBuilder ([version] $version, [string] $architecture, [string] $platform) {
$this.Version = $version
$this.Architecture = $architecture
$this.Platform = $platform
PythonBuilder ([semver] $version, [string] $architecture, [string] $platform) {
$this.InstallationTemplatesLocation = Join-Path -Path $PSScriptRoot -ChildPath "../installers"

$this.HostedToolcacheLocation = $env:AGENT_TOOLSDIRECTORY
$this.TempFolderLocation = $env:BUILD_SOURCESDIRECTORY
$this.WorkFolderLocation = $env:BUILD_BINARIESDIRECTORY
$this.ArtifactFolderLocation = $env:BUILD_STAGINGDIRECTORY

$this.InstallationTemplatesLocation = Join-Path -Path $PSScriptRoot -ChildPath "../installers"
$this.Version = $version
$this.Architecture = $architecture
$this.Platform = $platform
}

[uri] GetBaseUri() {
Expand Down Expand Up @@ -79,11 +79,21 @@ class PythonBuilder {
return "$pythonToolcacheLocation/$($this.Version)/$($this.Architecture)"
}

[string] GetBaseVersion() {
<#
.SYNOPSIS
Return Major.Minor.Patch version string.
#>

return "$($this.Version.Major).$($this.Version.Minor).$($this.Version.Patch)"
}

[void] PreparePythonToolcacheLocation() {
<#
.SYNOPSIS
Prepare system hostedtoolcache folder for new Python version.
#>

$pythonBinariesLocation = $this.GetFullPythonToolcacheLocation()

if (Test-Path $pythonBinariesLocation) {
Expand Down
45 changes: 45 additions & 0 deletions builders/python-version.psm1
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
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
}
3 changes: 2 additions & 1 deletion builders/ubuntu-python-builder.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class UbuntuPythonBuilder : NixPythonBuilder {
#>

UbuntuPythonBuilder(
[version] $version,
[semver] $version,
[string] $architecture,
[string] $platform
) : Base($version, $architecture, $platform) { }
Expand Down Expand Up @@ -68,6 +68,7 @@ class UbuntuPythonBuilder : NixPythonBuilder {
} else {
$tkinterInstallString = "sudo apt install -y python-tk tk-dev"
}

Execute-Command -Command $tkinterInstallString

### Install dependent packages
Expand Down
6 changes: 4 additions & 2 deletions builders/win-python-builder.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class WinPythonBuilder : PythonBuilder {
[string] $OutputArtifactName

WinPythonBuilder(
[version] $version,
[semver] $version,
[string] $architecture,
[string] $platform
) : Base($version, $architecture, $platform) {
Expand Down Expand Up @@ -72,10 +72,12 @@ class WinPythonBuilder : PythonBuilder {
#>

$base = $this.GetBaseUri()
$versionName = $this.GetBaseVersion()
$nativeVersion = Convert-Version -version $this.Version
$architecture = $this.GetArchitectureExtension()
$extension = $this.GetPythonExtension()

$uri = "${base}/$($this.Version)/python-$($this.Version)${architecture}${extension}"
$uri = "${base}/${versionName}/python-${nativeVersion}${architecture}${extension}"

return $uri
}
Expand Down
8 changes: 4 additions & 4 deletions config/python-manifest-config.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"regex": "python-\\d+\\.\\d+\\.\\d+-(\\w+)-([\\w\\.]+)?-?(x\\d+)",
"regex": "python-\\d+\\.\\d+\\.\\d+-(\\w+\\.\\d+)?-?(\\w+)-(\\d+\\.\\d+)?-?(x\\d+)",
"groups": {
"arch": 3,
"platform": 1,
"platform_version": 2
"arch": 4,
"platform": 2,
"platform_version": 3
}
}
7 changes: 3 additions & 4 deletions installers/nix-setup-template.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
set -e

MAJOR_VERSION="{{__VERSION_MAJOR__}}"
MINOR_VERSION="{{__VERSION_MINOR__}}"
BUILD_VERSION="{{__VERSION_BUILD__}}"
PYTHON_FULL_VERSION="{{__VERSION_FULL__}}"
MAJOR_VERSION=$(echo $PYTHON_FULL_VERSION | cut -d '.' -f 1)
MINOR_VERSION=$(echo $PYTHON_FULL_VERSION | cut -d '.' -f 2)

PYTHON_MAJOR=python$MAJOR_VERSION
PYTHON_MAJOR_DOT_MINOR=python$MAJOR_VERSION.$MINOR_VERSION
PYTHON_MAJORMINOR=python$MAJOR_VERSION$MINOR_VERSION
PYTHON_FULL_VERSION=$MAJOR_VERSION.$MINOR_VERSION.$BUILD_VERSION

if [ -z ${AGENT_TOOLSDIRECTORY+x} ]; then
# No AGENT_TOOLSDIRECTORY on GitHub images
Expand Down
Loading