diff --git a/images/win/scripts/Installers/Install-Pipx.ps1 b/images/win/scripts/Installers/Install-Pipx.ps1 new file mode 100644 index 00000000..a78cf456 --- /dev/null +++ b/images/win/scripts/Installers/Install-Pipx.ps1 @@ -0,0 +1,14 @@ +# Set custom directorys for pipx +$env:PIPX_BIN_DIR = "${env:ProgramFiles(x86)}\pipx_bin" +$env:PIPX_HOME = "${env:ProgramFiles(x86)}\pipx" + +# Install pipx +pip install pipx + +# Set environment variables +Add-MachinePathItem "${env:PIPX_BIN_DIR}" +Set-SystemVariable -SystemVariable PIPX_BIN_DIR -Value $env:PIPX_BIN_DIR +Set-SystemVariable -SystemVariable PIPX_HOME -Value $env:PIPX_HOME + +# Test pipx +Invoke-PesterTests -TestFile "Tools" -TestName "Pipx" \ No newline at end of file diff --git a/images/win/scripts/Installers/Install-PipxPackages.ps1 b/images/win/scripts/Installers/Install-PipxPackages.ps1 new file mode 100644 index 00000000..e83f5add --- /dev/null +++ b/images/win/scripts/Installers/Install-PipxPackages.ps1 @@ -0,0 +1,12 @@ +$pipxToolset = (Get-ToolsetContent).pipx +foreach($tool in $pipxToolset) { + if ($tool.python) { + $pythonPath = (Get-Item -Path "${env:AGENT_TOOLSDIRECTORY}\Python\${tool.python}.*\x64\python-${tool.python}*").FullName + Write-Host "Install ${tool.package} into python ${tool.python}" + pipx install $tool.package --python $pythonPath + } else { + Write-Host "Install ${tool.package} into default python" + pipx install $tool.package + } +} +Invoke-PesterTests -TestFile "PipxPackages" \ No newline at end of file diff --git a/images/win/scripts/Installers/Install-YAMLLint.ps1 b/images/win/scripts/Installers/Install-YAMLLint.ps1 deleted file mode 100644 index 1ebc09a3..00000000 --- a/images/win/scripts/Installers/Install-YAMLLint.ps1 +++ /dev/null @@ -1,3 +0,0 @@ -pip install yamllint - -Invoke-PesterTests -TestFile "Tools" -TestName "yamllint" \ No newline at end of file diff --git a/images/win/scripts/SoftwareReport/SoftwareReport.Common.psm1 b/images/win/scripts/SoftwareReport/SoftwareReport.Common.psm1 index ea56e1ff..72a33619 100644 --- a/images/win/scripts/SoftwareReport/SoftwareReport.Common.psm1 +++ b/images/win/scripts/SoftwareReport/SoftwareReport.Common.psm1 @@ -292,3 +292,8 @@ function Get-ShellTarget { function Get-YAMLLintVersion { yamllint --version } + +function Get-PipxVersion { + $pipxVersion = pipx --version + return "Pipx $pipxVersion" +} diff --git a/images/win/scripts/SoftwareReport/SoftwareReport.Generator.ps1 b/images/win/scripts/SoftwareReport/SoftwareReport.Generator.ps1 index aba000b7..fff45919 100644 --- a/images/win/scripts/SoftwareReport/SoftwareReport.Generator.ps1 +++ b/images/win/scripts/SoftwareReport/SoftwareReport.Generator.ps1 @@ -59,7 +59,8 @@ $markdown += New-MDList -Style Unordered -Lines @( (Get-RubyGemsVersion), (Get-HelmVersion), (Get-ComposerVersion), - (Get-NugetVersion) + (Get-NugetVersion), + (Get-PipxVersion) ) $markdown += New-MDHeader "Project Management" -Level 3 diff --git a/images/win/scripts/Tests/PipxPackages.Tests.ps1 b/images/win/scripts/Tests/PipxPackages.Tests.ps1 new file mode 100644 index 00000000..41041078 --- /dev/null +++ b/images/win/scripts/Tests/PipxPackages.Tests.ps1 @@ -0,0 +1,7 @@ +Describe "PipxPackages" { + $pipxToolset = (Get-ToolsetContent).pipx + $testCases = $pipxToolset | ForEach-Object { @{package = $_.package; cmd = $_.cmd} } + It "" -TestCases $testCases { + "$cmd" | Should -ReturnZeroExitCode + } +} \ No newline at end of file diff --git a/images/win/scripts/Tests/Tools.Tests.ps1 b/images/win/scripts/Tests/Tools.Tests.ps1 index cbb0609a..a0024532 100644 --- a/images/win/scripts/Tests/Tools.Tests.ps1 +++ b/images/win/scripts/Tests/Tools.Tests.ps1 @@ -214,12 +214,6 @@ Describe "ServiceFabricSDK" { } } -Describe "yamllint" { - It "yamllint" { - "yamllint --version" | Should -ReturnZeroExitCode - } -} - Describe "Svn" { It "svn" { "svn --version --quiet" | Should -ReturnZeroExitCode @@ -269,3 +263,9 @@ Describe "Zstd" { "zstd -V" | Should -ReturnZeroExitCode } } + +Describe "Pipx" { + It "Pipx" { + "pipx --version" | Should -ReturnZeroExitCode + } +} diff --git a/images/win/toolsets/toolset-2016.json b/images/win/toolsets/toolset-2016.json index 8b6f32f3..f5d30694 100644 --- a/images/win/toolsets/toolset-2016.json +++ b/images/win/toolsets/toolset-2016.json @@ -237,5 +237,11 @@ "mcr.microsoft.com/dotnet/framework/runtime:4.8-windowsservercore-ltsc2016", "microsoft/aspnetcore-build:1.0-2.0" ] - } + }, + "pipx": [ + { + "package": "yamllint", + "cmd": "yamllint --version" + } + ] } diff --git a/images/win/toolsets/toolset-2019.json b/images/win/toolsets/toolset-2019.json index a056fd88..ebb7aa82 100644 --- a/images/win/toolsets/toolset-2019.json +++ b/images/win/toolsets/toolset-2019.json @@ -280,5 +280,11 @@ "mcr.microsoft.com/dotnet/framework/runtime:4.8-windowsservercore-ltsc2019", "microsoft/aspnetcore-build:1.0-2.0" ] - } + }, + "pipx": [ + { + "package": "yamllint", + "cmd": "yamllint --version" + } + ] } diff --git a/images/win/windows2016.json b/images/win/windows2016.json index 8c1314d6..8136ebd4 100644 --- a/images/win/windows2016.json +++ b/images/win/windows2016.json @@ -235,8 +235,9 @@ "{{ template_dir }}/scripts/Installers/Install-PyPy.ps1", "{{ template_dir }}/scripts/Installers/Install-Toolset.ps1", "{{ template_dir }}/scripts/Installers/Configure-Toolset.ps1", - "{{ template_dir }}/scripts/Installers/Install-YAMLLint.ps1", - "{{ template_dir }}/scripts/Installers/Update-AndroidSDK.ps1" + "{{ template_dir }}/scripts/Installers/Update-AndroidSDK.ps1", + "{{ template_dir }}/scripts/Installers/Install-Pipx.ps1", + "{{ template_dir }}/scripts/Installers/Install-PipxPackages.ps1" ] }, { diff --git a/images/win/windows2019.json b/images/win/windows2019.json index a002f77f..f20e050c 100644 --- a/images/win/windows2019.json +++ b/images/win/windows2019.json @@ -249,9 +249,10 @@ "{{ template_dir }}/scripts/Installers/Install-PyPy.ps1", "{{ template_dir }}/scripts/Installers/Install-Toolset.ps1", "{{ template_dir }}/scripts/Installers/Configure-Toolset.ps1", - "{{ template_dir }}/scripts/Installers/Install-YAMLLint.ps1", "{{ template_dir }}/scripts/Installers/Update-AndroidSDK.ps1", - "{{ template_dir }}/scripts/Installers/Install-AzureModules.ps1" + "{{ template_dir }}/scripts/Installers/Install-AzureModules.ps1", + "{{ template_dir }}/scripts/Installers/Install-Pipx.ps1", + "{{ template_dir }}/scripts/Installers/Install-PipxPackages.ps1" ] }, {