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.