maturin icon indicating copy to clipboard operation
maturin copied to clipboard

Build option to dynamically set abi3 version

Open alex opened this issue 2 years ago • 9 comments

Currently the way to set abi3 version is via applying a versioned-feature in Cargo.toml (e.g., abi3-py312).

I'm requesting a way set that at the CLI. The reason for this is to be able to build wheels targeting multiple abi3 versions from the same source.

We're currently able to do this with setuptools-rust with the following command:

if [ -n "${{ matrix.PYTHON.ABI_VERSION }}" ]; then
    PY_LIMITED_API="--config-settings=--build-option=--py-limited-api=${{ matrix.PYTHON.ABI_VERSION }} --no-build-isolation"
fi
OPENSSL_DIR="/opt/pyca/cryptography/openssl" \
    OPENSSL_STATIC=1 \
    .venv/bin/python -m pip wheel -v $PY_LIMITED_API cryptograph*.tar.gz -w dist/ && mv dist/cryptography*.whl tmpwheelhouse

alex avatar Dec 24 '23 15:12 alex

What's the motivation for targeting multiple abi3 versions instead of the lowest supported?

konstin avatar Dec 26 '23 11:12 konstin

To be able to take advantage of improvements (e.g. performance) on newer versions, while maintaining compatibility.

The specific improvement that motivated us to do this was https://github.com/PyO3/pyo3/blob/main/src/impl_/pymodule.rs#L83-L119

alex avatar Dec 26 '23 12:12 alex

I think it's already possible by using MATURIN_PEP517_ARGS env var or --config-settings, for example

pip wheel --config-settings=build-args='--features abi3-py312'

messense avatar Dec 28 '23 02:12 messense

Ah, that will be respected? Let me test it. Thanks!

alex avatar Dec 28 '23 13:12 alex

Hmm, it fails when building an sdist with:

Caused by: You have selected the abi3 feature but not a minimum version (e.g. the abi3-py36 feature). maturin needs a minimum version feature to build abi3 wheels.

alex avatar Dec 28 '23 13:12 alex

I guess it fails everywhere except the places I passed that argument.

alex avatar Dec 28 '23 13:12 alex

To follow up on this, it's missing a key element that setuptools-rust "auto" provides: using abi3 with the current python if nothing is explicitly provided.

alex avatar Jan 15 '24 01:01 alex

Do you think support for something like "auto" abi3, where it used the current Python's version is possible?

alex avatar Feb 19 '24 15:02 alex

Do you think support for something like "auto" abi3, where it used the current Python's version is possible?

I think we can support this, we can change maturin to use the current Python's version when abi3 feature is enabled without an explicit abi3-pyXY feature, and print a message about this behavior of course.

messense avatar Feb 26 '24 05:02 messense