Skip to content

Commit e0b3934

Browse files
authored
Merge pull request tinyobjloader#111 from longjon/python2
Support Python 2.7
2 parents 947582b + c207ff3 commit e0b3934

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

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
@@ -183,10 +183,21 @@ static PyMethodDef mMethods[] = {
183183

184184
};
185185

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

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

0 commit comments

Comments
 (0)