change wireup.canonical to use env

This was a little complicated because in test_hooks we do a dance with canonical, and I had to update that to work with env instead of os.environ directly.

Chain: #2226, #2227.