diff --git a/images/macos/provision/core/commonutils.sh b/images/macos/provision/core/commonutils.sh index 9b32d5c2..5b3522f5 100644 --- a/images/macos/provision/core/commonutils.sh +++ b/images/macos/provision/core/commonutils.sh @@ -22,7 +22,6 @@ binst_common_utils=( github/gh/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..c01a4b97 --- /dev/null +++ b/images/macos/provision/core/pipx-packages.sh @@ -0,0 +1,25 @@ +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="/opt/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 + + # Run tests to determine that the software installed as expected + cmd=$(jq -r ".pipx[] | select(.package == \"$package\") .cmd" $toolset) + if ! command -v $cmd; then + echo "$package was not installed" + exit 1 + 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 41488642..5bda9ef3 100755 --- a/images/macos/provision/core/python.sh +++ b/images/macos/provision/core/python.sh @@ -7,7 +7,19 @@ echo "Brew Installing Python 3" /usr/local/bin/brew install python3 echo "Brew Installing Python 2" -# Create local tap with formula due to python2 formula depreciation +# Create local tap with formula due to python2 formula depreciation /usr/local/bin/brew tap-new local/python2 FORMULA_PATH=$(/usr/local/bin/brew extract python@2 local/python2 | grep "Homebrew/Library/Taps") /usr/local/bin/brew install $FORMULA_PATH + +echo "Installing pipx" +export PIPX_BIN_DIR=/opt/pipx_bin +export PIPX_HOME=/opt/pipx + +brew install pipx +python3 -m pipx ensurepath + +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..5c518d16 100644 --- a/images/macos/software-report/SoftwareReport.Common.psm1 +++ b/images/macos/software-report/SoftwareReport.Common.psm1 @@ -96,6 +96,10 @@ function Get-PipVersion { return "${versionPart1} ${versionPart2} ${versionPart3}" } +function Get-PipxVersion { + return "Pipx $(pipx --version 2> $null)" +} + 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 87c94459..40214d7a 100644 --- a/images/macos/software-report/SoftwareReport.Generator.ps1 +++ b/images/macos/software-report/SoftwareReport.Generator.ps1 @@ -81,6 +81,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 @@ -97,6 +98,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.14.json b/images/macos/templates/macOS-10.14.json index 269ffa71..3cb0b070 100644 --- a/images/macos/templates/macOS-10.14.json +++ b/images/macos/templates/macOS-10.14.json @@ -196,6 +196,13 @@ "execute_command": "chmod +x {{ .Path }}; {{ .Vars }} pwsh -f {{ .Path }}", "scripts": "./provision/core/toolset.ps1" }, + { + "type": "shell", + "execute_command": "chmod +x {{ .Path }}; {{ .Vars }} {{ .Path }}", + "scripts": [ + "./provision/core/pipx-packages.sh" + ] + }, { "type": "shell", "execute_command": "ruby {{ .Path }}", diff --git a/images/macos/templates/macOS-10.15.json b/images/macos/templates/macOS-10.15.json index 3dcc3d33..65a0d12d 100644 --- a/images/macos/templates/macOS-10.15.json +++ b/images/macos/templates/macOS-10.15.json @@ -195,6 +195,13 @@ "execute_command": "chmod +x {{ .Path }}; {{ .Vars }} pwsh -f {{ .Path }}", "scripts": "./provision/core/toolset.ps1" }, + { + "type": "shell", + "execute_command": "chmod +x {{ .Path }}; {{ .Vars }} {{ .Path }}", + "scripts": [ + "./provision/core/pipx-packages.sh" + ] + }, { "type": "shell", "execute_command": "ruby {{ .Path }}", diff --git a/images/macos/templates/macOS-11.0.json b/images/macos/templates/macOS-11.0.json index 6da9df38..c732f799 100644 --- a/images/macos/templates/macOS-11.0.json +++ b/images/macos/templates/macOS-11.0.json @@ -192,6 +192,13 @@ "execute_command": "chmod +x {{ .Path }}; {{ .Vars }} pwsh -f {{ .Path }}", "scripts": "./provision/core/toolset.ps1" }, + { + "type": "shell", + "execute_command": "chmod +x {{ .Path }}; {{ .Vars }} {{ .Path }}", + "scripts": [ + "./provision/core/pipx-packages.sh" + ] + }, { "type": "shell", "execute_command": "ruby {{ .Path }}", diff --git a/images/macos/toolsets/toolset-10.14.json b/images/macos/toolsets/toolset-10.14.json index e868f769..fc1d44af 100644 --- a/images/macos/toolsets/toolset-10.14.json +++ b/images/macos/toolsets/toolset-10.14.json @@ -257,5 +257,11 @@ "1.15.*" ] } + ], + "pipx": [ + { + "package": "yamllint", + "cmd": "yamllint" + } ] } \ 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 8497a710..e754bacf 100644 --- a/images/macos/toolsets/toolset-10.15.json +++ b/images/macos/toolsets/toolset-10.15.json @@ -26,28 +26,28 @@ "mono":"6.12", "ios": "14.0", "mac": "6.20", - "android": "11.0" + "android": "11.0" }, { "symlink": "6_12_0", "mono":"6.12", "ios": "13.20", "mac": "6.20", - "android": "11.0" + "android": "11.0" }, { "symlink": "6_10_0", "mono":"6.10", "ios": "13.18", "mac": "6.18", - "android": "10.3" + "android": "10.3" }, { "symlink": "6_8_1", "mono":"6.8", "ios": "13.16", "mac": "6.16", - "android": "10.2" + "android": "10.2" }, { "symlink": "6_8_0", @@ -166,5 +166,11 @@ "1.15.*" ] } + ], + "pipx": [ + { + "package": "yamllint", + "cmd": "yamllint" + } ] } \ 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 725da218..8a739f91 100644 --- a/images/macos/toolsets/toolset-11.0.json +++ b/images/macos/toolsets/toolset-11.0.json @@ -26,14 +26,14 @@ "mono":"6.12", "ios": "14.0", "mac": "6.20", - "android": "11.0" + "android": "11.0" }, { "symlink": "6_12_0", "mono":"6.12", "ios": "13.20", "mac": "6.20", - "android": "11.0" + "android": "11.0" } ] }, @@ -91,5 +91,11 @@ "1.15.*" ] } + ], + "pipx": [ + { + "package": "yamllint", + "cmd": "yamllint" + } ] } \ No newline at end of file