From 63e4fca54e18ae51097d59d0e977d17cd9200bc5 Mon Sep 17 00:00:00 2001 From: ruki Date: Wed, 10 Aug 2022 22:35:38 +0800 Subject: improve python.library --- xmake/rules/python/xmake.lua | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'xmake/rules/python') diff --git a/xmake/rules/python/xmake.lua b/xmake/rules/python/xmake.lua index 01fe83c59..e63abaf28 100644 --- a/xmake/rules/python/xmake.lua +++ b/xmake/rules/python/xmake.lua @@ -37,23 +37,28 @@ rule("python.library") else if target:is_plat("windows") then target:set("extension", ".pyd") + else + target:set("extension", ".so") end end -- fix segmentation fault for macosx -- @see https://github.com/xmake-io/xmake/issues/2177#issuecomment-1209398292 if target:is_plat("macosx") then target:add("shflags", "-undefined dynamic_lookup", {force = true}) - local pybind11 = target:pkg("pybind11") - if pybind11 then - local links = pybind11:get("links") + for _, pkg in pairs(target:pkgs()) do + local links = pkg:get("links") if links then - local links_without_python = {} + local with_python = false for _, link in ipairs(links) do - if not link:startswith("python") then - table.insert(links_without_python, link) + if link:startswith("python") then + with_python = true + break end end - pybind11:set("links", links_without_python) + if with_python then + pkg:set("links", nil) + pkg:set("linkdirs", nil) + end end end end -- cgit v1.3.1