[Python-Dev] mingw support?

Sturla Molden sturla at molden.no
Tue Aug 10 00:34:09 CEST 2010


>> Please understand that this very choice is there already.
>>
> That's great. Is that what the documentation refers to when it says
>
> """
> MSVCCompiler will normally choose the right compiler, linker etc. on its
> own. To override this choice, the environment variables
> DISTUTILS_USE_SDK and MSSdk must be both set. MSSdk indicates that the
> current environment has been setup by the SDK?s SetEnv.Cmd script, or
> that the environment variables had been registered when the SDK was
> installed; DISTUTILS_USE_SDK indicates that the distutils user has made
> an explicit choice to override the compiler selection by MSVCCompiler.
> """
>
> That isn't particularly clear to me, but it may be to others more
> familiar with building on Windows.


Ahh...

"MSSdk must be set" typically means we must use the Windows 7 SDK command
prompt.

Without DISTUTILS_USE_SDK, the build fails:


C:\DEVELOPMENT\test-distutils>setup.py build_ext
running build_ext
building 'test' extension
Traceback (most recent call last):
  File "C:\DEVELOPMENT\test-distutils\setup.py", line 6, in <module>
    ext_modules=[Extension('test', ['test.c'])],
  File "C:\Python26\lib\distutils\core.py", line 152, in setup
    dist.run_commands()
  File "C:\Python26\lib\distutils\dist.py", line 975, in run_commands
    self.run_command(cmd)
  File "C:\Python26\lib\distutils\dist.py", line 995, in run_command
    cmd_obj.run()
  File "C:\Python26\lib\distutils\command\build_ext.py", line 340, in run
    self.build_extensions()
  File "C:\Python26\lib\distutils\command\build_ext.py", line 449, in
build_exte
nsions
    self.build_extension(ext)
  File "C:\Python26\lib\distutils\command\build_ext.py", line 499, in
build_exte
nsion
    depends=ext.depends)
  File "C:\Python26\lib\distutils\msvc9compiler.py", line 449, in compile
    self.initialize()
  File "C:\Python26\lib\distutils\msvc9compiler.py", line 359, in initialize
    vc_env = query_vcvarsall(VERSION, plat_spec)
  File "C:\Python26\lib\distutils\msvc9compiler.py", line 275, in
query_vcvarsal
l
    raise ValueError(str(list(result.keys())))
ValueError: [u'path', u'include', u'lib']



Now let's do what the documentations says:

C:\DEVELOPMENT\test-distutils>set DISTUTILS_USE_SDK=1

C:\DEVELOPMENT\test-distutils>setup.py build_ext
running build_ext
building 'test' extension
creating build
creating build\temp.win-amd64-2.6
creating build\temp.win-amd64-2.6\Release
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\Bin\amd64\cl.exe /c
/nolog
o /Ox /MD /W3 /GS- /DNDEBUG -IC:\Python26\include -IC:\Python26\PC
/Tctest.c /Fo
build\temp.win-amd64-2.6\Release\test.obj
test.c
creating build\lib.win-amd64-2.6
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\Bin\amd64\link.exe
/DLL /n
ologo /INCREMENTAL:NO /LIBPATH:C:\Python26\libs
/LIBPATH:C:\Python26\PCbuild\amd
64 /EXPORT:inittest build\temp.win-amd64-2.6\Release\test.obj
/OUT:build\lib.win
-amd64-2.6\test.pyd /IMPLIB:build\temp.win-amd64-2.6\Release\test.lib
/MANIFESTF
ILE:build\temp.win-amd64-2.6\Release\test.pyd.manifest
test.obj : warning LNK4197: export 'inittest' specified multiple times;
using fi
rst specification
   Creating library build\temp.win-amd64-2.6\Release\test.lib and object
build\t
emp.win-amd64-2.6\Release\test.exp
C:\Program Files\Microsoft SDKs\Windows\v7.0\Bin\x64\mt.exe -nologo
-manifest bu
ild\temp.win-amd64-2.6\Release\test.pyd.manifest
-outputresource:build\lib.win-a
md64-2.6\test.pyd;2


:-D


Sturla



More information about the Python-Dev mailing list