Fix to ensure that define is interpreted as a string on windows

This commit is contained in:
wiredfool 2017-06-21 05:36:56 -07:00
parent 67d6e00751
commit edc8d8627c
3 changed files with 10 additions and 3 deletions

View File

@ -56,7 +56,10 @@ try:
from . import _imaging as core
if PILLOW_VERSION != getattr(core, 'PILLOW_VERSION', None):
raise ImportError("The _imaging extension was built for another "
"version of Pillow or PIL")
"version of Pillow or PIL: Core Version: %s"
"Pillow Version: %s" %
(getattr(core, 'PILLOW_VERSION', None),
PILLOW_VERSION))
except ImportError as v:
core = _imaging_not_installed()

View File

@ -3435,6 +3435,7 @@ static PyMethodDef functions[] = {
static int
setup_module(PyObject* m) {
PyObject* d = PyModule_GetDict(m);
const char* version = (char*)PILLOW_VERSION;
/* Ready object types */
if (PyType_Ready(&Imaging_Type) < 0)
@ -3479,7 +3480,7 @@ setup_module(PyObject* m) {
}
#endif
PyDict_SetItemString(d, "PILLOW_VERSION", PyUnicode_FromString(PILLOW_VERSION));
PyDict_SetItemString(d, "PILLOW_VERSION", PyUnicode_FromString(version));
return 0;
}

View File

@ -584,7 +584,10 @@ class pil_build_ext(build_ext):
if struct.unpack("h", "\0\1".encode('ascii'))[0] == 1:
defs.append(("WORDS_BIGENDIAN", None))
defs.append(("PILLOW_VERSION", '"%s"'%PILLOW_VERSION))
if sys.platform == "win32":
defs.append(("PILLOW_VERSION", '"\\"%s\\""'%PILLOW_VERSION))
else:
defs.append(("PILLOW_VERSION", '"%s"'%PILLOW_VERSION))
exts = [(Extension("PIL._imaging",
files,