From ed18dfab032f4a5e9ec1ea2927224fc8314806b5 Mon Sep 17 00:00:00 2001 From: Erik Bershel <110455084+erik-bershel@users.noreply.github.com> Date: Fri, 10 Oct 2025 17:19:38 +0200 Subject: [PATCH] [macOS] Update Python installer script (#13157) --- images/macos/scripts/build/install-python.sh | 14 ++++++++++++-- images/macos/scripts/tests/Python.Tests.ps1 | 2 +- images/macos/toolsets/toolset-14.json | 3 +++ images/macos/toolsets/toolset-15.json | 3 +++ images/macos/toolsets/toolset-26.json | 3 +++ 5 files changed, 22 insertions(+), 3 deletions(-) diff --git a/images/macos/scripts/build/install-python.sh b/images/macos/scripts/build/install-python.sh index 084f88b89..0188382f3 100644 --- a/images/macos/scripts/build/install-python.sh +++ b/images/macos/scripts/build/install-python.sh @@ -11,9 +11,19 @@ echo "Installing Python Tooling" # Close Finder window close_finder_window -echo "Brew Installing Python 3" -brew_smart_install "python@3.12" +# Installing latest Homebrew Python 3 to handle python3 and pip3 symlinks +# When latest Python3 is installed as a dependency for other packages +# it does not create /usr/local/bin/python3 and /usr/local/bin/pip3 +echo "Brew Installing default Python 3" +brew_smart_install "python" +# Install specific Python version +# Update symlinks for python3 and pip3 to point to the specific version +toolsetVersion=$(get_toolset_value '.python.default') +echo "Installing Python $toolsetVersion" +brew_smart_install "python@$toolsetVersion" + +# Pipx has its own Python dependency echo "Installing pipx" if is_Arm64; then diff --git a/images/macos/scripts/tests/Python.Tests.ps1 b/images/macos/scripts/tests/Python.Tests.ps1 index 7b6a8c53a..0100e9caa 100644 --- a/images/macos/scripts/tests/Python.Tests.ps1 +++ b/images/macos/scripts/tests/Python.Tests.ps1 @@ -14,7 +14,7 @@ Describe "Python3" { } } else { It "Python 3 is installed under /usr/local/bin" { - Get-ToolPath "python3" | Should -BeLike "/usr/local/bin*" + Get-ToolPath "python3" | Should -BeLike "/usr/local/bin/*" } } diff --git a/images/macos/toolsets/toolset-14.json b/images/macos/toolsets/toolset-14.json index 33dfe5be9..bf94c2568 100644 --- a/images/macos/toolsets/toolset-14.json +++ b/images/macos/toolsets/toolset-14.json @@ -222,6 +222,9 @@ "fastlane" ] }, + "python": { + "default": "3.13" + }, "toolcache": [ { "name": "Python", diff --git a/images/macos/toolsets/toolset-15.json b/images/macos/toolsets/toolset-15.json index 5d3c259f6..be5c180e3 100644 --- a/images/macos/toolsets/toolset-15.json +++ b/images/macos/toolsets/toolset-15.json @@ -226,6 +226,9 @@ "fastlane" ] }, + "python": { + "default": "3.13" + }, "toolcache": [ { "name": "Python", diff --git a/images/macos/toolsets/toolset-26.json b/images/macos/toolsets/toolset-26.json index 0a346018b..34c56fb58 100644 --- a/images/macos/toolsets/toolset-26.json +++ b/images/macos/toolsets/toolset-26.json @@ -130,6 +130,9 @@ "fastlane" ] }, + "python": { + "default": "3.13" + }, "toolcache": [ { "name": "Python",