Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, maturin is not self-contained: You need to install rust on the machine in order to build a package. We can improve this by downloading a matching rustup, using it to install cargo and rustc into a temporary directory and using this rust for the build. As long as the platform is supported by rustup, we get a self-contained build that doesn't mess with the host system. You can for example use
pip install ...
in a freshpython3-slim
docker container and any rust dependency with a missing wheel will build and install without additional setup (while it currently fails and prompts you to install rust).To inject this cache installation, we need to set
PATH
,RUST_HOME
andCARGO_HOME
whenever we callcargo
orrustc
.Since setuptools rejects supporting programmatically setting dependencies (pypa/setuptools#2854), we use their hack of an in-tree build backend that overrides some of setuptools' hooks. In this hook, we install https://github.com/konstin/puccinialin if rust is missing, and later (in
setup.py
) run it to install rust and run maturin with the right env vars already set.There's an option to disable rust bootstrapping through an env vars for users that don't want this automatism (e.g. linux distros).
In effect, this now works (using the dev maturin for demonstration):
I've only tested linux/windows/mac and x86_64/arm64 in puccinialin so far, but i hope to add all the other rustup supporter platforms and arches over time.
Needs PyO3/setuptools-rust#504