Skip to content

Commit 5ff949b

Browse files
committed
Enable building abi3 shared objects
This depends on PyO3/pyo3#1125
1 parent 9fcd0e7 commit 5ff949b

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

setuptools_rust/build.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,15 @@ 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+
assert ext.name not in build_ext.ext_map
292+
build_ext.ext_map[ext.name] = ext
293+
try:
294+
ext_path = build_ext.get_ext_fullpath(target_fname)
295+
finally:
296+
del build_ext.ext_map[ext.name]
289297

290298
try:
291299
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 `abi3` feature is enabled).
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)