Fix `autogenerate` for extension modules

* Basically, use the `ScriptDirectory` instance (which contains the
  overrides for the locations of `env.py` and the `versions` directory)
  from the extensions environment rather than building a new one.
Merge pull request #900 from reciprocity/feature/minor-migrate-fixes

Fix `autogenerate` for extension modules