ENH: Nest Pyglet imports for CLI use

I tried to run some analysis code that needed `read_tab` from `expyfun` form the CLI (remote SSH login), and couldn't do it because importing `pyglet.window` requires an active X server. This protects the Pyglet imports so that such code can run.

Ready for review/merge @rkmaddox.
I originally had this code in `_externals` because I thought Pyglet would eventually merge it upstream, but they decided not to. So instead I include it in our files directly below.