Skip to content

Commit f2b1fa1

Browse files
[macos] enable python3 (and pipx) on macOS13 (#7599)
1 parent 4ca8647 commit f2b1fa1

File tree

4 files changed

+39
-25
lines changed

4 files changed

+39
-25
lines changed

images/macos/provision/core/python.sh

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@ source ~/utils/utils.sh
33

44
echo "Installing Python Tooling"
55

6-
echo "Install latest Python 2"
7-
Python2Url="https://www.python.org/ftp/python/2.7.18/python-2.7.18-macosx10.9.pkg"
8-
download_with_retries $Python2Url "/tmp" "python2.pkg"
9-
sudo installer -pkg /tmp/python2.pkg -target /
10-
pip install --upgrade pip
11-
12-
echo "Install Python2 certificates"
13-
bash -c "/Applications/Python\ 2.7/Install\ Certificates.command"
6+
if ! is_Veertu; then
7+
echo "Install latest Python 2"
8+
Python2Url="https://www.python.org/ftp/python/2.7.18/python-2.7.18-macosx10.9.pkg"
9+
download_with_retries $Python2Url "/tmp" "python2.pkg"
10+
sudo installer -pkg /tmp/python2.pkg -target /
11+
pip install --upgrade pip
12+
13+
echo "Install Python2 certificates"
14+
bash -c "/Applications/Python\ 2.7/Install\ Certificates.command"
15+
fi
1416

1517
# Close Finder window
1618
if is_Veertu; then

images/macos/software-report/SoftwareReport.Generator.ps1

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,12 @@ $languageAndRuntime.AddToolVersion("Perl", $(Get-PerlVersion))
5252
if (-not $os.IsVenturaArm64) {
5353
$languageAndRuntime.AddToolVersion("PHP", $(Get-PHPVersion))
5454
}
55+
5556
if ((-not $os.IsVentura) -and (-not $os.IsVenturaArm64)) {
5657
$languageAndRuntime.AddToolVersion("Python", $(Get-PythonVersion))
58+
}
59+
60+
if (-not $os.IsVenturaArm64) {
5761
$languageAndRuntime.AddToolVersion("Python3", $(Get-Python3Version))
5862
}
5963
$languageAndRuntime.AddToolVersion("R", $(Get-RVersion))
@@ -73,9 +77,13 @@ $packageManagement.AddToolVersion("NPM", $(Get-NPMVersion))
7377
if ((-not $os.IsVentura) -and (-not $os.IsVenturaArm64)) {
7478
$packageManagement.AddToolVersion("NuGet", $(Get-NuGetVersion))
7579
$packageManagement.AddToolVersion("Pip", $(Get-PipVersion -Version 2))
80+
}
81+
82+
if (-not $os.IsVenturaArm64) {
7683
$packageManagement.AddToolVersion("Pip3", $(Get-PipVersion -Version 3))
7784
$packageManagement.AddToolVersion("Pipx", $(Get-PipxVersion))
7885
}
86+
7987
$packageManagement.AddToolVersion("RubyGems", $(Get-RubyGemsVersion))
8088
if (-not $os.IsVenturaArm64) {
8189
$packageManagement.AddToolVersion("Vcpkg", $(Get-VcpkgVersion))

images/macos/templates/macOS-13.anka.pkr.hcl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ build {
163163
"./provision/core/open_windows_check.sh",
164164
"./provision/core/powershell.sh",
165165
"./provision/core/dotnet.sh",
166+
"./provision/core/python.sh",
166167
"./provision/core/azcopy.sh",
167168
"./provision/core/ruby.sh",
168169
"./provision/core/rubygem.sh",

images/macos/tests/Python.Tests.ps1

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,7 @@ Import-Module "$PSScriptRoot/../helpers/Tests.Helpers.psm1" -DisableNameChecking
33

44
$os = Get-OSVersion
55

6-
Describe "Python" -Skip:($os.IsVentura -or $os.IsVenturaArm64) {
7-
It "Python 2 is available" {
8-
"python --version" | Should -ReturnZeroExitCode
9-
}
10-
11-
It "Python 2 is real 2.x" {
12-
(Get-CommandResult "python --version").Output | Should -BeLike "Python 2.*"
13-
}
14-
15-
It "Python 2 is installed under /usr/local/bin" {
16-
Get-WhichTool "python" | Should -BeLike "/usr/local/bin*"
17-
}
18-
6+
Describe "Python3" -Skip:($os.IsVenturaArm64) {
197
It "Python 3 is available" {
208
"python3 --version" | Should -ReturnZeroExitCode
219
}
@@ -24,10 +12,6 @@ Describe "Python" -Skip:($os.IsVentura -or $os.IsVenturaArm64) {
2412
Get-WhichTool "python3" | Should -BeLike "/usr/local/bin*"
2513
}
2614

27-
It "Pip 2 is available" {
28-
"pip --version" | Should -ReturnZeroExitCode
29-
}
30-
3115
It "Pip 3 is available" {
3216
"pip3 --version" | Should -ReturnZeroExitCode
3317
}
@@ -42,6 +26,25 @@ Describe "Python" -Skip:($os.IsVentura -or $os.IsVenturaArm64) {
4226
$pip3Path | Should -BeExactly $python3Path
4327
}
4428

29+
}
30+
31+
Describe "Python2" -Skip:($os.IsVenturaArm64 -or $os.IsVentura) {
32+
It "Python 2 is available" {
33+
"python --version" | Should -ReturnZeroExitCode
34+
}
35+
36+
It "Python 2 is real 2.x" {
37+
(Get-CommandResult "python --version").Output | Should -BeLike "Python 2.*"
38+
}
39+
40+
It "Python 2 is installed under /usr/local/bin" {
41+
Get-WhichTool "python" | Should -BeLike "/usr/local/bin*"
42+
}
43+
44+
It "Pip 2 is available" {
45+
"pip --version" | Should -ReturnZeroExitCode
46+
}
47+
4548
It "2to3 symlink does not point to Python 2" {
4649
$2to3path = (Get-ChildItem (Get-Command 2to3).Path).Target
4750
$2to3path | Should -Not -BeLike '/Frameworks/Python.framework/Versions/2.*'

0 commit comments

Comments
 (0)