From 6acc37b2c48aab0e2f78cea44d78f4bf2e6c73d0 Mon Sep 17 00:00:00 2001 From: myuanz Date: Tue, 1 Oct 2024 12:58:27 +0800 Subject: [PATCH 1/7] python: If headeronly is set, links is not needed --- packages/p/python/fetch.lua | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/packages/p/python/fetch.lua b/packages/p/python/fetch.lua index 1efc5ba3b01..d7f567e7d2e 100644 --- a/packages/p/python/fetch.lua +++ b/packages/p/python/fetch.lua @@ -66,17 +66,24 @@ function _find_library(package, opt) includepath = find_path("Python.h", { path.directory(exepath), out }, { suffixes = { "include/python" .. pyver } }) end - if libpath and includepath then - local result = { - version = version, - includedirs = includepath - } - if not package:config("headeronly") then - result.links = libpath.link - result.linkdirs = libpath.linkdir - end + if not includepath then + return false + end + local result = { + version = version, + includedirs = includepath + } + -- If headeronly is set, links is not needed + + if package:config("headeronly") then + return result + end + if libpath then + result.links = libpath.link + result.linkdirs = libpath.linkdir return result end + return false end function main(package, opt) From 68b0a1da7c599ba0c25ccceba98f00b64cbee2b5 Mon Sep 17 00:00:00 2001 From: myuanz Date: Tue, 1 Oct 2024 15:55:06 +0800 Subject: [PATCH 2/7] pybind11: add python_headeronly choice --- packages/p/pybind11/xmake.lua | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/packages/p/pybind11/xmake.lua b/packages/p/pybind11/xmake.lua index 81fe0619a62..ccd1533c002 100644 --- a/packages/p/pybind11/xmake.lua +++ b/packages/p/pybind11/xmake.lua @@ -19,7 +19,29 @@ package("pybind11") add_versions("v2.12.0", "411f77380c43798506b39ec594fc7f2b532a13c4db674fcf2b1ca344efaefb68") add_versions("v2.13.1", "a3c9ea1225cb731b257f2759a0c12164db8409c207ea5cf851d4b95679dda072") - add_deps("cmake", "python 3.x") + -- On Windows, pybind11 must be linked with python library. + -- But on Linux, Python Packaging Authority recommends using headeronly mode for C extensions, + -- and linking libpythonX.Y.so is not allowed on manylinux, which is the base image for distributing C extensions. + + -- see https://gitlab.kitware.com/cmake/cmake/-/issues/20425 and + -- https://peps.python.org/pep-0513/#libpythonx-y-so-1 + + add_configs("use_python_headeronly", {description = "Use python headeronly", default = false, type = "boolean"}) + + add_deps("cmake") + on_load(function (package) + local python_headeronly = package:config("use_python_headeronly") + + if os.host() == "windows" then + print("Python headeronly is not supported on Windows") + python_headeronly = false + end + + package:add("deps", "python 3.x", {configs = { + headeronly = python_headeronly, + }}) + end) + on_install("windows|native", "macosx", "linux", function (package) import("package.tools.cmake").install(package, {"-DPYBIND11_TEST=OFF"}) end) From 4c119ab01d945b86652e153c3da2b5e1d4f51516 Mon Sep 17 00:00:00 2001 From: myuanz Date: Wed, 2 Oct 2024 23:26:58 +0800 Subject: [PATCH 3/7] change code format --- packages/p/pybind11/xmake.lua | 14 ++++++-------- packages/p/python/fetch.lua | 2 -- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/packages/p/pybind11/xmake.lua b/packages/p/pybind11/xmake.lua index ccd1533c002..60fecdb4a86 100644 --- a/packages/p/pybind11/xmake.lua +++ b/packages/p/pybind11/xmake.lua @@ -19,21 +19,19 @@ package("pybind11") add_versions("v2.12.0", "411f77380c43798506b39ec594fc7f2b532a13c4db674fcf2b1ca344efaefb68") add_versions("v2.13.1", "a3c9ea1225cb731b257f2759a0c12164db8409c207ea5cf851d4b95679dda072") - -- On Windows, pybind11 must be linked with python library. - -- But on Linux, Python Packaging Authority recommends using headeronly mode for C extensions, - -- and linking libpythonX.Y.so is not allowed on manylinux, which is the base image for distributing C extensions. + -- Linking libpythonX.Y.so is not allowed on manylinux, which is the base image for distributing C extensions. -- see https://gitlab.kitware.com/cmake/cmake/-/issues/20425 and -- https://peps.python.org/pep-0513/#libpythonx-y-so-1 - add_configs("use_python_headeronly", {description = "Use python headeronly", default = false, type = "boolean"}) + add_configs("python_headeronly", {description = "Enable headeronly for Python", default = false, type = "boolean"}) add_deps("cmake") - on_load(function (package) - local python_headeronly = package:config("use_python_headeronly") - if os.host() == "windows" then - print("Python headeronly is not supported on Windows") + on_load(function (package) + local python_headeronly = package:config("python_headeronly") + if os.is_host("windows") then + wprint("Python headeronly is not supported on Windows") python_headeronly = false end diff --git a/packages/p/python/fetch.lua b/packages/p/python/fetch.lua index d7f567e7d2e..dfe87b615d5 100644 --- a/packages/p/python/fetch.lua +++ b/packages/p/python/fetch.lua @@ -73,7 +73,6 @@ function _find_library(package, opt) version = version, includedirs = includepath } - -- If headeronly is set, links is not needed if package:config("headeronly") then return result @@ -83,7 +82,6 @@ function _find_library(package, opt) result.linkdirs = libpath.linkdir return result end - return false end function main(package, opt) From e3cc0edd67cbb09cd86b76fd4b69e1f02687ec6a Mon Sep 17 00:00:00 2001 From: myuanz Date: Wed, 2 Oct 2024 23:29:12 +0800 Subject: [PATCH 4/7] remove os prefix --- packages/p/pybind11/xmake.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/p/pybind11/xmake.lua b/packages/p/pybind11/xmake.lua index 60fecdb4a86..e3d0f417cc2 100644 --- a/packages/p/pybind11/xmake.lua +++ b/packages/p/pybind11/xmake.lua @@ -30,7 +30,7 @@ package("pybind11") on_load(function (package) local python_headeronly = package:config("python_headeronly") - if os.is_host("windows") then + if is_host("windows") then wprint("Python headeronly is not supported on Windows") python_headeronly = false end From 9e5d6afa314a919dc68201b466a3ff1f537758f0 Mon Sep 17 00:00:00 2001 From: zhengmy Date: Tue, 8 Oct 2024 13:58:11 +0800 Subject: [PATCH 5/7] remove verbose doc --- packages/p/pybind11/xmake.lua | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/packages/p/pybind11/xmake.lua b/packages/p/pybind11/xmake.lua index e3d0f417cc2..9631f99852b 100644 --- a/packages/p/pybind11/xmake.lua +++ b/packages/p/pybind11/xmake.lua @@ -19,11 +19,7 @@ package("pybind11") add_versions("v2.12.0", "411f77380c43798506b39ec594fc7f2b532a13c4db674fcf2b1ca344efaefb68") add_versions("v2.13.1", "a3c9ea1225cb731b257f2759a0c12164db8409c207ea5cf851d4b95679dda072") - -- Linking libpythonX.Y.so is not allowed on manylinux, which is the base image for distributing C extensions. - - -- see https://gitlab.kitware.com/cmake/cmake/-/issues/20425 and -- https://peps.python.org/pep-0513/#libpythonx-y-so-1 - add_configs("python_headeronly", {description = "Enable headeronly for Python", default = false, type = "boolean"}) add_deps("cmake") @@ -35,9 +31,7 @@ package("pybind11") python_headeronly = false end - package:add("deps", "python 3.x", {configs = { - headeronly = python_headeronly, - }}) + package:add("deps", "python 3.x", {configs = {headeronly = python_headeronly}}) end) on_install("windows|native", "macosx", "linux", function (package) From 76f17db02d7edecc8c60dac6e42d90eb980702a0 Mon Sep 17 00:00:00 2001 From: zhengmy Date: Tue, 8 Oct 2024 13:58:26 +0800 Subject: [PATCH 6/7] remove `return false` --- packages/p/python/fetch.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/p/python/fetch.lua b/packages/p/python/fetch.lua index dfe87b615d5..436c1d27f50 100644 --- a/packages/p/python/fetch.lua +++ b/packages/p/python/fetch.lua @@ -67,7 +67,7 @@ function _find_library(package, opt) end if not includepath then - return false + return end local result = { version = version, From 10adbaf9219d1e730c392069c0b9b9a3a59faba2 Mon Sep 17 00:00:00 2001 From: zhengmy Date: Tue, 8 Oct 2024 14:19:03 +0800 Subject: [PATCH 7/7] add readonly for windows and mingw --- packages/p/pybind11/xmake.lua | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/packages/p/pybind11/xmake.lua b/packages/p/pybind11/xmake.lua index 9631f99852b..0bd8224e45d 100644 --- a/packages/p/pybind11/xmake.lua +++ b/packages/p/pybind11/xmake.lua @@ -20,18 +20,16 @@ package("pybind11") add_versions("v2.13.1", "a3c9ea1225cb731b257f2759a0c12164db8409c207ea5cf851d4b95679dda072") -- https://peps.python.org/pep-0513/#libpythonx-y-so-1 - add_configs("python_headeronly", {description = "Enable headeronly for Python", default = false, type = "boolean"}) + if is_plat("windows", "mingw") then + add_configs("python_headeronly", {description = "Enable headeronly for Python", default = false, type = "boolean", readonly = true}) + else + add_configs("python_headeronly", {description = "Enable headeronly for Python", default = false, type = "boolean"}) + end add_deps("cmake") on_load(function (package) - local python_headeronly = package:config("python_headeronly") - if is_host("windows") then - wprint("Python headeronly is not supported on Windows") - python_headeronly = false - end - - package:add("deps", "python 3.x", {configs = {headeronly = python_headeronly}}) + package:add("deps", "python 3.x", {configs = {headeronly = package:config("python_headeronly")}}) end) on_install("windows|native", "macosx", "linux", function (package)