~hrbrmstr/playdoh

ref: cda06176bb2626c26f9e20881df13246d1c51818 playdoh/R/zzz.R -rw-r--r-- 672 bytes
cda06176boB Rudis add RFC 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
py_c <- reticulate::py_config()

.dns <- NULL

.onLoad <- function(libname, pkgname) {

  if (utils::compareVersion(py_c$version, "3.5") < 0) {
    stop(
      paste0(
        c(
          "Python 3.5+ is required. If this is installed please set RETICULATE_PYTHON ",
          "to the path to the Python 3 binary on your system and try re-installing/",
          "re-loading the package."
        ),
        collapse = ""
      )
    )
    return()
  }

  if (!reticulate::py_module_available("dnslib")) {
    packageStartupMessage(
      "The 'dnslib' Python module must be installed."
    )
  } else {
    .dns <<- reticulate::import("dnslib", delay_load = TRUE)
  }

}