misc/openvdb: Replace the dependency on python 2.7 with the default python (currently 3.x)

PR:		244347
Submitted by:	VVD <vvd@unislabs.com>
This commit is contained in:
Yuri Victorovich 2020-04-01 20:06:02 +00:00
parent 26f1775dd3
commit 7f7c069004
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=530238
2 changed files with 27 additions and 1 deletions

View File

@ -28,7 +28,7 @@ OPTIONS_DEFINE= PYTHON TOOLS DOCS # TOOLS should be a subpackage
OPTIONS_DEFAULT= PYTHON TOOLS
OPTIONS_SUB= yes
PYTHON_USES= python:2.7 # 3.6 is broken: https://github.com/AcademySoftwareFoundation/openvdb/issues/427
PYTHON_USES= python
PYTHON_CMAKE_BOOL= OPENVDB_BUILD_PYTHON_MODULE
PYTHON_CMAKE_ON= -DFREEBSD_PYTHON_VER:STRING=${PYTHON_VER} -DUSE_NUMPY:BOOL=ON
PYTHON_LIB_DEPENDS= ${PY_BOOST}

View File

@ -0,0 +1,26 @@
--- openvdb/python/pyOpenVDBModule.cc.orig 2019-05-07 20:58:35 UTC
+++ openvdb/python/pyOpenVDBModule.cc
@@ -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;
}
@@ -337,7 +341,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.