-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* [r] Check that library versions match * Also enable .onAttach() Co-authored-by: Dirk Eddelbuettel <[email protected]>
- Loading branch information
1 parent
d1ee1a4
commit d425839
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.") | ||
} | ||
} |