-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed version getter scripts for ahk2
- Loading branch information
Showing
6 changed files
with
55 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,40 @@ | ||
a2dev_get_py() | ||
{ | ||
; TODO: this needs to be a little bit more dynamic | ||
supported_versions := ["3.11", "3.10", "3.9"] | ||
;exe_type := {filename: "python.exe", reg_name: "ExecutablePath"} | ||
exe_type := {filename: "pythonw.exe", reg_name: "WindowedExecutablePath"} | ||
|
||
supported_versions := ["3.12", "3.11", "3.10", "3.9"] | ||
; First: Try to read python path from registry in either CURRENT_USER or LOCAL_MACHINE domain | ||
pypath := check_registry(supported_versions, exe_type) | ||
pypath := check_registry(supported_versions) | ||
if (pypath != "") | ||
Return pypath | ||
|
||
versions_string := string_join(supported_versions) | ||
|
||
MsgBox, 16, No Matching Python Version!, Could not find a Python installation!`nSupported versions include: %versions_string%! | ||
title := "No Matching Python Version!" | ||
msg := "Could not find a Python installation!`nSupported versions include: " . string_join(supported_versions) . "!" | ||
MsgBox(msg, title, 16) | ||
ExitApp | ||
} | ||
|
||
|
||
check_registry(supported_versions, exe_type) { | ||
reg_name := exe_type["reg_name"] | ||
Loop, % supported_versions.MaxIndex() | ||
check_registry(supported_versions) { | ||
;exe_type := {filename: "python.exe", reg_name: "ExecutablePath"} | ||
exe_type := {filename: "pythonw.exe", reg_name: "WindowedExecutablePath"} | ||
reg_name := exe_type.reg_name | ||
|
||
Loop(supported_versions.Length) | ||
{ | ||
this_version := supported_versions[A_Index] | ||
|
||
py_key = HKEY_CURRENT_USER\Software\Python\PythonCore\%this_version%\InstallPath | ||
RegRead, pypath, %py_key%, %reg_name% | ||
py_key := "HKEY_CURRENT_USER\Software\Python\PythonCore\" . this_version . "\InstallPath" | ||
pypath := RegRead(py_key, reg_name) | ||
|
||
if !string_endswith(pypath, exe_type.filename) | ||
{ | ||
py_key = HKEY_LOCAL_MACHINE\Software\Python\PythonCore\%this_version%\InstallPath | ||
RegRead, pypath, %py_key%, %reg_name% | ||
py_key := "HKEY_LOCAL_MACHINE\Software\Python\PythonCore\" . this_version . "\InstallPath" | ||
pypath := RegRead(py_key, reg_name) | ||
} | ||
|
||
IfExist, %pypath% | ||
If FileExist(pypath) | ||
{ | ||
global a2_PY_VERSION_SHORT := this_version | ||
Return, pypath | ||
Return pypath | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
#include %A_ScriptDir%\..\..\_a2dev_find_py.ahk | ||
#include %A_ScriptDir%\..\..\a2_globals.ahk | ||
#include %A_ScriptDir%\..\..\Autohotkey\lib\string.ahk | ||
#include %A_ScriptDir%\..\..\Autohotkey\lib\path.ahk | ||
py_exe := a2dev_get_py() | ||
if (!FileExist(py_exe)) | ||
MsgBox, No Python Found here`n%py_exe% | ||
MsgBox("No Python Found here`n" . py_exe) | ||
|
||
SplitPath, py_exe,, py_dir | ||
FileAppend, %py_dir%, * | ||
SplitPath py_exe,, &py_dir | ||
FileAppend py_dir, "*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
#include %A_ScriptDir%\..\..\_a2dev_find_py.ahk | ||
#include %A_ScriptDir%\..\..\a2_globals.ahk | ||
#include %A_ScriptDir%\..\..\Autohotkey\lib\string.ahk | ||
#include %A_ScriptDir%\..\..\Autohotkey\lib\path.ahk | ||
py := a2dev_get_py() | ||
if (!FileExist(py)) | ||
MsgBox, No Python Found here`n%py% | ||
FileGetVersion, version, %py% | ||
MsgBox("No Python Found here`n" . py) | ||
version := FileGetVersion(py) | ||
if (!version) | ||
MsgBox, No Python Version found!`n%py% | ||
FileAppend, %version%, * | ||
MsgBox("No Python Version found!`n" . py) | ||
FileAppend version, "*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
FileAppend, %A_AhkVersion%, * | ||
FileAppend A_AhkVersion, "*" |