$npx -y skills add opendatahub-io/ai-helpers --skill python-full-depsResolve the full install-time dependency tree for a Python package. Use when the user needs all transitive dependencies, full dependency list, or install requirements resolved for a specific Python version with environment markers.
| 1 | # Python Full Dependency Tree |
| 2 | |
| 3 | Resolve and return the complete set of packages that would be installed for a given Python package (entire transitive dependency tree), resolved for a specific Python version so environment markers are respected. |
| 4 | |
| 5 | ## When to use |
| 6 | |
| 7 | - User asks for "full dependency tree", "all dependencies", "transitive dependencies", or "install requirements" of a Python package. |
| 8 | - User needs the full picture of install-time dependencies (not just direct deps from metadata). |
| 9 | - User wants to understand the total footprint of a package in a container image or environment. |
| 10 | - Complement to `python-packaging-complexity` when the full resolved tree is needed beyond direct metadata. |
| 11 | |
| 12 | ## When NOT to use |
| 13 | |
| 14 | - User only needs **direct** (first-level) dependencies -- use `python-packaging-complexity` instead, which reads PyPI metadata without resolution. |
| 15 | - User is asking about **build-time** dependencies (e.g. setuptools, CMake, Cython) -- those are not included in install-time resolution. |
| 16 | - User is asking about **dev/test** dependencies (e.g. pytest, mypy) -- those are extras, not default install deps. |
| 17 | - User is asking about **license**, **source**, or **build complexity** analysis -- use the corresponding `python-packaging-*` skills. |
| 18 | |
| 19 | ## Inputs |
| 20 | |
| 21 | | Parameter | Required | Default | Description | |
| 22 | |-----------------|----------|---------|-------------------------------------| |
| 23 | | package name | Yes | — | PyPI project name (e.g. `vllm`) | |
| 24 | | package version | No | latest | e.g. `0.4.0` | |
| 25 | | Python version | No | 3.12 | e.g. `3.11`, `3.12` | |
| 26 | |
| 27 | ## Instructions |
| 28 | |
| 29 | When a user asks about the full dependency tree, all transitive dependencies, or install requirements for a Python package: |
| 30 | |
| 31 | 1. **Run the helper script** with the package name and optional version/Python version: |
| 32 | |
| 33 | ```bash |
| 34 | python3 scripts/resolve_full_deps.py <package> [version] [python_version] |
| 35 | ``` |
| 36 | |
| 37 | The script automatically tries `uv pip compile` first (fast, supports cross-version resolution). If `uv` is not installed, it falls back to `pip install --dry-run --report` in a temporary venv. |
| 38 | |
| 39 | 2. **Present the output** to the user: |
| 40 | - Output is sorted alphabetically and deduplicated. |
| 41 | - Each line is `name==version` with PEP 503 normalized names. |
| 42 | - Warnings/errors go to stderr and should be relayed to the user. |
| 43 | |
| 44 | 3. **Provide context** based on the results: |
| 45 | - Total number of transitive dependencies. |
| 46 | - Notable packages in the tree (e.g. `torch`, `numpy`, `cuda` related packages). |
| 47 | - If the user is assessing container image size or supply-chain risk, highlight the dependency count and any heavy packages. |
| 48 | |
| 49 | ## Output format |
| 50 | |
| 51 | Return a **sorted, unique** set of normalized dependencies. Include version unless the user asked for names only. |
| 52 | |
| 53 | - One dependency per line: `name==version` |
| 54 | - Or as a list: `["package-a==1.0.0", "package-b==2.1.0"]` |
| 55 | |
| 56 | ### Example |
| 57 | |
| 58 | ```bash |
| 59 | $ python3 scripts/resolve_full_deps.py requests 2.32.3 |
| 60 | certifi==2024.8.30 |
| 61 | charset-normalizer==3.4.1 |
| 62 | idna==3.10 |
| 63 | requests==2.32.3 |
| 64 | urllib3==2.3.0 |
| 65 | ``` |
| 66 | |
| 67 | Interpretation: `requests 2.32.3` pulls in 4 transitive dependencies (5 total including itself). |
| 68 | |
| 69 | ## Error handling |
| 70 | |
| 71 | - **`uv` not found**: The script automatically falls back to pip. If the user sees a stderr warning about this, suggest installing [uv](https://docs.astral.sh/uv/) for faster resolution. |
| 72 | - **Package not found on PyPI**: The script exits with a non-zero code and an error on stderr. Verify the package name spelling and whether a specific version exists. |
| 73 | - **Network errors / timeouts**: Both `uv` and `pip` need network access to PyPI. If resolution times out (150s), suggest retrying or checking network connectivity. |
| 74 | - **pip version too old**: The `--report` flag requires pip >= 22.2. If the fallback fails with an unrecognized argument error, advise upgrading pip. |
| 75 | |
| 76 | ## Integration with other skills |
| 77 | |
| 78 | - **`python-packaging-complexity`**: Use that skill first to get direct dependencies and build complexity, then use this skill to get the full transitive tree. Together they give a complete picture. |
| 79 | - **`python-packaging-license-checker`** / **`python-packaging-license-finder`**: After getting the full dep list from this skill, feed individual packages into the license skills to audit the entire tree. |