rextendr icon indicating copy to clipboard operation
rextendr copied to clipboard

Embrace `{usethis}`

Open Ilia-Kosenkov opened this issue 2 years ago • 7 comments

Recent PR #292 shows that we heavily rely on {usethis} and only pretend we can work without it. At this point, I see no particular reason to not depend on {usethis} and drop all hacks that we have in place.

Pinging @CGMossa @multimeric @yutannihilation @eitsupi @JosiahParry

Ilia-Kosenkov avatar Jun 28 '23 09:06 Ilia-Kosenkov

When using functions to create packages, it makes sense to assume that usethis is installed (The rextendr::document function will not work without more massive devtools than usethis!).

However, since this package also has functions unrelated to package creation, it would make sense to keep usethis as an optional dependency.

eitsupi avatar Jun 28 '23 09:06 eitsupi

This topic has been raised again today. I think my personal preference on how to handle this would be to completely error out for functions that require the use of usethis rather than still succeeding but with work arounds that omit the use of usethis.

I think this can be accomplished with rlang::check_installed("usethis") which provides the user with an interactive prompt. If they choose to install the package the function continues and if not, the function errors out.

JosiahParry avatar Nov 17 '23 18:11 JosiahParry

Alright, I personally would go with @JosiahParry solution. If you're up for such a PR, or @kbvernon for that matter, I think that's a good way forward. These packages won't be maintained by us forever, and they need to be in slick shape for the future (mostly also for the god damn present).

CGMossa avatar Nov 17 '23 18:11 CGMossa

I can cast an eye over your R code to check for usethis calls and add rlang::check_installed("usethis") + if (!requireNamespace("usethis")) guards as Josiah suggests. The "workarounds" that come after the else might be a little much for me though, but I can try.

kbvernon avatar Nov 17 '23 18:11 kbvernon

I'm creating a package, which could be directly build with R CMD check. Several changes:

  1. Change lib type from ["staticlib"] to ["cdylib"], which will let cargo generate a .so/.dll file directly.
  2. Edit the Makevars, edit $(STATICLIB) target to STATLIB = $(LIBDIR)/librext.so (since I have no knowledge how to tell Makevars to build SHLIB directly.)
  3. For target $(STATICLIB), add a cp $(STATLIB) . instruction since there is no need link *.a to *.so anymore.
  4. Write useDynLib(libname,...) rather than useDynLib(name,...) in NAMESPACE.

I'm currently working with such things, wondering whether any of you need help.

Neutron3529 avatar Jun 08 '24 02:06 Neutron3529

@yutannihilation ,hi, I know you did a lot of research on the topic, any thoughts?

Ilia-Kosenkov avatar Jun 11 '24 07:06 Ilia-Kosenkov

@Neutron3529 Hallo! I think it is nice that you're experimenting with these. We've done a ton of these experiments, and happy to follow along with similar journeys. I would like this to be in its own issue rather than be jammed into this issue about {usethis}.

CGMossa avatar Jun 11 '24 07:06 CGMossa