Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 535babc

Browse files
committed
Fix build issue with Python 3.3/3.4.
Fixes #4
1 parent 2c183ed commit 535babc

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

setup.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,17 @@ def build_extension(self, ext):
109109
if not os.path.exists(dest_dir):
110110
os.makedirs(dest_dir)
111111

112+
# Up to Python 3.2 sys.maxunicode is used to determine the size of Py_UNICODE
113+
# but from 3.3 onwards Py_UNICODE is a typedef of wchar_t.
114+
if sys.version_info[:2] <= (3, 2):
115+
unicode_width = 2 if sys.maxunicode < 0x10FFFF else 4
116+
else:
117+
import ctypes
118+
unicode_width = ctypes.sizeof(ctypes.c_wchar)
119+
112120
defines = [
113121
"PYTHON%d%s" % (sys.version_info[:2]),
114-
"UCS2" if sys.maxunicode < 0x10FFFF else "UCS4",
122+
"UCS%d" % unicode_width,
115123
]
116124

117125
if CONFIG == "Debug":

0 commit comments

Comments
 (0)