🦀 Rust
📦 Pyaket uses the rust programming language for its core functionality.
Developing or compiling rust projects requires a toolchain - collection of a compiler, project manager, standard library, and other tools. Luckily, rustup, the official installation method, manages it all for you, including cross compilation; except for few external dependencies.
All major platforms are supported, though some might be problematic for your dependencies.
Native¶
✅ You can run $ pyaket rust
to install everything you need for your platform!
Windows¶
Ensure you have Winget installed, open a powershell and run:
1 |
|
There's two options for a C linker/compiler, MinGW or Visual C++ Build Tools (MSVC).
Reason: Rust can't bundle Build Tools due licensing, out of two let the user choose one. Some crates links against system libraries, such as zstd or networking, and need to interface with C.
Overall, it's easier to get started with MSVC if you're in a hurry or prefer official Microsoft tools - at the cost of maybe needing a license for medium companies. MinGW isn't bad, just extra steps.
MSVC¶
To avoid any potential confusion, here's a brief clarification on confusing products:
- Visual Studio is a full IDE for C#, C++, .NET development, the original one (purple) #
- Visual Studio Code is a lightweight code editor with many extensions (blue) #
- Visual Studio Build Tools is just the compiler, linker for C/C++, without the IDE #
Download and install Build Tools for Visual Studio, enable the following components:
- Visual C++ Build Tools
- Windows 10 SDK
- Windows 11 SDK
This process can be somewhat reliabily automated by running:
1 2 3 4 5 6 7 |
|
You should have cl.exe
, link.exe
and msvc.exe
available in your shell to verify.
MinGW¶
Download and install MSYS2, a lightweight Linux-like shell and package manager for Windows. Their homepage conveniently lists instructions for installing the MinGW toolchain 🙂
Either way, search for a MSYS2 Terminal application in your system, and run:
1 |
|
Note: MinGW will only be available inside the MSYS2 terminal, you might need to cd into your project's directory with cd /c/Users/user/.../Project
, activate the venv with activate.sh
.
Linux¶
Ensure you have your Distro's equivalent of a base-devel
package installed, and rustup
:
1 2 3 4 5 |
|
1 2 3 4 5 |
|
1 2 3 4 5 |
|
1 2 3 4 5 |
|
Either way, running rustup's official command should work too:
1 |
|
This script should have added ~/.cargo/bin
to your PATH
environment based on your shell.
Note: You may need to restart the terminal to have cargo
and rustc
available.
macOS¶
Ensure you have Homebrew and Xcode installed, install rustup with:
1 |
|
Workflows¶
GitHub Actions¶
Runners seem to already have rustup installed by default. Better be safe than sorry though - you can add the following action in your workflow job steps by @dtolnay (unofficial):
1 2 |
|
For compiling Linux ARM binaries, you might need:
1 2 |
|
A full workflow file could look like this:
Ensure wider compatibility by compiling with the oldest Linux runner you can get
The final binary will only work with the glibc version greater than or equal to the one used to compile it of the host. This is a core part of the Linux ABI, desktop distros are well updated but servers or embedded systems may not be.
.github/workflows/make-pyaket.yml | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
|