
Install Python dependencies inside a throwaway Docker container
Source:R/reproducibility_check_python_docker.R
repro_install_deps_py_docker.RdThe Docker-backed twin of repro_install_deps_py(): same return contract,
same throwaway-library semantics, but the actual pip install runs INSIDE
a container (default networking, since PyPI must be reachable), writing
into lib_dir via a bind mount — so the run phase
(repro_run_scripts_py_docker()), which mounts the same lib_dir with the
network off, finds the packages already there.
Usage
repro_install_deps_py_docker(
install_deps,
lib_dir,
image = getOption("metacheck.docker_image_py", .repro_docker_default_image_py),
timeout = 600
)Arguments
- install_deps
a data frame as produced inside
reproducibility_check()(package,source,ref,base) — the non-base rows ofrepro_dependencies_py()'s output- lib_dir
throwaway
pip install --targetdirectory ON THE HOST (created if absent); bind-mounted into the container at/pylib- image
the Docker image to install into (see .repro_docker_default_image_py)
- timeout
timeout in seconds for the whole install container run (default 600)
Value
a data frame with package, source, installed (logical),
message (pip's stderr on failure, else ""), via_archive (always
FALSE — pip has no CRAN-Archive-style fallback), and category (always
NA) — same columns as repro_install_deps_py() so callers do not need
to branch on which backend ran.
Examples
if (FALSE) { # \dontrun{
# needs Docker
deps <- repro_dependencies_py("import numpy as np")
repro_install_deps_py_docker(deps, file.path(tempdir(), "pylib"))
} # }