Skip to content

msmu.pv.to_env

Export recorded Python/package versions for uv or conda, without installing.

format="uv" returns requirements.txt text; format="conda" returns environment.yml text with CPython/pip from conda-forge and Python packages in its pip section. With filename, write UTF-8 text (overwriting an existing file) and return None, as to_script does.

Accepts MuData or get_log() output, independently of replay support or hashes. By default, all referenced environments must agree on Python, package pins, platform and msmu source. Otherwise select a recorded environment_id. Numerical/thread settings may differ and are included as comments only.

These are version pins, not lockfiles: original package sources, conda builds, native dependencies and uncommitted code cannot be reconstructed. Only recorded CPython environments are supported. The supplied history is unchanged.

Parameters:

Name Type Description Default
history MuData | dict

MuData or decoded history from get_log.

required
filename str | Path | None

Optional output file path; an existing file is overwritten.

None
format str

"uv" for requirements.txt text or "conda" for environment.yml text.

'uv'
environment_id str | None

Recorded environment ID to export. If omitted, all referenced environments must agree on the required version/source fields.

None

Returns:

Type Description
str | None

Environment specification string when no filename is supplied; otherwise None.

Notes

Use get_log to find environment IDs. This does not install packages or mutate history.

Examples:

import msmu as mm
requirements = mm.pv.to_env(mdata, format="uv")