r-lib/backports

Exports are determined at install time

Closed this issue · 8 comments

Which is not ideal if somebody has multiple R versions and leads to hard to debug problems.

If backports could export the functions at load time somehow, that would be great.

mllg commented
  1. Note that using packages build against a different R version is in general somewhat risky. This is not tested and discouraged by R core (according to Uwe Ligges). backports should probably warn about that.
  2. Using load-time exports was my first attempt for backports, but I encountered several problems silencing R CMD check. I'll check again if I can find a working solution (suggestions welcome!).
  3. If it helps, I can re-license the package under MIT or BSD.
  1. Note that using packages build against a different R version is in general somewhat risky. This is not tested and discouraged by R core (according to Uwe Ligges). backports should probably warn about that.

True in general, but for simple packages without compiled code and build-time dependencies, it is usually fine.

  1. Using load-time exports was my first attempt for backports, but I encountered several problems silencing R CMD check. I'll check again if I can find a working solution (suggestions welcome!).

@lionel- did this:
r-lib/devtools@b04266d#diff-434efa1e44ee83a15481ea98901eaaef

I don't know if it is directly usable for you.

  1. If it helps, I can re-license the package under MIT or BSD.

I don't mind the license as long as I use the package. I would mind it if I had to / wanted to copy code over from it. Btw. I am not sure if you can license it under non-GPL, if you already looked at the R code you are re-implementing.

I don't know about the CMD check issue, but you could keep the install time export just like it is and then provide an import() function that would take the relevant functions from your namespace and assign them in a supplied environment (converted with asNamespace() if a string).

The import() function would do the relevant version check for each requested backport. If no argument is supplied, it would conditionally import all backports.

mllg commented

There is now an import function here.
I decided to not rely on version numbers because R core is not very disciplined in adding new functionality only in major releases. Instead, the import function only assigns the backport in the package namespace iff R does not provide it.

Let me know if this works for you.

Cool, thanks!

mllg commented

Released on CRAN. Using import is now the recommended way to use backports.

@mllg Great, thanks!