-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[r] Check that TileDB Core library versions match (#2410)
* [r] Check that library versions match * Also enable .onAttach()
- Loading branch information
1 parent
65bc19f
commit 0a6ca6b
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
## .onLoad is called whether code from the package is used and the packages is 'loaded'. An | ||
## example is calling `tiledbsoma::show_package_versions()`. So this is most elementary check, | ||
## .onAttach is also called when the package is 'attached' via 'library(tiledbsoma)' | ||
## During package build and byte-code compilation and load check, both are called. | ||
.onLoad <- function(libname, pkgname) { | ||
rpkg_lib_version <- tiledb::tiledb_version(compact=TRUE) | ||
soma_lib_version <- libtiledbsoma_version(compact=TRUE) | ||
if (rpkg_lib_version != soma_lib_version) { | ||
msg <- sprintf("TileDB Core version %s used by TileDB-R package, but TileDB-SOMA uses %s", | ||
sQuote(rpkg_lib_version), sQuote(soma_lib_version)) | ||
stop(msg, call. = FALSE) | ||
} | ||
} | ||
|
||
## An .onAttach() function is not allowed to use cat() etc but _must_ communicate via | ||
## packageStartupMessage() as this function can be 'muzzled' as desired. See Writing R Extensions. | ||
.onAttach <- function(libname, pkgname) { | ||
if (interactive()) { | ||
packageStartupMessage("TileDB-SOMA R package ", packageVersion(pkgname), | ||
" with TileDB Embedded ", format(tiledb::tiledb_version(TRUE)), | ||
" on ", utils::osVersion, | ||
".\nSee https://github.com/single-cell-data for more information ", | ||
"about the SOMA project.") | ||
} | ||
} |