Skip to content

Commit

Permalink
FIX build error when build on windows + venv
Browse files Browse the repository at this point in the history
  • Loading branch information
19317362 committed Jan 27, 2024
1 parent 67490e3 commit 8456394
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions hikyuu_pywrap/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,19 @@ target("core")
-- find python include and libs directory
local pydir = os.iorun("python -c \"import sys; print(sys.executable)\"")
pydir = path.directory(pydir)
if pydir:endswith("Scripts") then
-- if venv is activated, find the real python directory
file = io.open(pydir .. "/../pyvenv.cfg", "r")
for line in file:lines() do
if string.find(line, "home =") then
-- 使用 string.gmatch 函数抽取路径
for path in string.gmatch(line, "home = (.*)") do
pydir = path
end
end
end
file:close()
end
target:add("includedirs", pydir .. "/include")
target:add("linkdirs", pydir .. "/libs")
return
Expand Down

0 comments on commit 8456394

Please sign in to comment.