-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathexternal-info.R
More file actions
90 lines (78 loc) · 2.34 KB
/
Copy pathexternal-info.R
File metadata and controls
90 lines (78 loc) · 2.34 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#' Information about related software
#'
#' @details
#' Note that calling this function will attempt to load the tcltk and
#' grDevices packages.
#'
#' @return A list with elements:
#' * `cairo`: The cairo version string.
#' * `libpng`: The png version string.
#' * `jpeg`: The jpeg version string.
#' * `tiff`: The tiff library and version string used.
#' * `tcl`: The tcl version string.
#' * `curl`: The curl version string.
#' * `zlib`: The zlib version string.
#' * `bzlib`: The zlib version string.
#' * `xz`: The zlib version string.
#' * `PCRE`: The Perl Compatible Regular Expressions (PCRE) version string.
#' * `ICU`: The International Components for Unicode (ICU) version string.
#' * `TRE`: The TRE version string.
#' * `iconv`: The iconv version string.
#' * `readline`: The readline version string.
#' * `BLAS`: The path with the implementation of BLAS in use.
#' * `LAPACK`: The path with the implementation of LAPACK in use.
#'
#'
#' @seealso Similar functions and objects in the base packages:
#' [utils::sessionInfo()], [base::extSoftVersion], [tcltk::tclVersion()]
#' [base::La_library], [base::La_version()], [base::libcurlVersion()].
#'
#' @export
#' @examplesIf FALSE
#' external_info()
external_info <- function() {
ex <- c(
get_grsoft_version(),
tcl = get_tcl_version(),
curl = libcurlVersion(),
extSoftVersion()
)
ex["lapack"] <- get_la_library()
ex["lapack_version"] <- get_la_version()
names(ex) <- gsub("^lib", "", names(ex))
structure(as.list(ex), class = c("external_info", "list"))
}
get_tcl_version <- function() {
tryCatch(
suppressWarnings(tcltk::tclVersion()),
error = function(err) ""
)
}
get_grsoft_version <- function() {
grDevices::grSoftVersion()
}
get_la_library <- function() {
tryCatch(base::La_library(), error = function(err) NA_character_)
}
get_la_version <- function() {
tryCatch(base::La_version(), error = function(err) NA_character_)
}
#' @export
format.external_info <- function(x, ...) {
df <- data.frame(
setting = names(x),
value = unlist(x),
stringsAsFactors = FALSE
)
format_df(df)
}
#' @export
print.external_info <- function(x, ...) {
cat(format(x, ...), sep = "\n")
}
#' @export
as.character.external_info <- function(x, ...) {
old <- options(cli.num_colors = 1)
on.exit(options(old), add = TRUE)
format(x, ...)
}