Skip to content

Commit c207ff3

Browse files
committed
Support Python 2.7.
1 parent aa4dabe commit c207ff3

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

python/TODO.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
* PBR material
22
* Define index_t struct
3-
* Python 2.7 binding

python/main.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// python3 module for tinyobjloader
1+
// python2/3 module for tinyobjloader
22
//
33
// usage:
44
// import tinyobjloader as tol
@@ -182,10 +182,21 @@ static PyMethodDef mMethods[] = {
182182

183183
};
184184

185+
#if PY_MAJOR_VERSION >= 3
186+
185187
static struct PyModuleDef moduledef = {PyModuleDef_HEAD_INIT, "tinyobjloader",
186188
NULL, -1, mMethods};
187189

188190
PyMODINIT_FUNC PyInit_tinyobjloader(void) {
189191
return PyModule_Create(&moduledef);
190192
}
193+
194+
#else
195+
196+
PyMODINIT_FUNC inittinyobjloader(void) {
197+
Py_InitModule3("tinyobjloader", mMethods, NULL);
198+
}
199+
200+
#endif // PY_MAJOR_VERSION >= 3
201+
191202
}

0 commit comments

Comments
 (0)