I can do
from cpython.version cimport PY_MAJOR_VERSION
if PY_MAJOR_VERSION == 3:
spam = bytes("spam")
However, if I try to do the detection at compile time, it fails.
from cpython.version cimport PY_MAJOR_VERSION
IF PY_MAJOR_VERSION == 3:
spam = bytes("spam")
Compile-time name 'PY_MAJOR_VERSION' not defined
Does anyone know a way to do this?