How can I build my C extensions with MinGW-w64 in Python?

后端 未结 4 1201
星月不相逢
星月不相逢 2020-12-07 16:03

So I have a few Python C extensions I have previously built for and used in 32 bit Python running in Win7. I have now however switched to 64 bit Python, and I am having issu

4条回答
  •  隐瞒了意图╮
    2020-12-07 16:23

    I realize this is an old question, but it is still the top search result. Today, in 2019, I was able to do this:

    https://github.com/PetterS/quickjs/commit/67bc2428b8c0716538b4583f4f2b0a2a5a49106c

    In short:

    1. Make sure a 64-bit version of mingw-w64 is in the PATH.
    2. Monkey-patch distutils:
      import distutils.cygwinccompiler
      distutils.cygwinccompiler.get_msvcr = lambda: []
      
    3. Some differences in the shell w.r.t. escaping.

    4. extra_link_args = ["-Wl,-Bstatic", "-lpthread"] in order to link statically and not have extra runtime deps.

    5. pipenv run python setup.py build -c mingw32 now works.

提交回复
热议问题