Skip to content

Commit

Permalink
deprecate RustExtension.py_limited_api
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhewitt committed Feb 2, 2024
1 parent e374a56 commit ebc9e82
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 20 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## Unreleased
### Changed
- Deprecate `py_limited_api` option to `RustExtension` in favour of always using `"auto"` to configure this from `bdist_wheel`. [#410](https://github.com/PyO3/setuptools-rust/pull/410)

## 1.8.1 (2023-10-30)
### Fixed
- Fix regression in `install_extension` crashing since 1.8.0. [#380](https://github.com/PyO3/setuptools-rust/pull/380)
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ target = "hello_world._lib" # The last part of the name (e.g. "_lib") has to ma
# but you can add a prefix to nest it inside of a Python package.
path = "Cargo.toml" # Default value, can be omitted
binding = "PyO3" # Default value, can be omitted
py-limited-api = "auto" # Default value, can be omitted
```

Each extension module should map directly into the corresponding `[lib]` table on the
Expand Down
1 change: 0 additions & 1 deletion examples/hello-world-setuppy/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
# in Cargo.toml and the function name in the `.rs` file,
# but you can add a prefix to nest it inside of a Python package.
path="Cargo.toml", # Default value, can be omitted
py_limited_api="auto", # Default value, can be omitted
binding=Binding.PyO3, # Default value, can be omitted
)
],
Expand Down
1 change: 0 additions & 1 deletion examples/hello-world/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ find = { where = ["python"] }
# Private Rust extension module to be nested into Python package
target = "hello_world._lib" # The last part of the name (e.g. "_lib") has to match lib.name in Cargo.toml,
# but you can add a prefix to nest it inside of a Python package.
py-limited-api = "auto" # Default value, can be omitted
binding = "PyO3" # Default value, can be omitted
# See reference for RustExtension in https://setuptools-rust.readthedocs.io/en/latest/reference.html

Expand Down
2 changes: 1 addition & 1 deletion examples/rust_with_cffi/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
packages=find_packages(where="python"),
package_dir={"": "python"},
rust_extensions=[
RustExtension("rust_with_cffi.rust", py_limited_api="auto"),
RustExtension("rust_with_cffi.rust"),
],
cffi_modules=["cffi_module.py:ffi"],
install_requires=["cffi"],
Expand Down
24 changes: 8 additions & 16 deletions setuptools_rust/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,22 +107,7 @@ class RustExtension:
optional: If it is true, a build failure in the extension will not
abort the build process, and instead simply not install the failing
extension.
py_limited_api: Similar to ``py_limited_api`` on
``setuptools.Extension``, this controls whether the built extension
should be considered compatible with the PEP 384 "limited API".
- ``'auto'``: the ``py_limited_api`` option of
``bdist_wheel`` will control whether the extension is
built as a limited api extension. The corresponding
``pyo3/abi3-pyXY`` feature will be set accordingly.
This is the recommended setting, as it allows
to build a version-specific extension for best performance.
- ``True``: the extension is assumed to be compatible with the
limited abi. You must ensure this is the case (e.g. by setting
the ``pyo3/abi3`` feature).
- ``False``: the extension is version-specific.
py_limited_api: Deprecated.
"""

def __init__(
Expand Down Expand Up @@ -180,6 +165,13 @@ def __init__(
DeprecationWarning,
)

if self.py_limited_api != "auto":
warnings.warn(
"`RustExtension.py_limited_api` is deprecated, use [bdist_wheel] configuration "
"in `setup.cfg` or `DIST_EXTRA_CONFIG` to build abi3 wheels.",
DeprecationWarning,
)

def get_lib_name(self, *, quiet: bool) -> str:
"""Parse Cargo.toml to get the name of the shared library."""
metadata = self.metadata(quiet=quiet)
Expand Down

0 comments on commit ebc9e82

Please sign in to comment.