Allow building python with shared libraries

This adds the possibility to build `python` with shared libraries.