From 84563946c10642716ddb9d1965d0cf469080a6f9 Mon Sep 17 00:00:00 2001 From: wps <19317362@qq.com> Date: Sat, 27 Jan 2024 14:00:57 +0800 Subject: [PATCH] FIX build error when build on windows + venv --- hikyuu_pywrap/xmake.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/hikyuu_pywrap/xmake.lua b/hikyuu_pywrap/xmake.lua index f4bc77543..ed1b68351 100644 --- a/hikyuu_pywrap/xmake.lua +++ b/hikyuu_pywrap/xmake.lua @@ -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