| 1 |
isRshared <- function(platform = .Platform) { |
| 2 |
platform$ OS.type == "windows" || { |
| 3 |
## works on Linux; what about others, notably Mac ? |
| 4 |
ldd.s <- try(Rcmd(paste("ldd", R.home("bin/exec/R"), "| head -5"), |
| 5 |
stdout=TRUE)) |
| 6 |
## If in doubt (error etc), assume |
| 7 |
## R executable to be linked to libR.{so,dylib} , i.e., "shared" : |
| 8 |
inherits(ldd.s, "try-error") || is.null(ldd.s) || anyNA(ldd.s) || |
| 9 |
any(grepl(paste0("^.?libR", platform$dynlib.ext), ldd.s)) |
| 10 |
} |
| 11 |
} |
| 12 |
|
| 13 |
## MM: cf. ~/R/Pkgs/robustbase/inst/xtraR/more |
| 14 |
sessionInfoX <- function(pkgs=NULL, list.libP = FALSE, extraR.env = TRUE) { |
| 15 |
## return an object; then print() via method |
| 16 |
lP <- .libPaths() # *is* normalized in the sense of normalizePath() |
| 17 |
nRL <- normalizePath(RLIBS <- strsplit(Sys.getenv("R_LIBS"), ":")[[1]]) |
| 18 |
si <- sessionInfo() |
| 19 |
## typically the "same" [ setequal(.,.) ] as loadedNamespaces() : |
| 20 |
sessionPkgs <- c(si[["basePkgs"]], |
| 21 |
unlist(lapply(si[c("otherPkgs", "loadedOnly")], names), use.names=FALSE)) |
| 22 |
if(isTRUE(pkgs)) |
| 23 |
pkgs <- sessionPkgs |
| 24 |
else if(!is.null(pkgs)) stopifnot(is.character(pkgs), length(pkgs) > 0) |
| 25 |
Rver <- package_version(si$R.version) |
| 26 |
struct(class = "sessionInfoX", |
| 27 |
list(sInfo = si, |
| 28 |
sysInf = Sys.info(), |
| 29 |
capabilities = capabilities(), |
| 30 |
Machine = .Machine, |
| 31 |
compiledBy= if(Rver >= "4.3.0") R_compiled_by(), |
| 32 |
extSoft = if(Rver >= "3.2.0") extSoftVersion(), |
| 33 |
grSoft = if(Rver >= "3.2.0") grSoftVersion(), |
| 34 |
tclVersion=if(Rver >= "3.2.0" && "tcltk" %in% sessionPkgs) tcltk::tclVersion(), |
| 35 |
LAPACK = if(Rver >= "3.0.3") La_version(), |
| 36 |
pcre = if(Rver >= "3.1.3") pcre_config(), |
| 37 |
isRshared = isRshared(), |
| 38 |
pkgDescr = if(!is.null(pkgs)) sapply(pkgs, packageDescription, simplify=FALSE), |
| 39 |
libPath = lP, .Library = .Library, RLIBS = RLIBS, n.RLIBS = nRL, |
| 40 |
list.libP = if(list.libP) sapply(lP, list.files, simplify=FALSE), |
| 41 |
R.env = Sys.getenv(c("R_ENVIRON", "R_PROFILE", "R_CHECK_ENVIRON")), |
| 42 |
xR.env = if(extraR.env) local({ |
| 43 |
ss <- Sys.getenv() |
| 44 |
ss[grepl("^_?R_", names(ss))] |
| 45 |
}))) |
| 46 |
} |
| 47 |
|
| 48 |
print.sessionInfoX <- function(x, locale = TRUE, RLIBS = TRUE, Renv = TRUE, ...) { |
| 49 |
cat("Extended sessionInfo():", |
| 50 |
"-----------------------", sep="\n")# does add a final '\n' |
| 51 |
if(!is.null(pkgD <- x$pkgDescr)) { |
| 52 |
cat("specific packageDescription()s:\n") |
| 53 |
print(pkgD, ...) |
| 54 |
cat("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n") |
| 55 |
} |
| 56 |
cat("Capabilities:\n") |
| 57 |
print(symnum(x$capabilities, symbols = c("-", "X")), ...) |
| 58 |
cat("Sys.info:\n") |
| 59 |
print(struct(x$sysInf[c("nodename", "user")], class="Dlist"), ...) |
| 60 |
cat(".Machine: "); str(x$Machine) |
| 61 |
cat("\n") |
| 62 |
if(!is.null(cby <- x$compiledBy)) { |
| 63 |
cat("R was compiled by:\n"); print(struct(cby, class="Dlist"), ...) } |
| 64 |
if(!is.null(x$LAPACK)) cat("LAPACK version:", x$LAPACK, "\n") |
| 65 |
if(!is.null(x$extSoft)) { |
| 66 |
cat("External software (versions):\n") |
| 67 |
print(struct(x$extSoft, class="Dlist"), ...) |
| 68 |
} |
| 69 |
if(!is.null(x$grSoft)) { |
| 70 |
cat("Graphical software (versions):\n") |
| 71 |
print(struct(x$grSoft, class="Dlist"), ...) |
| 72 |
} |
| 73 |
if(!is.null(x$tclVersion)) |
| 74 |
cat("Tcl version:", x$tclVersion, "\n") |
| 75 |
if(!is.null(x$pcre)) |
| 76 |
cat("\nPCRE (regex) config.:", |
| 77 |
sub("^c", "", deparse(x$pcre, width.cutoff=99)), "\n") |
| 78 |
cat("R executable linked against libR.* ['is R shared']:", x$isRshared, "\n") |
| 79 |
cat("\n") |
| 80 |
if(RLIBS) { |
| 81 |
cat("R_LIBS:\n") |
| 82 |
cbind(x$RLIBS) |
| 83 |
xtr.lp <- setdiff(x$libPath, |
| 84 |
union(normalizePath(x$.Library), x$n.RLIBS)) |
| 85 |
if(length(xtr.lp)) { |
| 86 |
cat("libPath [.libPaths()] contents in addition to R_LIBS and .Library:\n") |
| 87 |
print(xtr.lp) |
| 88 |
} else |
| 89 |
cat("libPath contains not more than RLIBS and .Library (normalized)\n") |
| 90 |
if(length(xx <- setdiff(x$n.RLIBS, x$libPath))) { ## typically empty |
| 91 |
cat("** RLIBS has entries not in .libPaths():\n") |
| 92 |
print(xx) |
| 93 |
} |
| 94 |
} |
| 95 |
if(Renv) { |
| 96 |
cat("Main R env. variables", |
| 97 |
if(!is.null(x$xR.env)) " (for more, inspect the 'xR.env' component)", |
| 98 |
":\n", sep="") |
| 99 |
print(cbind(x$R.env), ...) |
| 100 |
} |
| 101 |
cat("---------------- standard sessionInfo():\n") |
| 102 |
print(x$sInf, locale=locale, ...) |
| 103 |
invisible(x) |
| 104 |
} |
| 105 |
|
| 106 |
## "FIXME"/"TODO": |
| 107 |
## used in mtextVersion() in ~/R/Pkgs/DPQ/inst/extraR/relErr-plots.R |
| 108 |
## which mentions myRversion {long.double, non-{'x86_64'}} |
| 109 |
shortRversion <- function(Rv = R.version, |
| 110 |
Rst = Rv$status, |
| 111 |
Rvstring = if(!is.null(s <- Rv$version.string)) |
| 112 |
## in R 0.90.1 had no $version.string |
| 113 |
s else R.version.string, |
| 114 |
date = Rst != "", |
| 115 |
spaces = TRUE) |
| 116 |
{ |
| 117 |
## for non-empty Rst (typically R.version$status), i.e., R-devel, ..: |
| 118 |
pat <- paste0("\\(", if(date) "([^)]+)" else "[0-9]{4}-[0-9]{2}-[0-9]{2} *(.+)", |
| 119 |
"\\)$") |
| 120 |
r <- |
| 121 |
if(Rst == "Under development (unstable)") |
| 122 |
## "R Under development (unstable) (2017-10-16 r73554)" |
| 123 |
paste("R devel", sub(paste0(".*",pat), "\\1", Rvstring)) |
| 124 |
else if(tolower(Rst) %in% c("patched", "alpha", "beta", "rc")) |
| 125 |
## "R version 3.4.2 Patched (2017-10-12 r73556)" |
| 126 |
sub(pat, "\\1", sub(" version", "", Rvstring)) |
| 127 |
else if(Rst == "") # "R version 3.2.5 (2016-04-14)" (regular release) |
| 128 |
gsub(if(date) "[()]" else " \\(.*", "", sub(" version", "", Rvstring)) |
| 129 |
else |
| 130 |
stop("invalid R.version $ status: ", sQuote(Rst)) |
| 131 |
|
| 132 |
if(spaces) r else gsub(" ", "_", sub("^R ", "R-", r)) |
| 133 |
} |