<div dir="ltr">Thank you, Steve.<div><br></div><div>Ok so, setuptools can successfully build extension modules with Py_LIMITED_API on Windows, with a generic *.pyd suffix and no extra tags. <br></div><div><br></div><div>However, there are still two problems before I can distribute them:</div><div><br></div><div>1) it's not clear how wheels containing such extension modules should be tagged on Windows, given that `abi3` tag is not recognized for that platform. The function imp.get_suffixes() used by both pip and wheel to get the list of supported tags does not return any abi3 suffixes on Windows, and for this reason the bdist_wheel command assumes from this that Windows does not support extensions built with Py_LIMITED_API, and gives an error. Some have resorted to tagging their Windows wheels with abi "none" to work around this, however "none" seems to imply that extension does not use the Python ABI which is not true.</div><div>Alex Grönholm (current maintainer of pypa/wheel package) pointed me to this other related discussion on distutils-sig (from 2013) where Paul Moore explains what the problem is: <a href="https://mail.python.org/pipermail/distutils-sig/2013-February/020022.html">https://mail.python.org/pipermail/distutils-sig/2013-February/020022.html</a> </div><div>Has anything happened since the to address this either in the PEPs and/or the tooling?</div><div><br></div><div>2) the current virtualenv module (not the built-in venv) does not copy over the required PYTHON3.DLL and thus importing such extension modules from within the virtual environment fails. The latter issue was already fixed in virtualenv's master branch, but virtualenv package hasn't seen a release since then (the last release 15.10.0 was in November 2016).</div><div><span style="font-size:13px"><a href="https://github.com/pypa/virtualenv/pull/1083">https://github.com/pypa/virtualenv/pull/1083</a></span><br></div><div><span style="font-size:13px"><br></span></div><div><span style="font-size:13px">I would love to take advantage of CPython limited API feature, and be able to distribute a one/two wheels per platform instead of four (multiply that by two for 32 vs 64 bit arch), and having to rebuild one for each new Python 3.x release.</span></div><div><span style="font-size:13px"><br></span></div><div><span style="font-size:13px">It works fine for Linux and macOS; I hope that Windows python users will also be able to enjoy this soon.</span></div><div><span style="font-size:13px">I am willing to contribute my time to help solving this issue.</span></div><div><span style="font-size:13px"><br></span></div><div><span style="font-size:13px">Thanks,</span></div><div><span style="font-size:13px"><br></span></div><div><span style="font-size:13px">Cosimo</span></div></div><br><div class="gmail_quote"><div dir="ltr">On Mon, Jan 8, 2018 at 1:31 AM Steve Dower <<a href="mailto:steve.dower@python.org">steve.dower@python.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-US" link="blue" vlink="#954F72"><div class="m_-5610149597555114083WordSection1"><p class="MsoNormal"><span lang="EN-AU">There is a solution to that problem on the linked issue. Basically, you need to declare Py_LIMITED_API in your code or as an extra preprocessor variable.<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-AU"><u></u> <u></u></span></p><p class="MsoNormal"><span lang="EN-AU">Windows doesn’t use a filename suffix for python3.dll linked extensions as it will be handled at load time. The tag for the wheel is outside of my area, so hopefully someone can chime in on that for you.<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-AU"><u></u> <u></u></span></p><p class="MsoNormal"><span lang="EN-AU">Cheers,<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-AU">Steve</span></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">Top-posted from my Windows phone</p><p class="MsoNormal"><u></u> <u></u></p><div style="border:none;border-top:solid #e1e1e1 1.0pt;padding:3.0pt 0in 0in 0in"><p class="MsoNormal" style="border:none;padding:0in"><b>From: </b><a href="mailto:cosimo@anthrotype.com" target="_blank">Cosimo Lupo</a><br><b>Sent: </b>Monday, January 8, 2018 10:32<br><b>To: </b><a href="mailto:distutils-sig@python.org" target="_blank">distutils-sig@python.org</a><br><b>Subject: </b>Re: [Distutils] Should abi3 tag be usable on Windows?</p></div></div></div><div lang="EN-US" link="blue" vlink="#954F72"><div class="m_-5610149597555114083WordSection1"><p class="MsoNormal"><u></u> <u></u></p><div><p class="MsoNormal">It turns out setuptools is still linking to PYTHON36.DLL instead of PYTHNO3.DLL even when py_limited_api=True</p><div><p class="MsoNormal"><span style="font-size:10.0pt"><a href="https://github.com/pypa/setuptools/issues/1248" target="_blank">https://github.com/pypa/setuptools/issues/1248</a></span></p></div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal"><span style="font-size:10.0pt">This is a different, though somewhat related, problem from the one concering wheel/pip pep425tags disallowing `abi3` tag on Windows.</span></p></div><div><p class="MsoNormal"><u></u> <u></u></p></div></div><p class="MsoNormal"><u></u> <u></u></p><div><div><p class="MsoNormal">On Sun, Jan 7, 2018 at 12:39 PM Cosimo Lupo <<a href="mailto:cosimo@anthrotype.com" target="_blank">cosimo@anthrotype.com</a>> wrote:</p></div><blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in"><div><p class="MsoNormal"><span style="font-size:10.0pt">I jut found this related pip issue: <a href="https://github.com/pypa/pip/issues/4445" target="_blank">https://github.com/pypa/pip/issues/4445</a></span></p><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal"><span style="font-size:10.0pt">(I myself as @anthrotype commented on that thread back in April last year but then completely forgot...)</span></p></div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">After re-reading it now, it's still not clear to me what the resolution on that issue was.</p></div></div><p class="MsoNormal"><u></u> <u></u></p><div><div><p class="MsoNormal">On Sun, Jan 7, 2018 at 10:12 AM Cosimo Lupo <<a href="mailto:cosimo@anthrotype.com" target="_blank">cosimo@anthrotype.com</a>> wrote:</p></div><blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in"><div><div name="messageBodySection"><p class="MsoNormal">Hello,<br><br>CFFI has recently added support for Py_LIMITED_API extension modules built for CPython 3.<br>The wheel module since version 0.30.0 also supports passing —py-limited-api cp3X to bdist_wheel command to allow the generated .whl to be installed on all CPython versions equal or greater than the one specified.<br><br>Yesterday I was trying to apply this on a cffi-built extension module, and it worked for Linux and macOS but failed for Windows:<br><br><a href="https://github.com/hynek/argon2_cffi/pull/32#issuecomment-355771832" target="_blank">https://github.com/hynek/argon2_cffi/pull/32<br></a><br>The AssertionError from wheel.pep425tags complains that a tag with abi3 would be unsupported for the target platform.<br><br>Alex Gronholm commented<br><br>> <span style="color:#24282d">imp.get_suffixes() does not seem to contain any ABI3 suffixes, but I'm not sure if this is even applicable on Windows.<br><br>Incidentally, I noticed one specific package, PyQt5, that distributes both abi3-tagged wheels for Mac and manylinux and Windows wheels for a range of cp35.cp36.cp37 but with abi tag set as “none”, and they do seem to work.<br><br>So, can one make such py_limited_api wheels work on Windows with the current state of the tooling, and if so how?<br><br>Thank you in advance</span></p></div></div><div><div name="messageSignatureSection"><p class="MsoNormal"><u></u> <u></u></p><div><p class="MsoNormal">Cosimo Lupo</p></div></div></div></blockquote></div><p class="MsoNormal"><br clear="all"><br>-- </p><div><div><p class="MsoNormal">Cosimo Lupo</p></div></div></blockquote></div><p class="MsoNormal"><br clear="all"><br>-- </p><p class="MsoNormal">Cosimo Lupo</p><p class="MsoNormal"><u></u> <u></u></p></div></div></blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Cosimo Lupo</div></div>