improve python3

pull/49/head
ruki 5 years ago
parent a26a10fde7
commit 54b93578a1
No known key found for this signature in database
GPG Key ID: 809EF06AD42725BD
  1. 30
      packages/p/pybind11/xmake.lua
  2. 32
      packages/p/python/xmake.lua

@ -0,0 +1,30 @@
package("pybind11")
set_homepage("https://github.com/pybind/pybind11")
set_description("Seamless operability between C++11 and Python.")
set_urls("https://github.com/pybind/pybind11/archive/v$(version).zip",
"https://github.com/pybind/pybind11.git")
add_deps("python 3.x")
add_versions("2.5.0", "1859f121837f6c41b0c6223d617b85a63f2f72132bae3135a2aa290582d61520")
on_install(function (package)
os.cp("include", package:installdir())
end)
on_test(function (package)
assert(package:check_cxxsnippets({test = [[
#include <pybind11/pybind11.h>
int add(int i, int j) {
return i + j;
}
namespace py = pybind11;
PYBIND11_PLUGIN(example) {
py::module m("example", "pybind11 example plugin");
m.def("add", &add, "A function which adds two numbers");
return m.ptr();
}
]]}, {configs = {languages = "c++11"}}))
end)

@ -124,6 +124,38 @@ package("python")
io.gsub("Lib/ctypes/macholib/dyld.py", "DEFAULT_LIBRARY_FALLBACK = %[", format("DEFAULT_LIBRARY_FALLBACK = [ '%s/lib',", package:installdir()))
end
-- add flags
local cflags = {}
local ldflags = {}
if package:is_plat("macosx") then
local xcode_dir = get_config("xcode")
local xcode_sdkver = get_config("xcode_sdkver")
if xcode_dir and xcode_sdkver then
-- help Python's build system (setuptools/pip) to build things on SDK-based systems
-- the setup.py looks at "-isysroot" to get the sysroot (and not at --sysroot)
local xcode_sdkdir = xcode_dir .. "/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX" .. xcode_sdkver .. ".sdk"
table.insert(cflags, "-isysroot " .. xcode_sdkdir)
table.insert(cflags, "-I" .. path.join(xcode_sdkdir, "/usr/include"))
table.insert(ldflags, "-isysroot " .. xcode_sdkdir)
-- for the Xlib.h, Python needs this header dir with the system Tk
-- yep, this needs the absolute path where zlib needed a path relative to the SDK.
table.insert(cflags, "-I" .. path.join(xcode_sdkdir, "/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers"))
end
-- avoid linking to libgcc https://mail.python.org/pipermail/python-dev/2012-February/116205.html
local target_minver = get_config("target_minver")
if target_minver then
table.insert(configs, "MACOSX_DEPLOYMENT_TARGET=" .. target_minver)
end
end
if #cflags > 0 then
table.insert(configs, "CFLAGS=" .. table.concat(cflags, " "))
end
if #ldflags > 0 then
table.insert(configs, "LDFLAGS=" .. table.concat(ldflags, " "))
end
-- unset these so that installing pip and setuptools puts them where we want
-- and not into some other Python the user has installed.
import("package.tools.autoconf").configure(package, configs, {envs = {PYTHONHOME = "", PYTHONPATH = ""}})

Loading…
Cancel
Save