-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Windows Stable ABI Support #4445
Comments
I think the first stage would need to be for distutils/setuptools to be able to build extensions that use the stable ABI. That is, the extension would need to link to |
Are you sure it's not supported on Windows? |
Interesting. They must have renamed those manually (and of course, they'd need to change the name each time a new Python version appeared, but that's not exactly a big issue except around release time). I guess they had to do some manual work when building to make the extensions use only the stable ABI, but there's no indication of how they did that. Their approach looks like a reasonable workaround for the lack of first-class support for the stable ABI, though. |
That's a clever workaround (that I'll be interested in using in the interim), but passing |
@pfmoore Heh, shows what I know about Windows. So I guess the next step here is to open an issue with setuptools to get it to link against |
Probably. Plus the build would need to define Py_LIMITED_ABI - but it might be worth waiting for @zooba to comment as he knows most about the MSVC support in setuptools in case there's any quirks that need to be considered. Personally, I wasn't even aware that the stable ABI had sufficient features to allow its use for defining extensions - I thought it was purely for embedding. |
The stable ABI is meant for extensions as well, and generally works fine. (There's actually no point in using it for embedding on Windows, since you would also have to ship a Python runtime with your application, which means you know which version you will have.) Defining Potential CRT conflicts should be isolated by the limited ABI, as that was an intentional part of the design. But of course it's fairly easy to spoil that if you are not careful in your extension. The main caveat I'm aware of right now is bpo-23903 - basically, keeping python3.dll up to date is a manual process, and most people who add to the limited ABI (normally accidentally) do not update the required file. The headers with In short:
So it's a bit of a mess. I love the concept of the limited ABI, but it's hard to recommend it over running multiple builds for supported versions. |
@zooba Ok so if |
One other requirement for 3.5 and later is to make sure that the extension suffix is But the point of the more specific suffix is to allow you to have multiple extensions in the same folder for different interpreters. So you can have a multi-targeted wheel with separate pyd's in it and the interpreter will load the correct one. |
@zooba With setuptools if you pass |
@dstufft Yes to both. When I was adding the more specific suffixes on Windows the |
So that leaves us back here then, since it seems like Python, setuptools, and wheel are currently capable of producing wheels that are linking to the limited ABI on Windows, but we're ignoring them because our |
If I understand correctly, Is that all? (I feel like I'm missing something) |
well, in my tests, setuptools doesn't seem to be currently capable of building extension modules that link to the limited ABI on Windows. It is still linking to the versioned PYTHON35.DLL or PYTHON36.DLL instead of PYTHON3.DLL associated with the Py_LIMITED_API. I wrote to distutils-sig and opened an issue at setuptools (sorry for cross posting, I thought it would be useful to mention this here as well) |
Sorry, I take that back... It's not setuptools nor distutils that's linking with the incorrect python DLL. Only when Py_LIMITED_API is already defined before including pyconfig.h, the correct "python3.lib" import library is passed to the linker with that #pragma. I was incorrectly defining Py_LIMITED_API only after including the Python.h header (which must be in turn including pyconfig.h). Ok good, so we are back to the original issue that pip/wheel pep425tags module fails with AssertionError on Windows because it
EDIT: I could have spared a couple of hours if I had read more carefully @zooba's commend above...
|
What needs to be done to add support for stable ABI tag on Windows? |
Sorry but it's way too late for pip 10. We're releasing the beta this weekend. Step 1 is probably not directly pip related, though. Building wheels that use the limited ABI would be a requirement, so I'd start with confirming (and documenting) precisely how to build such wheels. This may require changes to the wheel project to allow users to supply some form of |
yes, building the extension module works fine with setuptools. It's just a matter of using See https://github.com/anthrotype/hello-world-cpython-extension The bdist_wheel command already has an option The only way I can build a stable ABI wheel on Windows is without the --py-limited-api option, and by simply renaming it to *-cp35.cp36.cp37-none-win_amd64 (note the none as the abi tag). Then I can successfully install and import the wheel in all the listed cpython versions.
that's the question, exactly what would the appropriate tag be? "abi3" or "none"? |
cc @agronholm |
I have no idea. I wasn't involved in the definition of these standards. |
My point here was that I'd prefer to get the upstream questions resolved, so that there's a clear process for projects to build stable ABI wheels (that doesn't involve the manual processes you describe here). Then, we need agreement on what the correct "stable ABI for Windows" tags should be, and wheel should support them. That may well involve a round of discussion on distutils-sig and an update to the relevant standards. I'm not clear on what's involved in those steps, so that's about all I can say there. Once we have agreement on what the relevant tag is (and it's documented) it's easy to add it to pip. But we don't want to add a tag to pip before we have that agreement. |
I did try that a couple of months ago, maybe we should revive the discussion there: |
Unless I'm mistaken, the virtualenv issue has been fixed since 15.2.0. I'm a bit confused as to what the next step is? |
@jlaine the virtualenv issue is indeed fixed, but we now have a nasty long tail of existing virtualenvs (both outdated installs and virtual environments created with older versions) that would exhibit very ugly failure modes in the presence of a limited API wheel. That's not to say we shouldn't figure out how to move forward now that the primary blocker is fixed, but it's going to be a bit tricky. |
There is still the problem that —py-limited-api option of bdist_wheel command doesn’t work on Windows because abi3 isn’t recognised for that platform, so one has to work around this by using none as the abi tag. |
Description:
I'd like to be able to use the stable ABI to lessen the burden of distributing wheels. pip 9 supports this on macOS, but on Windows it does not. The stable ABI is a bit less useful on Windows due to CRT issues, but with the changes to CRT linking in Python 3.5 and above it seems like it should be possible to do a single stable ABI build that works with Python 3.5+? I am only a Windows Python user to the extent required by the build infrastructure for PyCA projects so hopefully someone more knowledgeable can help out here 😄
Assuming the stable ABI should be supported on Windows then we can start digging into the problem. It turns out that
pep425tags.get_supported()
doesn't show abi3 as a supported tag on Windows. The implementation usesimp.get_suffixes()
and on Windows this does not return anything withabi3
in it. Setuptools uses a function get_abi3_suffix that keys onpyd
in Windows, but it's unclear to me if this is the correct behavior. Is there a more correct way to detect support for stable ABI on Python 3 in Windows?(Aside: It'd be nice if
pep425tags
had a canonical single repo that is then vendored by pip/wheel rather than being divergent modules)The text was updated successfully, but these errors were encountered: