
Parse a requirements.txt / pyproject.toml dependency block into per-package pins
Source:R/reproducibility_check_python.R
dot-repro_py_manifest_pins.RdA requirements.txt line is package, package==1.2.3, package>=1.2,
a VCS/URL install (git+https://...#egg=package, package @ https://...),
or a comment/blank line (skipped, along with -r other.txt/-e ./--...
option lines, which name no installable package at all); an inline comment
(numpy==1.26 # pinned) and per-requirement options (--hash=...) are
dropped. In a pyproject.toml only the dependency declarations are read:
the strings of [project]'s dependencies = [...] array, and the
name = "spec" / name = { version = "spec", ... } lines of
[tool.poetry.dependencies] (not python). Every other quoted string of
the file (name = "analysis", the version, the description) was read as a
requirement before, and a file whose strings did not all start like a
package name stopped the function (U236). Poetry's ^ and ~ versions are
written as pip ranges (^1.26 -> >=1.26,<2.0, ~1.11 -> >=1.11,<1.12),
a bare version as ==, and * as no version, since pip refuses Poetry's
own syntax.
Value
a data frame with package (lowercased, as PyPI names are
case-insensitive) and requirement (the requirement text, for
repro_install_deps_py()/repro_install_deps_py_docker() to pass to
pip install verbatim). Empty frame when manifest_text is NULL/empty.