Move compatibility version testing to compatibility.py

This consolidates version checking and makes the appropriate imports
from sympy/core/compaitibility.py.