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

Fixes for Python3 and loading the python module on MacOS #428

Merged
merged 1 commit into from
May 20, 2019
Merged
Show file tree
Hide file tree
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
9 changes: 8 additions & 1 deletion openvdb/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,16 @@ target_link_libraries(pyopenvdb
)

set_target_properties(pyopenvdb PROPERTIES
PREFIX ""
PREFIX "" # no 'lib' prefix
)

if(UNIX)
# must be .so (not .dylib)
set_target_properties(pyopenvdb PROPERTIES
SUFFIX ".so"
)
endif()

if(OPENVDB_ENABLE_RPATH)
# @todo There is probably a better way to do this for imported targets
set(RPATHS "")
Expand Down
9 changes: 8 additions & 1 deletion openvdb/python/pyOpenVDBModule.cc
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,11 @@ struct PointIndexConverter
/// @return nullptr if the given Python object is not convertible to the PointIndex.
static void* convertible(PyObject* obj)
{
#if PY_MAJOR_VERSION >= 3
if (!PyLong_Check(obj)) return nullptr; // not a Python integer
#else
if (!PyInt_Check(obj)) return nullptr; // not a Python integer
#endif
return obj;
}

Expand All @@ -336,8 +340,11 @@ struct PointIndexConverter

// Extract the PointIndex from the python integer
PointIndexT* index = static_cast<PointIndexT*>(storage);

#if PY_MAJOR_VERSION >= 3
*index = static_cast<IntType>(PyLong_AsLong(obj));
#else
*index = static_cast<IntType>(PyInt_AsLong(obj));
#endif
}

/// Register both the PointIndex-to-integer and the integer-to-PointIndex converters.
Expand Down