get the realpath up front, then grab the dirname.
get the realpath up front, then grab the dirname.

This allows for use within iPython which would otherwise return "pygilstate_check.py" with __file__ only.
pankajp/pygilstate_check,pankajp/pygilstate_check