Reduce the size of the build by not compiling parts of stubgen (#10107)
This might fix the out-of-memory errors we are getting when
building Windows wheels. In any case these will speed up
builds slightly.
The `stubgen.py` file must be compiled since it uses inheritance
from native classes. This removes one case of inheritance, but
the others are harder to get rid of.