deltachat / deltachat-core-rust

Delta Chat Rust Core library, used by Android/iOS/desktop apps, bindings and bots 📧
https://delta.chat/en/contribute
Other
665 stars 85 forks source link

"One-click" `deltachat-rpc-server` installation #4524

Closed link2xt closed 1 year ago

link2xt commented 1 year ago

Installation of async Python bindings includes installation of deltachat-rpc-server binary and deltachat-rpc-client Python package. Installing deltachat-rpc-server involves downloading the correct binary from the Releases page into ~/.local/bin, renaming it into deltachat-rpc-server, setting executable permission and adding ~/.local/bin to PATH. After that user needs to install deltachat-rpc-client Python bindings from source.

This installation process will improve with #4216 and #4523, but is still far from the simplicity of pip install deltachat.

One example of a Rust project that distributes the binary via PyPI is ruff. It is installable via pip install ruff.

Unfortunately, PyPI does not allow uploading wheels with a simple linux_x86_64 platform tag anymore even though our binaries are statically linked against musl libc and work on any Linux regardless of whether it is a glibc-based distribution, musl-based distribution or an Android phone running deltachat-rpc-server in Termux. ruff project builds manylinux binaries using maturin-action GitHub Action which involves building ARM wheels in QEMU or using manylinux-cross Docker images to build glibc binaries. If we go this way and upload the binary to PyPI, we can either build manylinux binaries or just upload the same wheel with multiple platform tags.

Another distribution option is npm. esbuild package Go binaries to npm. Primary package https://www.npmjs.com/package/esbuild runs the script which downloads actual binary package like https://www.npmjs.com/package/@esbuild/linux-arm64 If we package to npm, we do not necessarily need to split packages and can make a single package that distributes Linux, Windows and macOS binary. This is how prebuildify works, so it seems to be acceptable in JavaScript world to download Windows binaries when you install on Linux and vice versa.

Third option is to make a script that downloads the correct binary from GitHub, similar to rustup. Binary hashes can be built into the script. It can also be built into __main__.py of deltachat-rpc-client so that deltachat-rpc-server is installable via python -m deltachat_rpc_client or something like this.

Fourth option is cargo-binstall but its usage is very limited as you need cargo-binstall to be installed already.

link2xt commented 1 year ago

git-cliff is another Rust package that uploads binaries to PyPI now: https://github.com/orhun/git-cliff/pull/158 This is mentioned in 1.3.0 release notes: https://git-cliff.org/blog/1.3.0/

link2xt commented 1 year ago

As deltachat-rpc-server is not usable by itself, I think we need to split this issue into "package deltachat-rpc-server on npm" and "package deltachat-rpc-server on PyPI", so Node.js client can depend on the first one and deltachat-rpc-client can depend on the second one without the user need to know anything about deltachat-rpc-server binary existing.

EDIT: opened an issue for npm packaging: #4694

link2xt commented 1 year ago

Zig provides ziglang package at https://pypi.org/project/ziglang/ Source code is at https://github.com/ziglang/zig-pypi What is interesting is that wheels are built directly using a small script.

link2xt commented 1 year ago

Made a PR to repackage binaries as Python wheels: #4831 Going to upload them to PyPI for the next core release.

link2xt commented 1 year ago

deltachat-rpc-server is installable with pip now: https://pypi.org/project/deltachat-rpc-server/

npm is tracked in #4694