Move all this to `compatibility.py`.