@@ -4,7 +4,7 @@ proc Kratos::InstallAllPythonDependencies { } {
44
55 if { $::tcl_platform(platform) == " windows" } { set os win } {set os unix}
66 set dir [lindex [Kratos::GetLaunchConfigurationFile] 0]
7- if { $os eq " win " } { set py " python " } { set py " python3 " }
7+ set py [Kratos::GetPythonExeName]
88 # Check if python is installed. minimum 3.5, best 3.9
99 set python_version [pythonVersion $py ]
1010 if { $python_version <= 0 || [GidUtils::TwoVersionsCmp $python_version " 3.9.0" ] <0 } {
@@ -35,6 +35,18 @@ proc Kratos::InstallPip { } {
3535 W " "
3636}
3737
38+ proc Kratos::GetPythonExeName { } {
39+
40+ if { $::tcl_platform(platform) == " windows" } { set os win } {set os unix}
41+ if {$os eq " win" } {set py " python" } {set py " python3" }
42+ return $py
43+ }
44+
45+ proc Kratos::GetDefaultPythonPath { } {
46+ set py [Kratos::GetPythonExeName]
47+ return [exec $py -c " import sys; print(sys.exec_prefix)" 2>@1]
48+ }
49+
3850proc Kratos::pythonVersion {{pythonExecutable " python" }} {
3951 # Tricky point: Python 2.7 writes version info to stderr!
4052 set ver 0
@@ -65,11 +77,9 @@ proc Kratos::GetMissingPipPackages { } {
6577 variable pip_packages_required
6678 set missing_packages [list ]
6779
68-
69- if { $::tcl_platform(platform) == " windows" } { set os win } {set os unix}
70- if {$os eq " win" } {set pip " pyw" } {set pip " python3" }
80+ set py [Kratos::GetPythonExeName]
7181 set pip_packages_installed [list ]
72- set pip_packages_installed_raw [exec $pip -m pip list --format=freeze --disable-pip-version-check 2>@1]
82+ set pip_packages_installed_raw [exec $py -m pip list --format=freeze --disable-pip-version-check 2>@1]
7383 foreach package $pip_packages_installed_raw {
7484 lappend pip_packages_installed [lindex [split $package " ==" ] 0]
7585 }
@@ -94,8 +104,7 @@ proc Kratos::CheckDependenciesPipMode {} {
94104 if { [GidUtils::IsTkDisabled] } {
95105 return 0
96106 }
97- if { $::tcl_platform(platform) == " windows" } { set os win } {set os unix}
98- if {$os eq " win" } {set py " python" } {set py " python3" }
107+ set py [Kratos::GetPythonExeName]
99108 set py_version [Kratos::pythonVersion $py ]
100109 if {$py_version <= 0} {
101110 set msgBox_type yesno
0 commit comments