Drop Python 2 support by filmor · Pull Request #1158 · pythonnet/pythonnet
# Up to Python 3.2 sys.maxunicode is used to determine the size of # Py_UNICODE, but from 3.3 onwards Py_UNICODE is a typedef of wchar_t. # TODO: Is this doing the right check for Py27? if sys.version_info[:2] <= (3, 2): unicode_width = 2 if sys.maxunicode < 0x10FFFF else 4 else: import ctypes
unicode_width = ctypes.sizeof(ctypes.c_wchar) import ctypes unicode_width = ctypes.sizeof(ctypes.c_wchar)
defines = [ "PYTHON{0}{1}".format(PY_MAJOR, PY_MINOR), "PYTHON{0}".format(PY_MAJOR), # Python Major Version "UCS{0}".format(unicode_width), ]
if sys.platform != "win32" and (DEVTOOLS == "Mono" or DEVTOOLS == "dotnet"): on_darwin = sys.platform == "darwin" defines.append("MONO_OSX" if on_darwin else "MONO_LINUX")
# Check if --enable-shared was set when Python was built enable_shared = sysconfig.get_config_var("Py_ENABLE_SHARED")
if sys.platform == "win32": defines.append("WINDOWS")
if hasattr(sys, "abiflags"): if "d" in sys.abiflags: defines.append("PYTHON_WITH_PYDEBUG")
# Search within registry to find build tools try: # PY2 import _winreg as winreg except ImportError: # PY3 import winreg import winreg
_collect_installed_windows_kits_v10(winreg)