Rust
Warning
This section is outdated and needs a cleanup/rewrite:
- Cross compilation to MacOS needs an SDK
- Rust is now auto-provided by Rustbin
📦 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, the official installation method rustup manages it all for you, including cross compilation (except for a few external dependencies).
All major platforms are supported, though some might be problematic for your project.
Native¶
Linux¶
Install rustup with the official installation script, or from your package manager:
Ensure you have your Distro's equivalent of a base-devel package installed and/or mingw:
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, ensure it.
Windows¶
Ensure you have WinGet installed, open a powershell and run:
There's two options for a C linker/compiler now, 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 MinGW, which is needed for cross compiling to macOS and Linux anyway. Go with MSVC if you prefer official Microsoft tools or will only target Windows.
MinGW¶
Download and install MSYS2, a lightweight Linux-like shell and package manager for Windows, in the default location at C:\msys64.
That's it: The python package will auto install dependencies for the platform you're compiling for
MSVC¶
To avoid any potential confusion, here's a brief clarification on product names:
- 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:
winget install --id Microsoft.VisualStudio.2022.BuildTools `
--override " `
--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 `
--add Microsoft.VisualStudio.Component.Windows10SDK `
--add Microsoft.VisualStudio.Component.Windows11SDK `
" `
--wait --passive
You should have cl.exe, link.exe and msvc.exe available in your shell.
macOS¶
Install Homebrew and Xcode, then rustup with:
Windows cross compilation:
Linux cross compilation: