Skip to content

Commit 87ee58c

Browse files
committed
Enable building abi3 shared objects
This depends on PyO3/pyo3#1125
1 parent 16a111d commit 87ee58c

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

setuptools_rust/build.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,14 @@ def build_extension(self, ext):
285285

286286
ext.install_script(ext_path)
287287
else:
288-
ext_path = build_ext.get_ext_fullpath(target_fname)
288+
# Technically it's supposed to contain a
289+
# `setuptools.Extension`, but in practice the only attribute it
290+
# checks is `ext.py_limited_api`.
291+
build_ext.ext_map[ext.name] = ext
292+
try:
293+
ext_path = build_ext.get_ext_fullpath(target_fname)
294+
finally:
295+
del build_ext.ext_map[ext.name]
289296

290297
try:
291298
os.makedirs(os.path.dirname(ext_path))

setuptools_rust/extension.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ class RustExtension:
4747
optional : bool
4848
if it is true, a build failure in the extension will not abort the
4949
build process, but instead simply not install the failing extension.
50+
py_limited_api : bool
51+
Same as `py_limited_api` on `setuptools.Extension`. Note that if you
52+
set this to True, your extension must pass the appropriate feature
53+
flags to pyo3 (ensuring that `unstable-apis` feature is disabled).
5054
"""
5155

5256
def __init__(
@@ -64,6 +68,7 @@ def __init__(
6468
script=False,
6569
native=False,
6670
optional=False,
71+
py_limited_api=False,
6772
):
6873
if isinstance(target, dict):
6974
name = "; ".join("%s=%s" % (key, val) for key, val in target.items())
@@ -83,6 +88,7 @@ def __init__(
8388
self.script = script
8489
self.native = native
8590
self.optional = optional
91+
self.py_limited_api = py_limited_api
8692

8793
if features is None:
8894
features = []

0 commit comments

Comments
 (0)