rgpycrumbs.locks¶
Consume Python lock files / SBOMs as install pins for dispatch + AUTO_DEPS.
Supported formats (auto-detected by path/content):
PEP 751
pylock.toml/pylock.*.toml— standards-track lockuv.lock — uv native TOML lock (
[[package]])CycloneDX JSON — e.g. eb-stack
--sbom-outoruv export --format cyclonedx1.5
rgpycrumbs does not generate these files. When a path is provided via
RGPYCRUMBS_LOCK / --lock (or the SBOM aliases), PyPI packages become
name==version constraints for uv run and ensure_import.
Non-Python / non-PyPI entries (e.g. eb-stack pkg:generic/...) are skipped.
Added in version 1.9.13.
Changed in version 1.9.14: Also accept PEP 751 pylock and uv.lock (not only CycloneDX).
Attributes¶
Classes¶
str(object='') -> str |
Functions¶
|
PEP 503-ish name normalization for pin lookups. |
|
Return the distribution name from a pip requirement string. |
|
|
|
Parse |
|
Guess lock format from filename and optional file text. |
|
Extract |
|
Extract pins from a PEP 751 pylock.toml document. |
|
Extract pins from a uv.lock TOML document ( |
|
Load and validate a CycloneDX JSON document from path. |
|
Load a TOML lock document (pylock or uv.lock). |
|
Load any supported lock/SBOM path and return a PyPI pin map. |
|
Render pin map as pip/uv constraint lines ( |
|
If pip_spec's package is in pins, return |
|
Read pin map from |
Module Contents¶
- class rgpycrumbs.locks.LockFormat[source]¶
-
str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to ‘utf-8’. errors defaults to ‘strict’.
- rgpycrumbs.locks.normalize_pypi_name(name: str) str[source]¶
PEP 503-ish name normalization for pin lookups.
- rgpycrumbs.locks.package_name_from_spec(pip_spec: str) str[source]¶
Return the distribution name from a pip requirement string.
- rgpycrumbs.locks._pin_from_purl(purl: str) tuple[str, str] | None[source]¶
Parse
pkg:pypi/name@version(optional qualifiers after?).
- rgpycrumbs.locks.detect_lock_format(path: str | pathlib.Path, text: str | None = None) LockFormat[source]¶
Guess lock format from filename and optional file text.
- rgpycrumbs.locks.pypi_pins_from_cyclonedx(doc: dict[str, Any]) dict[str, str][source]¶
Extract
{normalized_name: version}for PyPI components only.
- rgpycrumbs.locks.pypi_pins_from_pylock(doc: dict[str, Any]) dict[str, str][source]¶
Extract pins from a PEP 751 pylock.toml document.
Uses
[[packages]]entries withname+version. Packages without a version (rare) are skipped. Marker diversity is ignored for pin map purposes: last wins (constraints still force that version for installs).
- rgpycrumbs.locks.pypi_pins_from_uv_lock(doc: dict[str, Any]) dict[str, str][source]¶
Extract pins from a uv.lock TOML document (
[[package]]tables).
- rgpycrumbs.locks.load_cyclonedx(path: str | pathlib.Path) dict[str, Any][source]¶
Load and validate a CycloneDX JSON document from path.
- rgpycrumbs.locks.load_toml_lock(path: str | pathlib.Path) dict[str, Any][source]¶
Load a TOML lock document (pylock or uv.lock).
- rgpycrumbs.locks.load_pypi_pins(path: str | pathlib.Path) dict[str, str][source]¶
Load any supported lock/SBOM path and return a PyPI pin map.
- Raises:
FileNotFoundError: path missing ValueError: unreadable / unsupported / empty-of-python when required
- rgpycrumbs.locks.pins_to_constraint_lines(pins: dict[str, str]) list[str][source]¶
Render pin map as pip/uv constraint lines (
name==version).