File tree Expand file tree Collapse file tree 8 files changed +62
-2
lines changed
Expand file tree Collapse file tree 8 files changed +62
-2
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ backends = [
55 " scikit-build-core" ,
66 " setuptools @ git+https://github.com/ngoldbaum/setuptools@abi3.abi3t" ,
77 " packaging @ git+https://github.com/ngoldbaum/packaging@abi3.abi3t" ,
8+ " cffi @ git+https://github.com/ngoldbaum/cffi@abi3t.abi3" ,
89]
910build-tools = [
1011 " cython @ git+https://github.com/cython/cython@freethreading-limited-api-preview" ,
Original file line number Diff line number Diff line change 1+ recursive-include src/limited *.py
2+ include setup.py
3+ include pyproject.toml
Original file line number Diff line number Diff line change 1+ [build-system ]
2+ build-backend = " setuptools.build_meta"
3+ requires = [
4+ " setuptools@git+https://github.com/ngoldbaum/setuptools@abi3.abi3t" ,
5+ " packaging@git+https://github.com/ngoldbaum/packaging@abi3.abi3t" ,
6+ " cffi@git+https://github.com/ngoldbaum/cffi@abi3t.abi3" ,
7+ ]
8+
9+ [project ]
10+ name = " limited-api"
11+ version = " 1.2.3"
12+ dependencies = [
13+ " cffi@git+https://github.com/ngoldbaum/cffi@abi3t.abi3" ,
14+ ]
Original file line number Diff line number Diff line change 1+ [bdist_wheel]
2+ py_limited_api = cp315
Original file line number Diff line number Diff line change 1+ # CFFI doesn't support declarative setup for this
2+ # see https://github.com/python-cffi/cffi/issues/55
3+ from setuptools import setup
4+
5+ setup (
6+ cffi_modules = ["src/limited/gen_limited.py:ffibuilder" ],
7+ )
Original file line number Diff line number Diff line change 1+ from ._limited import lib
2+
3+ add = lib .add
Original file line number Diff line number Diff line change 1+ from cffi import FFI
2+
3+ ffibuilder = FFI ()
4+
5+ ffibuilder .set_source (
6+ "limited._limited" ,
7+ r"""
8+ #include <stdint.h>
9+
10+ static int64_t add(int64_t a, int64_t b) {
11+ return a + b;
12+ }
13+ """ ,
14+ libraries = [],
15+ )
16+
17+ ffibuilder .cdef (
18+ r"""
19+ int64_t add(int64_t a, int64_t b);
20+ """
21+ )
22+
23+ if __name__ == "__main__" :
24+ ffibuilder .compile (verbose = True )
Original file line number Diff line number Diff line change 3838
3939import limited
4040
41- # if the build system created a package, import the actual extension
4241if hasattr(limited, "__path__"):
43- from limited import limited
42+ if hasattr(limited, "lib"):
43+ # limited.lib is present for CFFI. We had to create a Python wrapper package
44+ # because CFFI doesn't directly expose wrapped functions in the top-level
45+ # namespace of an extension module
46+ limited = limited._limited
47+ else:
48+ # if the build system created a package, import the actual extension
49+ from limited import limited
4450
4551assert ".abi3" in Path(limited.__file__).name, (
4652 f"{limited.__file__} is not abi3 extension")
You can’t perform that action at this time.
0 commit comments