Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pure Python fallbacks #1839

Open
davidhewitt opened this issue Nov 7, 2023 · 4 comments
Open

Pure Python fallbacks #1839

davidhewitt opened this issue Nov 7, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@davidhewitt
Copy link
Member

Recently I heard a comment pointing out that many C extension modules offer a pure Python fallbacks for users on performs without wheels and do not wish to compile code.

For Rust there's the additional case that not all hardware can run Rust code. Even if that gap is closing over time, it would be nice to make it possible to package code for these users.

I think it might not be too hard - there could be a pure-python path in the pep517 backend which is activated by a MATURIN_NO_RUST environment variable. This pathway would just install the Python code and skip any compile. Maybe we could even delegate to another backend like hatch.

Then we just need an example, to prompt users to consider it.

Of course, maybe this kind of complex configuration is better left to setuptools-rust.

@davidhewitt davidhewitt added the enhancement New feature or request label Nov 7, 2023
@messense
Copy link
Member

messense commented Nov 7, 2023

See also #1081

@konstin
Copy link
Member

konstin commented Nov 7, 2023

The main problem generating different kinds of wheels based on the environment is that it breaks built source distribution caching, which is one of the main assumption a python package manager has to make. Would uploading a py3-none-any wheel next to the built wheels also work for you? That wheel could, but wouldn't even need to be built by maturin; I assume you need different python sources anyway if you don't have a rust lib to call into.

@davidhewitt
Copy link
Member Author

Interesting idea to upload a pure python wheel. I think if users have set the build backend to maturin in the pyproject.toml it will be awkward for them to use a different backend without us giving them a way to delegate it. We could add config for that.

I think the Python sources can be the same ones, they could do a fairly common trick of try to import from the Rust library, and if that fails fall back to Python.

cc @mgorny who I understand would want this in Gentoo. Does giving maturin the ability to assemble a pure Python wheel help with your distribution challenges, assuming extension authors then did add pure-python fallbacks?

@mgorny
Copy link

mgorny commented Nov 7, 2023

Yes, I think having an option of building pure Python wheels would be helpful. Rather than via envvar, enabling it via maturin options (i.e. via the config_settings dict in the PEP517 backend) would also work for us.

However, it all depends on whether the Python-Rust ecosystem would actually develop a culture of providing fallbacks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants