3

I'm building a Python extension module on Windows. The extension module is written in C++. When I call setup.py bdist then setup.py uses MinGW to compile the C++ code. Is there any way I can tell setup.py to use MSVS 2008 instead?

(Why do I want to do this? This issue is one reason.)

Community
  • 1
  • 1
Johan Råde
  • 20,480
  • 21
  • 73
  • 110

1 Answers1

7
setup.py build --compiler=msvc
setup.py bdist_egg
Johan Råde
  • 20,480
  • 21
  • 73
  • 110
AKX
  • 152,115
  • 15
  • 115
  • 172
  • No, I get the error message "error: option --compiler not recognized". – Johan Råde Mar 26 '12 at 21:15
  • `python setup.py build --compiler=msvc` (or `build_ext`) has usually done the trick for me, but YMMV. – AKX Mar 26 '12 at 21:18
  • And after "setup.py build --compiler=msvc" I just run "setup.py bdist" to create the distribution package. Right? – Johan Råde Mar 27 '12 at 09:07
  • What if there's several version of Visual Studio installed (e.g. VS2017, VS2019). Then how can I specify VS2017 instead of VS2019? – ChrisZZ Jul 26 '20 at 06:03
  • @HaxtraZ, I have this problem too where I have installed `Visual studio 2010` beside `2017` and know I don't know how make the `setup.py` to use 2017 one. – Saeed Masoomi Nov 13 '20 at 10:01
  • @SaeedMasoomi As a workaround, in setup.py we can invoke cmake. It is easy to specify compiler in cmake, just specify the generator. You may refer to this (written by me) https://github.com/Sanster/text_renderer/blob/d096c3b1ff8089371a47da4e76e85d041c7bb44a/libs/gpu/setup.py#L81 – ChrisZZ Nov 14 '20 at 10:31