diff --git a/images/macos/provision/core/commonutils.sh b/images/macos/provision/core/commonutils.sh index c7e93496..a479974c 100644 --- a/images/macos/provision/core/commonutils.sh +++ b/images/macos/provision/core/commonutils.sh @@ -21,7 +21,6 @@ binst_common_utils=( gh p7zip ant - yamllint aria2 ) diff --git a/images/macos/provision/core/pipx-packages.sh b/images/macos/provision/core/pipx-packages.sh new file mode 100644 index 00000000..658600fa --- /dev/null +++ b/images/macos/provision/core/pipx-packages.sh @@ -0,0 +1,18 @@ +source ~/utils/utils.sh + +export PATH="$PATH:/opt/pipx_bin" + +toolset=$(get_toolset_path) +pipx_packages=$(jq -r ".pipx[] .package" $toolset) + +for package in $pipx_packages; do + python_version=$(jq -r ".pipx[] | select(.package == \"$package\") .python" $toolset) + if [ "$python_version" != "null" ]; then + python_path="$HOME/hostedtoolcache/Python/$python_version*/x64/bin/python$python_version" + echo "Install $package into python $python_path" + pipx install $package --python $python_path + else + echo "Install $package into default python" + pipx install $package + fi +done \ No newline at end of file diff --git a/images/macos/provision/core/python.sh b/images/macos/provision/core/python.sh index b4c64147..62922053 100755 --- a/images/macos/provision/core/python.sh +++ b/images/macos/provision/core/python.sh @@ -17,3 +17,13 @@ echo "Brew Installing Python 2" brew tap-new --no-git local/python2 FORMULA_PATH=$(brew extract python@2 local/python2 | grep "Homebrew/Library/Taps") brew install $FORMULA_PATH + +echo "Installing pipx" +export PIPX_BIN_DIR=/usr/local/opt/pipx_bin +export PIPX_HOME=/usr/local/opt/pipx + +brew install pipx + +echo "export PIPX_BIN_DIR=${PIPX_BIN_DIR}" >> "${HOME}/.bashrc" +echo "export PIPX_HOME=${PIPX_HOME}" >> "${HOME}/.bashrc" +echo 'export PATH="$PIPX_BIN_DIR:$PATH"' >> "${HOME}/.bashrc" diff --git a/images/macos/software-report/SoftwareReport.Common.psm1 b/images/macos/software-report/SoftwareReport.Common.psm1 index c3fe7517..7616b81b 100644 --- a/images/macos/software-report/SoftwareReport.Common.psm1 +++ b/images/macos/software-report/SoftwareReport.Common.psm1 @@ -96,6 +96,11 @@ function Get-PipVersion { return "${versionPart1} ${versionPart2} ${versionPart3}" } +function Get-PipxVersion { + $pipxVersion = Run-Command "pipx --version" -SuppressStderr + return "Pipx $pipxVersion" +} + function Get-NVMNodeVersionList { $nvmPath = Join-Path $env:HOME ".nvm" "nvm.sh" $nvmInitCommand = ". ${nvmPath} > /dev/null 2>&1 || true" diff --git a/images/macos/software-report/SoftwareReport.Generator.ps1 b/images/macos/software-report/SoftwareReport.Generator.ps1 index 9bcef14c..4eab767c 100644 --- a/images/macos/software-report/SoftwareReport.Generator.ps1 +++ b/images/macos/software-report/SoftwareReport.Generator.ps1 @@ -83,6 +83,7 @@ $npmVersion = Run-Command "npm --version" $yarnVersion = Run-Command "yarn --version" $nugetVersion = Run-Command "nuget help" | Select-Object -First 1 | Take-Part -Part 2 $pip3Version = Get-PipVersion -Version 3 +$pipxVersion = Get-PipxVersion $condaVersion = Invoke-Expression "conda --version" $rubyGemsVersion = Run-Command "gem --version" $composerVersion = Run-Command "composer --version" | Take-Part -Part 2 @@ -99,6 +100,7 @@ if ($os.IsLessThanBigSur) { $markdown += New-MDList -Style Unordered -Lines @( "Pip ${pip3Version}", + $pipxVersion, $bundlerVersion, "Carthage ${carthageVersion}", "CocoaPods ${cocoaPodsVersion}", diff --git a/images/macos/templates/macOS-10.13.json b/images/macos/templates/macOS-10.13.json index 35c7ef3c..9ebd56e6 100644 --- a/images/macos/templates/macOS-10.13.json +++ b/images/macos/templates/macOS-10.13.json @@ -181,7 +181,8 @@ "./provision/core/edge.sh", "./provision/core/firefox.sh", "./provision/core/toolcache-high-sierra.sh", - "./provision/core/pypy.sh" + "./provision/core/pypy.sh", + "./provision/core/pipx-packages.sh" ] }, { diff --git a/images/macos/templates/macOS-10.14.json b/images/macos/templates/macOS-10.14.json index 2687302e..c03cc72a 100644 --- a/images/macos/templates/macOS-10.14.json +++ b/images/macos/templates/macOS-10.14.json @@ -186,7 +186,8 @@ "./provision/core/miniconda.sh", "./provision/core/xcode-postbuild.sh", "./provision/core/toolcache.sh", - "./provision/core/pypy.sh" + "./provision/core/pypy.sh", + "./provision/core/pipx-packages.sh" ], "environment_vars": [ "GITHUB_FEED_TOKEN={{user `github_feed_token`}}" diff --git a/images/macos/templates/macOS-10.15.json b/images/macos/templates/macOS-10.15.json index a65bd72a..cf49ef57 100644 --- a/images/macos/templates/macOS-10.15.json +++ b/images/macos/templates/macOS-10.15.json @@ -185,7 +185,8 @@ "./provision/core/firefox.sh", "./provision/core/xcode-postbuild.sh", "./provision/core/toolcache.sh", - "./provision/core/pypy.sh" + "./provision/core/pypy.sh", + "./provision/core/pipx-packages.sh" ], "environment_vars": [ "GITHUB_FEED_TOKEN={{user `github_feed_token`}}" diff --git a/images/macos/templates/macOS-11.0.json b/images/macos/templates/macOS-11.0.json index 27f39bfb..585a9354 100644 --- a/images/macos/templates/macOS-11.0.json +++ b/images/macos/templates/macOS-11.0.json @@ -181,7 +181,8 @@ "./provision/core/chrome.sh", "./provision/core/edge.sh", "./provision/core/firefox.sh", - "./provision/core/toolcache.sh" + "./provision/core/toolcache.sh", + "./provision/core/pipx-packages.sh" ], "environment_vars": [ "GITHUB_FEED_TOKEN={{user `github_feed_token`}}" diff --git a/images/macos/tests/Linters.Tests.ps1 b/images/macos/tests/Linters.Tests.ps1 index 3b7b8e0d..31d3698c 100644 --- a/images/macos/tests/Linters.Tests.ps1 +++ b/images/macos/tests/Linters.Tests.ps1 @@ -3,10 +3,6 @@ Import-Module "$PSScriptRoot/../helpers/Tests.Helpers.psm1" $os = Get-OSVersion Describe "Linters" { - It "yamllint" { - "yamllint --version" | Should -ReturnZeroExitCode - } - It "SwiftLint" -Skip:($os.IsHighSierra) { "swiftlint version" | Should -ReturnZeroExitCode } diff --git a/images/macos/tests/PipxPackages.Tests.ps1 b/images/macos/tests/PipxPackages.Tests.ps1 new file mode 100644 index 00000000..ed981938 --- /dev/null +++ b/images/macos/tests/PipxPackages.Tests.ps1 @@ -0,0 +1,7 @@ +Describe "PipxPackages" { + $pipxToolset = Get-ToolsetValue "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/macos/tests/Python.Tests.ps1 b/images/macos/tests/Python.Tests.ps1 index 62460999..7a50a7ab 100644 --- a/images/macos/tests/Python.Tests.ps1 +++ b/images/macos/tests/Python.Tests.ps1 @@ -32,6 +32,10 @@ Describe "Python" { "pip3 --version" | Should -ReturnZeroExitCode } + It "Pipx is available" { + "pipx --version" | Should -ReturnZeroExitCode + } + It "Pip 3 and Python 3 came from the same brew formula" { $pip3Path = Split-Path (readlink (which pip3)) $python3Path = Split-Path (readlink (which python3)) diff --git a/images/macos/toolsets/toolset-10.13.json b/images/macos/toolsets/toolset-10.13.json index 6c12251b..3bf62968 100644 --- a/images/macos/toolsets/toolset-10.13.json +++ b/images/macos/toolsets/toolset-10.13.json @@ -194,5 +194,11 @@ "3.6" ] } + ], + "pipx": [ + { + "package": "yamllint", + "cmd": "yamllint --version" + } ] } \ No newline at end of file diff --git a/images/macos/toolsets/toolset-10.14.json b/images/macos/toolsets/toolset-10.14.json index 2abe9803..aa1b4101 100644 --- a/images/macos/toolsets/toolset-10.14.json +++ b/images/macos/toolsets/toolset-10.14.json @@ -254,5 +254,11 @@ "1.15.*" ] } + ], + "pipx": [ + { + "package": "yamllint", + "cmd": "yamllint --version" + } ] } \ No newline at end of file diff --git a/images/macos/toolsets/toolset-10.15.json b/images/macos/toolsets/toolset-10.15.json index fc0bf798..e041c15e 100644 --- a/images/macos/toolsets/toolset-10.15.json +++ b/images/macos/toolsets/toolset-10.15.json @@ -163,5 +163,11 @@ "1.15.*" ] } + ], + "pipx": [ + { + "package": "yamllint", + "cmd": "yamllint --version" + } ] } \ No newline at end of file diff --git a/images/macos/toolsets/toolset-11.0.json b/images/macos/toolsets/toolset-11.0.json index 5ff2280a..cb14b3a0 100644 --- a/images/macos/toolsets/toolset-11.0.json +++ b/images/macos/toolsets/toolset-11.0.json @@ -88,5 +88,11 @@ "1.15.*" ] } + ], + "pipx": [ + { + "package": "yamllint", + "cmd": "yamllint --version" + } ] } \ No newline at end of file