Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add openvdb python interface #4573

Merged
merged 1 commit into from
Jul 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions packages/o/openvdb/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ package("openvdb")
add_configs("with_houdini", {description = "Location of Houdini installation. Set to enable built with Houdini.", default = "", type = "string"})
add_configs("with_maya", {description = "Location of Maya installation. Set to enable built with Maya.", default = "", type = "string"})
add_configs("simd", {description = "SIMD acceleration architecture.", type = "string", values = {"None", "SSE42", "AVX"}})
add_configs("python", {description = "Build the pyopenvdb Python module.", default = false, type = "boolean"})
add_configs("print", {description = "Command line binary for displaying information about OpenVDB files.", default = true, type = "boolean"})
add_configs("lod", {description = "Command line binary for generating volume mipmaps from an OpenVDB grid.", default = false, type = "boolean"})
add_configs("render", {description = "Command line binary for ray-tracing OpenVDB grids.", default = false, type = "boolean"})
Expand All @@ -45,6 +46,10 @@ package("openvdb")
package:add("deps", package:version():ge("9.0.0") and "tbb" or "tbb <2021.0")
end
end
if package:config("python") then
package:add("deps", "python 3.x")
package:add("deps", "pybind11")
end
if package:config("view") then
package:add("deps", "glew", {configs = {shared = true}})
package:add("deps", "glfw")
Expand Down Expand Up @@ -92,6 +97,7 @@ package("openvdb")
end
table.insert(configs, "-DBoost_USE_STATIC_RUNTIME=" .. (package:config("vs_runtime"):startswith("MT") and "ON" or "OFF"))
end
table.insert(configs, "-DOPENVDB_BUILD_PYTHON_MODULE=" .. (package:config("python") and "ON" or "OFF"))
table.insert(configs, "-DOPENVDB_BUILD_VDB_LOD=" .. (package:config("lod") and "ON" or "OFF"))
table.insert(configs, "-DOPENVDB_BUILD_VDB_PRINT=" .. (package:config("print") and "ON" or "OFF"))
table.insert(configs, "-DOPENVDB_BUILD_BINARIES=" .. (package:config("print") and "ON" or "OFF"))
Expand Down Expand Up @@ -128,6 +134,22 @@ package("openvdb")
end
import("package.tools.cmake").install(package, configs)
package:addenv("PATH", "bin")
if package:config("python") then
local pyver = package:dep("python"):version()
local pydpath = path.join(package:installdir("lib"), format("python%d.%d", pyver:major(), pyver:minor()), "site-packages")
package:addenv("PYTHONPATH", pydpath)
-- after python 3.8, python will not search in PATH for dlls
if package:is_plat("windows") then
local tbb = package:dep("tbb"):fetch()
if tbb and tbb.linkdirs then
local tbb_dir = path.directory(tbb.linkdirs[1])
os.cp(path.join(tbb_dir, "bin", "tbb*.dll"), pydpath)
end
if package:config("shared") then
os.cp(path.join(package:installdir("bin"), "openvdb.dll"), pydpath)
end
end
end
end)

on_test(function (package)
Expand All @@ -151,4 +173,7 @@ package("openvdb")
]]}, {configs = {languages = "c++17"},
includes = {"nanovdb/util/GridBuilder.h"}}))
end
if package:config("python") then
os.vrun("python -c 'import pyopenvdb'")
end
end)
Loading