Imitate Visual C++ with MinGW or other C++ compilers (for Python packages based on Visual C++)

I was redirected to this forum by a member of github vscode-cpptools.

Please refer to the github link to see details of the idea and its comments. It is about how to reduce the size of C/C++ compiler that is required by Python packages, take dtaidistance for instance, among many others. It would be good to be able to run them with MinGW instead, or to reduce MSVC strongly in size.

There was a workaround until Python 3.4 which might also be an approach now: Use MinGW compiler till Python 3.4 by adding a “distutils.cfg” to the folder “\Lib\distutils” in Python install directory. It would be nice to have that MinGW “distutils.cfg” workaround for the recent Python versions as well.

It was I who gave the redirect. Welcome!

The people who need to see this question are likely the setuptools and pip folk, since what you need is some kind of option to override the compiler used for build options. (Historically, this would also have involved contributing code to the distutils module in CPython, but now that it’s moving into setuptools you’re best to start there).

If anyone knows the current active MinGW folk, it may be valuable to loop them in. I have no idea what their status is on making it look more like MSVC.

I do know that both the MSVC and Windows teams are very aware of the size of their respective packages and the complexity in acquiring/installing them. I’m not sure what changes will come about yet, but as those are the tools that are properly supported we’ll make sure that Python continues to work with them.

As for the distutils.cfg workaround, I doubt that was ever removed, so not sure why it stopped working there. It may be when setuptools started being injected by pip, in which case you’ll still want to work with someone from that project (@jaraco probably) to figure out what broke it, though it’s also possible that MinGW will say they shouldn’t be used anymore.


Thank you for taking this up and redirecting it to the Python community.
I am myself just a normal end user who caught the idea due to a nearly full disk on the netbook, that is why I cannot contribute anything. I can perhaps guess that the workaround with distutils.cfg seems most promising to revive. It would already be a good step to know why it does not work anymore. By the way, I have not tested the workaround. Unlikely, as it is not documented, but not that it is actually still working? :slight_smile:

I’m pretty sure that part of the problem was that mingw didn’t really support linking with any C runtime other than msvcrt. As Python uses a different C runtime, this has the potential to cause issues (in practice, the risk seems to be mostly theoretical, though). I don’t think enough people found using MSVC an issue (particularly once it became free to use) that anyone with sufficient technical knowledge was interested in working on maintaining that option.

I’ve no idea whether any of the above is still true or relevant, though…