Debian Codegraph @

R/pip.R

raw
1
2 pip_freeze <- function(..., python = NULL) {
3
4 python <- python %||% renv_python_active()
5 hook <- getOption("renv.hooks.pip_freeze")
6 if (is.function(hook))
7 return(hook(python = python))
8
9 renv_scope_envvars(PIP_DISABLE_PIP_VERSION_CHECK = "1")
10 python <- renv_path_canonicalize(python)
11 args <- c("-m", "pip", "freeze")
12 action <- "invoking pip freeze"
13 renv_system_exec(python, args, action, ...)
14
15 }
16
17 pip_install <- function(modules, ..., python = NULL) {
18
19 python <- python %||% renv_python_active()
20 hook <- getOption("renv.hooks.pip_install")
21 if (is.function(hook))
22 return(hook(modules = modules, python = python))
23
24 renv_scope_envvars(PIP_DISABLE_PIP_VERSION_CHECK = "1")
25 python <- renv_path_canonicalize(python)
26 args <- c("-m", "pip", "install", "--upgrade", modules)
27 action <- paste("installing", paste(dQuote(modules), collapse = ", "))
28 renv_system_exec(python, args, action, ...)
29
30 }
31
32 pip_install_requirements <- function(requirements, ..., python = NULL) {
33
34 python <- python %||% renv_python_active()
35 hook <- getOption("renv.hooks.pip_install_requirements")
36 if (is.function(hook))
37 return(hook(requirements = requirements, python = python))
38
39 file <- renv_scope_tempfile("renv-requirements-", fileext = ".txt")
40 writeLines(requirements, con = file)
41
42 renv_scope_envvars(PIP_DISABLE_PIP_VERSION_CHECK = "1")
43 python <- renv_path_canonicalize(python)
44 args <- c("-m", "pip", "install", "--upgrade", "-r", renv_shell_path(file))
45 action <- "restoring Python packages"
46 renv_system_exec(python, args, action, ...)
47
48 }
49
50 pip_uninstall <- function(modules, ..., python = NULL) {
51
52 python <- python %||% renv_python_active()
53 hook <- getOption("renv.hooks.pip_uninstall")
54 if (is.function(hook))
55 return(hook(modules = modules, python = python))
56
57 renv_scope_envvars(PIP_DISABLE_PIP_VERSION_CHECK = "1")
58 python <- renv_path_canonicalize(python)
59 args <- c("-m", "pip", "uninstall", "--yes", modules)
60 action <- paste("uninstalling", paste(dQuote(modules), collapse = ", "))
61 renv_system_exec(python, args, action, ...)
62
63 TRUE
64
65 }