summaryrefslogtreecommitdiff
path: root/xmake/modules/detect/tools/find_python3.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2021-03-26 22:41:34 +0800
committerruki <[email protected]>2021-03-26 22:41:34 +0800
commit49953b37d748a0116626a74f87faebf198c2d688 (patch)
tree7c84ee8918eebe798fd422a5342489097cb18c9b /xmake/modules/detect/tools/find_python3.lua
parent17c2672e3aae56bfe765fda6adc9abc861d7342d (diff)
improve to find_python
Diffstat (limited to 'xmake/modules/detect/tools/find_python3.lua')
-rw-r--r--xmake/modules/detect/tools/find_python3.lua15
1 files changed, 8 insertions, 7 deletions
diff --git a/xmake/modules/detect/tools/find_python3.lua b/xmake/modules/detect/tools/find_python3.lua
index 2bc659ff5..0e056dd27 100644
--- a/xmake/modules/detect/tools/find_python3.lua
+++ b/xmake/modules/detect/tools/find_python3.lua
@@ -41,15 +41,19 @@ function main(opt)
opt = opt or {}
if is_host("windows") then
opt.paths = opt.paths or {}
- table.insert(opt.paths, "$(reg HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\3.7\\InstallPath;ExecutablePath)")
- table.insert(opt.paths, "$(reg HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\3.7-32\\InstallPath;ExecutablePath)")
- table.insert(opt.paths, "$(reg HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\3.6\\InstallPath;ExecutablePath)")
- table.insert(opt.paths, "$(reg HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\3.6-32\\InstallPath;ExecutablePath)")
+ local keys = winos.registry_keys("HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\3.*\\InstallPath")
+ for _, key in ipairs(keys) do
+ local value = winos.registry_query(key .. ";ExecutablePath")
+ if value and os.isfile(value) then
+ table.insert(opt.paths, value)
+ end
+ end
end
-- find program
local program = find_program(opt.program or "python3", opt)
if not program then
+ opt.force = true
program = find_program("python", opt)
opt.version = true
end
@@ -68,8 +72,5 @@ function main(opt)
if version and not version:startswith("3.") then
return
end
-
- -- ok?
return program, version
-
end