Made cython model loader py2exe friendly.

Signed-off-by: Xiaomao Chen <xiaomao5@live.com>
This commit is contained in:
Quantum 2013-10-30 18:48:58 -04:00
parent de08850f24
commit e45f8f6f85
2 changed files with 453 additions and 295 deletions

File diff suppressed because it is too large Load diff

View file

@ -257,8 +257,16 @@ cdef class WavefrontObject(object):
free(buf)
fclose(cfile)
import sys
if hasattr(sys, 'frozen'):
model_base = os.path.dirname(sys.executable)
else:
model_base = os.path.join(os.path.dirname(__file__), 'assets', 'models')
del sys
def load_model(path):
path = os.path.join(os.path.dirname(__file__), 'assets', 'models', path)
if not os.path.isabs(path):
path = os.path.join(model_base, path)
if not isinstance(path, unicode):
path = path.decode('mbcs')
return WavefrontObject(path)