https://github.com/mrazza/portage-rust-deps
Generate Rust crate dependencies for Gentoo ebuilds
https://github.com/mrazza/portage-rust-deps
Last synced: 20 days ago
JSON representation
Generate Rust crate dependencies for Gentoo ebuilds
- Host: GitHub
- URL: https://github.com/mrazza/portage-rust-deps
- Owner: mrazza
- License: apache-2.0
- Created: 2026-05-18T03:39:28.000Z (about 1 month ago)
- Default Branch: main
- Last Pushed: 2026-05-27T01:50:14.000Z (about 1 month ago)
- Last Synced: 2026-05-27T03:21:41.242Z (about 1 month ago)
- Language: Python
- Homepage:
- Size: 10.7 KB
- Stars: 0
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# portage-rust-deps
A Python utility to generate and update Gentoo `CRATES` variables for Rust-based ebuilds. This is the Rust equivalent of [portage-dotnet-deps](https://github.com/mrazza/portage-dotnet-deps).
## Features
- **Dependency Extraction**: Supports two methods for identifying dependencies:
- `metadata`: Uses `cargo metadata` (requires Rust/Cargo installed). Most reliable for complex workspaces.
- `lockfile`: Parses `Cargo.lock` directly using Python's built-in `tomllib` (requires Python 3.11+). Works without Rust installed.
- **Ebuild Updating**: Can automatically update an existing `CRATES` block in an ebuild or insert one before the `inherit cargo` line.
- **Legacy Format**: Generates entries in the `name@version` format.
## Usage
### Basic Usage (Print to Console)
```bash
./generate_ebuild_crates.py /path/to/rust-project
```
### Update an Ebuild
```bash
./generate_ebuild_crates.py /path/to/rust-project --ebuild /path/to/your.ebuild
```
### Use Lockfile Method (No Cargo required)
```bash
./generate_ebuild_crates.py /path/to/rust-project --method lockfile
```
## Requirements
- Python 3.11+ (for `tomllib` support in the `lockfile` method).
- Rust/Cargo (only if using the `metadata` method).
## Running Tests
To run the automated test suite, use the built-in `unittest` module:
```bash
python3 -m unittest tests/test_generate_ebuild_crates.py
```
## License
Apache License 2.0