python-cffi / cffi

A Foreign Function Interface package for calling C libraries from Python.
https://cffi.readthedocs.io/en/latest/
Other
114 stars 41 forks source link

Support for declarative project configuration (setup.cfg / pyproject.toml) #55

Open schlamar opened 8 months ago

schlamar commented 8 months ago

There was a ticket in heptapod including a patch to support configuration of cffi modules in setup.cfg https://foss.heptapod.net/pypy/cffi/-/issues/396

Personally, I would prefer a configuration in pyproject.toml as this seems to be the new standard everyone is adopting.

arigo commented 8 months ago

I won't work on it as long as the existing solution works fine, but I'm not against it, if the new way works in older systems too. Pull requests welcome. See e.g. https://github.com/python-cffi/cffi/actions/runs/7709709848 for the list of supported versions of Pythons. (Ideally it should also work if the user uses some setuptools that was installed at the time of that Python release and not updated since. I'm pretty sure that's a completely unrealistic expectation, though, so take that with a grain of salt.)

genotrance commented 7 months ago

Here's my setup.py:

from setuptools import setup

setup(
    cffi_modules=["mcurl/gen.py:ffibuilder"]
)

Everything else is in pyproject.toml and it works on Python 3.6+ on Windows, Linux (glibc/musl, x86_64/i686/aarch64) and OSX. Will be nice to move this into pyproject.toml.

James-E-A commented 7 months ago

Everything else is in pyproject.toml and it works on Python 3.6+ on Windows, Linux (glibc/musl, x86_64/i686/aarch64) and OSX. Will be nice to move this into pyproject.toml.

@genotrance Does your project support ABI3?

In my own project, I've got that file still existing for two reasons: one of them is to keep cffi_modules referenced, and the other is to make ABI3 work with CFFI.

I'm not sure my solution is a good one, though, and I'm also trying to ditch setup.py and move to a "pure" pyproject.toml, so I'm curious how other people are handling this.

genotrance commented 7 months ago

Yes it supports ABI3 - here's how I am specifying it via the CLI. The resulting wheels run on every version of Python I've tested.