Coded up in https://bitbucket.org/pypa/wheel/pull-requests/69 and
https://github.com/pypa/pip/pull/3922 and supported in setuptools 26.

It's a multi-step process, unfortunately, but if you do it correctly then
you should need a lot fewer wheels:

0. Use only the functions from the limited api, for example, by using cffi
to generate your C extensions. #define Py_LIMITED_API to the desired value.
Python 3.3 is a good minimum, adding some useful functions forgotten in
Python 3.2's limited api.
1. In setup.py, specify Extension(..., py_limited_api=True) to use .abi3.so
filenames on your C extensions
2. In setup.cfg, specify [bdist_wheel] py_limited_api=cp32 # or greater,
tagging the wheel for compatibility with that version of CPython, or later.
This argument is ignored outside of CPython 3.
3. A new enough version of pip recognizes the wheel tag

Your extension uses the limited API, setuptools' Extension() changes the
filename so that more than just the exact version of Python can find it,
wheel adds a cp33-abi3-manylinux1_x86 tag, pip finds it, and you no longer
have to compile new wheels just because a new version of CPython came out.

On Tue, Aug 2, 2016 at 4:02 AM Nick Coghlan <[email protected]> wrote:

> On 2 August 2016 at 02:24, Daniel Holth <[email protected]> wrote:
> > On Mon, Aug 1, 2016 at 12:01 PM Steve Dower <[email protected]>
> wrote:
> >> The DLL tag on Windows will have to just be ".pyd" if you want to
> >> support back prior to 3.5. In 3.5 you can use ".cp35-win32.pyd" or
> >> ".cp35-win_amd64.pyd" and the importer will prefer that DLL over a plain
> >> ".pyd", but my proposal to also support ".cp3-${PLAT}.pyd" here didn't
> >> make it.
> >>
> >> The wheel tag is more important than the DLL tag. (Possibly you're not
> >> even suggesting changing the DLL name at all and just passing the flag
> >> through for the build option? Hard to tell from the discussion.)
> >
> > I'm sure we are interpolating from Linux, where you'd be looking at
> > extensions .cpython-35m-x86_64-linux-gnu.so versus .abi3.so. But any DLL
> > extension that the target CPythons will agree to load, plus an
> appropriate
> > wheel tag, should be sufficient for our use case.
>
> Right, on *nix the SO names already include the SOABI details by
> default, so we really do want to change those to something less
> explicit, but I'm not sure it's even possible to using a completely
> unqualified SO name even if we wanted to.
>
> On Windows, if we have to rely on dropping any ABI indicated from the
> DLL entirely, we can leave with - pip should keep things from
> colliding too badly.
>
> Cheers,
> Nick.
>
> --
> Nick Coghlan   |   [email protected]   |   Brisbane, Australia
>
_______________________________________________
Distutils-SIG maillist  -  [email protected]
https://mail.python.org/mailman/listinfo/distutils-sig

Reply via email to