[R-pkg-devel] Checking package dependencies before loading namespace

Tiago Olivoto t|@goo||voto @end|ng |rom gm@||@com
Mon Sep 6 12:43:03 CEST 2021


Thanks to all for the suggestions!
Best,
Tiago

Em sáb., 4 de set. de 2021 às 23:45, Martin Morgan <mtmorgan.bioc using gmail.com>
escreveu:

> Actually, I think the right thing to do is to tell the user what to do
> ("To use this feature, install EBImage following the directions at
> https://bioconductor.org/packages/EBImage') instead of doing it for them.
>
> Martin
>
> From: Tiago Olivoto <tiagoolivoto using gmail.com>
> Date: Friday, September 3, 2021 at 2:14 PM
> To: Martin Morgan <mtmorgan.bioc using gmail.com>
> Cc: Uwe Ligges <ligges using statistik.tu-dortmund.de>, R Package Devel <
> r-package-devel using r-project.org>
> Subject: Re: [R-pkg-devel] Checking package dependencies before loading
> namespace
> Thanks for your response Martin,
> I'm definitely thinking to use BiocManager::install("EBImage") since it is
> the official suggestion of the Bioconductor community. Anyway, I've been
> learning a lot from this discussion. Thanks all!!
> Best,
> Tiago
>
> Em sex., 3 de set. de 2021 às 12:58, Martin Morgan <mailto:
> mtmorgan.bioc using gmail.com> escreveu:
> The specific repository you've chosen is not what you want to do. This
> will always install EBImage from Bioconductor version 3.13, but
> Bioconductor version 3.13 is only relevant for R-4.1 (see
> https://bioconductor.org/about/release-announcements/)
>
> Personally, I would encourage you to follow the Bioconductor community
> best practice of BiocManager::install("EBImage"). In that way you will get
> the version of EBImage that has been tested with other Bioconductor
> packages in the same release, and on the version of R in use by your user.
>
> If you were to use a specific repository, it should the one that is as
> good as base R can do (this can be different from the version that
> BiocManager would choose because R's release cycle is different from
> Bioconductor's). I think this is most easily accomplished by
> utils::chooseBioCmirror(), and then selecting the 0-Bioconductor
> repository. That's a lot to tell your users... Maybe others in the R
> community have a better way (the key information is in
> tools:::.BioC_version_associated_with_R_version(), but that is not an
> exported function so not recommended for CRAN packages...)
>
> Martin Morgan
>
> On 9/1/21, 8:13 AM, "R-package-devel on behalf of Tiago Olivoto" <mailto:
> r-package-devel-bounces using r-project.org on behalf of mailto:
> tiagoolivoto using gmail.com> wrote:
>
>     Thank you, Duncan and Uwe for the suggestions.
>      I followed your instructions and created a function to check for
> EBImage
>     that is only called in an interactive section and, if necessary, ask
> the
>     user to install the package with install.packages("EBImage", repos="
>     https://bioconductor.org/packages/3.13/bioc")
>
>     Best,
>     Tiago
>
>     Em qua., 1 de set. de 2021 às 03:53, Uwe Ligges <
>     mailto:ligges using statistik.tu-dortmund.de> escreveu:
>
>     > Two more comments.
>     >
>     > 1. Note that your code only works in interactice mode, not when
> checking
>     > your package as it waits infinitely for the user's choice.
>     >
>     > 2. I do not see an advantage of installing BiocManager if EBImage is
>     > needed, the essential part is simply to select BioC as a repository
> to
>     > install packages from.
>     >
>     > Best,
>     > Uwe Ligges
>     >
>     >
>     > On 31.08.2021 23:33, Duncan Murdoch wrote:
>     > > People shouldn't be able to install your package unless the "hard"
>     > > dependencies are available.
>     > >
>     > > If EBImage isn't essential to your package, you should make it a
> "soft"
>     > > dependency by listing it in Suggests and checking for it every
> time you
>     > > use it.
>     > >
>     > > Duncan Murdoch
>     > >
>     > > On 31/08/2021 3:20 p.m., Tiago Olivoto wrote:
>     > >> Dear all,
>     > >> I have a package called pliman
>     > >> <https://CRAN.R-project.org/package=pliman>
>     > >> which depends on the Bioconductor package EBImage.
>     > >>
>     > >> When running install.packages("pliman") I get the following
> warning
>     > >>
>     > >> Warning in install.packages :  dependency ‘EBImage’ is not
> available
>     > >>
>     > >> and thus when loading the package with library(pliman), the
> following
>     > >> error
>     > >> occurs
>     > >>
>     > >> Erro: package or namespace load failed for ‘pliman’ in
> loadNamespace(i,
>     > >> c(lib.loc, .libPaths()), versionCheck = vI[[i]]):
>     > >>   there is no package called ‘EBImage’
>     > >>
>     > >> I created a check function to check if EBImage is available and if
>     > >> not, ask
>     > >> users if they want to install it
>     > >>
>     > >> ---
>     > >> check_ebi <- function(){
>     > >>    if(!requireNamespace("EBImage", quietly = TRUE)) {
>     > >>      inst <-
>     > >>      switch(menu(c("Yes", "No"), title = "Package {EBImage}
> required
>     > >> but not
>     > >> available.\nDo you want to install it now?"),
>     > >>             "yes", "no")
>     > >>      if(inst == "yes"){
>     > >>        if (!requireNamespace("BiocManager", quietly = TRUE)){
>     > >>          install.packages("BiocManager")
>     > >>        }
>     > >>        BiocManager::install("EBImage", ask = FALSE, update =
> FALSE)
>     > >>      } else{
>     > >>        message("To use {pliman}, first install {EBImage} with
>     > >> 'BiocManager::install(\"EBImage\")'.")
>     > >>      }
>     > >>    }
>     > >> }
>     > >> ---
>     > >>
>     > >> Is there any way to run this function prior to namespace loading?
> I
>     > tried
>     > >> putting check_ebi() into .onLoad() but the same error occurs.
>     > >>
>     > >> Thanks in advance for any suggestions.
>     > >> Tiago
>     > >>
>     > >>     [[alternative HTML version deleted]]
>     > >>
>     > >> ______________________________________________
>     > >> mailto:R-package-devel using r-project.org mailing list
>     > >> https://stat.ethz.ch/mailman/listinfo/r-package-devel
>     > >>
>     > >
>     > > ______________________________________________
>     > > mailto:R-package-devel using r-project.org mailing list
>     > > https://stat.ethz.ch/mailman/listinfo/r-package-devel
>     >
>
>         [[alternative HTML version deleted]]
>
>     ______________________________________________
>     mailto:R-package-devel using r-project.org mailing list
>     https://stat.ethz.ch/mailman/listinfo/r-package-devel
>

	[[alternative HTML version deleted]]



More information about the R-package-devel mailing list