Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Dependency Analysis

Dependency analysis identifies package managers and their manifest files in the source project, building a graph of external libraries that must be mapped to Rust equivalents.

Supported Package Managers

Batuta’s DependencyManager enum recognizes manifests from all major ecosystems:

ManagerManifest FileLanguage
Piprequirements.txtPython
PipenvPipfilePython
Poetrypyproject.tomlPython
Condaenvironment.ymlPython
npmpackage.jsonJavaScript
Yarnyarn.lockJavaScript
CargoCargo.tomlRust
Go modulesgo.modGo
Mavenpom.xmlJava
Gradlebuild.gradleJava
MakeMakefileMulti-language

Detection Output

Each detected manifest produces a DependencyInfo record:

#![allow(unused)]
fn main() {
pub struct DependencyInfo {
    pub manager: DependencyManager,
    pub file_path: PathBuf,
    pub count: Option<usize>,
}
}

The count field holds the number of declared dependencies when parseable. This feeds into TDG scoring since high dependency counts correlate with migration complexity.

Python to Rust Mapping

For Python projects, the most critical output is mapping pip packages to Rust crate equivalents within the Sovereign AI Stack:

Python PackageRust CrateStack Layer
numpytruenoCompute primitives
scikit-learnaprenderML algorithms
torch / transformersrealizarInference
pandasalimentarData loading

CLI Usage

# Dependency-only analysis
$ batuta analyze --dependencies ./my-project

Dependencies
------------
pip (requirements.txt)  |  24 packages
Conda (environment.yml) |  18 packages
Make (Makefile)         |  detected

Dependency Graph Construction

When multiple manifest files reference the same packages, Batuta deduplicates and builds a unified dependency graph. Version constraints are preserved for compatibility checking during transpilation.

For projects using requirements.txt, Batuta parses version specifiers:

numpy>=1.24,<2.0    -->  trueno = "0.14"
scikit-learn~=1.3    -->  aprender = "0.24"
torch>=2.0           -->  realizar = "0.5"

ML Dependency Detection

The has_ml_dependencies() method on ProjectAnalysis checks whether any Python package manager (Pip, Conda, Poetry) is present. When true, the ML detection sub-phase activates to perform deeper import-level analysis.


Navigate: Table of Contents