I hate it when projects list some arcane package manager as the official way to install. In 2015 when "cargo install" was added, I was arguing against it for this reason. But it's now 2024, Rust adoption has grown a lot -- at least in my bubble. We can at least mention it as an alternative. See also: github.com / rust-lang / rfcs/pull/1200#issuecomment-121014961 (Hyperlink defused to avoid GitHub cross-referencing it.)
2 KiB
Installation
With Cargo
Although Cargo is not a system package manager, if you have it available it’s an easy way to try RCL:
cargo +1.70.0 install --git https://github.com/ruuda/rcl.git rcl
From source
To build from source, clone the repository from one of the two mirrors:
git clone https://github.com/ruuda/rcl.git
git clone https://codeberg.org/ruuda/rcl.git
RCL is written in Rust and builds with Cargo. The repository includes a
rust-toolchain.toml file that specifies a compatible Rust version. When Cargo
is managed by Rustup, it will automatically fetch the right toolchain.
To build:
cargo build --release
Put the binary on your PATH to be able to use it system-wide, e.g.:
cp target/release/rcl ~/.local/bin
Python module from source
To build the Python module, follow the steps as before, but build the pyrcl
directory:
cargo build --release --manifest-path pyrcl/Cargo.toml
Then rename libpyrcl.so to rcl.so so that Python can discover it, and copy
it to a location on the PYTHONPATH, e.g.:
cp target/release/libpyrcl.so ./rcl.so
Now you can use the module as any regular one:
$ python3
>>> import rcl
>>> rcl.loads("10 + 32")
42
It is also possible to build a wheel that can be installed into a virtualenv using Maturin.
As a Nix flake
The repository includes a Nix flake. It is mainly used to provide a suitable environment for local development and CI, but it also includes the application itself. You can run RCL with a flake-enabled version of Nix, such as Nix 2.18:
nix run github:ruuda/rcl -- --help
The Nix flake also includes the Python module:
PYTHONPATH=$(nix build github:ruuda/rcl#pyrcl --print-out-paths)/lib python3