mirror of
https://github.com/actions/runner-images-sangeeth.git
synced 2025-12-20 06:29:50 +00:00
[macos] Remove python2 UnixTools and adjust brew symlinks (#8452)
This commit is contained in:
committed by
GitHub
parent
060ad1383a
commit
b3b303d294
@@ -7,7 +7,18 @@ if is_Monterey || is_BigSur; then
|
|||||||
echo "Install latest Python 2"
|
echo "Install latest Python 2"
|
||||||
Python2Url="https://www.python.org/ftp/python/2.7.18/python-2.7.18-macosx10.9.pkg"
|
Python2Url="https://www.python.org/ftp/python/2.7.18/python-2.7.18-macosx10.9.pkg"
|
||||||
download_with_retries $Python2Url "/tmp" "python2.pkg"
|
download_with_retries $Python2Url "/tmp" "python2.pkg"
|
||||||
sudo installer -pkg /tmp/python2.pkg -target /
|
|
||||||
|
sudo installer -showChoiceChangesXML -pkg /tmp/python2.pkg -target / > /tmp/python2_choices.xml
|
||||||
|
|
||||||
|
# To avoid symlink conflicts, remove tools installation in /usr/local/bin using installer choices
|
||||||
|
xmllint --shell /tmp/python2_choices.xml <<EOF
|
||||||
|
cd //array/dict[string[text()='org.python.Python.PythonUnixTools-2.7']]/integer
|
||||||
|
set 0
|
||||||
|
save
|
||||||
|
EOF
|
||||||
|
|
||||||
|
sudo installer -applyChoiceChangesXML /tmp/python2_choices.xml -pkg /tmp/python2.pkg -target /
|
||||||
|
|
||||||
pip install --upgrade pip
|
pip install --upgrade pip
|
||||||
|
|
||||||
echo "Install Python2 certificates"
|
echo "Install Python2 certificates"
|
||||||
@@ -19,10 +30,8 @@ if is_Veertu; then
|
|||||||
close_finder_window
|
close_finder_window
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Explicitly overwrite symlinks created by Python2 such as /usr/local/bin/2to3 since they conflict with symlinks from Python3
|
|
||||||
# https://github.com/actions/runner-images/issues/2322
|
|
||||||
echo "Brew Installing Python 3"
|
echo "Brew Installing Python 3"
|
||||||
brew_smart_install "python@3.11" || brew link --overwrite python@3.11
|
brew_smart_install "python@3.11"
|
||||||
|
|
||||||
echo "Installing pipx"
|
echo "Installing pipx"
|
||||||
export PIPX_BIN_DIR=/usr/local/opt/pipx_bin
|
export PIPX_BIN_DIR=/usr/local/opt/pipx_bin
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ function Get-PipVersion {
|
|||||||
[int] $Version
|
[int] $Version
|
||||||
)
|
)
|
||||||
|
|
||||||
$command = If ($Version -eq 2) { "pip --version" } Else { "pip3 --version" }
|
$command = If ($Version -eq 2) { "/Library/Frameworks/Python.framework/Versions/2.7/bin/pip --version" } Else { "pip3 --version" }
|
||||||
$commandOutput = Run-Command $command
|
$commandOutput = Run-Command $command
|
||||||
$versionPart1 = $commandOutput | Take-Part -Part 1
|
$versionPart1 = $commandOutput | Take-Part -Part 1
|
||||||
$versionPart2 = $commandOutput | Take-Part -Part 4
|
$versionPart2 = $commandOutput | Take-Part -Part 4
|
||||||
@@ -192,7 +192,7 @@ function Get-PerlVersion {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function Get-PythonVersion {
|
function Get-PythonVersion {
|
||||||
$pythonVersion = Run-Command "python --version"
|
$pythonVersion = Run-Command "/Library/Frameworks/Python.framework/Versions/2.7/bin/python --version"
|
||||||
return ($pythonVersion -replace "^Python").Trim()
|
return ($pythonVersion -replace "^Python").Trim()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,19 +30,11 @@ Describe "Python3" -Skip:($os.IsVenturaArm64) {
|
|||||||
|
|
||||||
Describe "Python2" -Skip:($os.IsVenturaArm64 -or $os.IsVentura) {
|
Describe "Python2" -Skip:($os.IsVenturaArm64 -or $os.IsVentura) {
|
||||||
It "Python 2 is available" {
|
It "Python 2 is available" {
|
||||||
"python --version" | Should -ReturnZeroExitCode
|
"/Library/Frameworks/Python.framework/Versions/2.7/bin/python --version" | Should -ReturnZeroExitCode
|
||||||
}
|
|
||||||
|
|
||||||
It "Python 2 is real 2.x" {
|
|
||||||
(Get-CommandResult "python --version").Output | Should -BeLike "Python 2.*"
|
|
||||||
}
|
|
||||||
|
|
||||||
It "Python 2 is installed under /usr/local/bin" {
|
|
||||||
Get-WhichTool "python" | Should -BeLike "/usr/local/bin*"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Pip 2 is available" {
|
It "Pip 2 is available" {
|
||||||
"pip --version" | Should -ReturnZeroExitCode
|
"/Library/Frameworks/Python.framework/Versions/2.7/bin/pip --version" | Should -ReturnZeroExitCode
|
||||||
}
|
}
|
||||||
|
|
||||||
It "2to3 symlink does not point to Python 2" {
|
It "2to3 symlink does not point to Python 2" {
|
||||||
|
|||||||
Reference in New Issue
Block a user