summaryrefslogtreecommitdiff
path: root/xmake/modules/detect/tools/find_python3.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2018-09-22 08:44:35 +0800
committerruki <[email protected]>2018-09-22 08:44:35 +0800
commit6935be8876c358d89b5c5c2d5c0a56f4ea9d1590 (patch)
tree234c1e6a32b2da58b231279bb3bfc33d01f3d262 /xmake/modules/detect/tools/find_python3.lua
parent180e96c3759ab7e80e18d3ab445945d8c758e01a (diff)
add find_python2
Diffstat (limited to 'xmake/modules/detect/tools/find_python3.lua')
-rw-r--r--xmake/modules/detect/tools/find_python3.lua14
1 files changed, 12 insertions, 2 deletions
diff --git a/xmake/modules/detect/tools/find_python3.lua b/xmake/modules/detect/tools/find_python3.lua
index a6c75611e..dcbf2e3af 100644
--- a/xmake/modules/detect/tools/find_python3.lua
+++ b/xmake/modules/detect/tools/find_python3.lua
@@ -53,10 +53,14 @@ function main(opt)
-- find program
local program = find_program(opt.program or "python3", opt)
-
+ if not program then
+ program = find_program("python", opt)
+ opt.version = true
+ end
+
-- find program version
local version = nil
- if program and opt and opt.version then
+ if program and opt.version then
opt.command = function ()
local outs, errs = os.iorunv(program, {"--version"})
return ((outs or "") .. (errs or "")):trim()
@@ -64,6 +68,12 @@ function main(opt)
version = find_programver(program, opt)
end
+ -- check version
+ if version and not version:startswith("3.") then
+ return
+ end
+
-- ok?
return program, version
+
end