extendr / rextendr

An R package that helps scaffolding extendr-enabled packages or compiling Rust code dynamically
https://extendr.github.io/rextendr/
Other
190 stars 28 forks source link

extendr project template #321

Closed kbvernon closed 8 months ago

kbvernon commented 10 months ago

Trying to add required content to support RStudio project templates. Currently getting the following error:

Error: No root directory found in G:/My Drive or its parent directories. Root criterion: contains a file "DESCRIPTION" with contents matching "^Package: "
Ilia-Kosenkov commented 10 months ago

Found an issue, and I will fix it in a separate PR.

kbvernon commented 10 months ago

I believe I have this working, but I'm not sure what the M.O. is for doing tests.

kbvernon commented 10 months ago

@Ilia-Kosenkov, do you have a recommendation for how to handle missing usethis before use_extendr() gets called? should it just error?

kbvernon commented 10 months ago

use_extendr() uses rlang::check_installed("usethis"). However, that opens an interactive context I don't think is available for project directory creation through the RStudio GUI. Maybe I should use a combination of rlang::is_installed("usethis") and cli::abort() instead?

Ilia-Kosenkov commented 10 months ago

You can also use this in your function, call it before you access anything {usethis} - related. https://github.com/extendr/rextendr/blob/09bfebae90e679cbb3a21e9ce983c032c82e1828/R/use_extendr.R#L38

kbvernon commented 10 months ago

Per our Discord discussion, I added commits so that create_extendr_package() no longer adds a temporary INDEX file to the project folder. This made the single {testthat} test irrelevant, so I also reverted that commit.

kbvernon commented 10 months ago

Because we remove the INDEX file, it was suggested that we add its content to the package documentation, probably "Using Rust code in packages". Would be happy to do this, but should it be done in another PR?

Ilia-Kosenkov commented 10 months ago

You should do it in this PR, and also update NEWS.md

JosiahParry commented 8 months ago

Package is created and opened interactively with RStudio. The infrastructure works as well. This should not be exported until the arguments are changed and handled differently.

This is because you're capturing all arguments via ... and expecting there to be a valid value passed in. This is true when using the wizard. But it is not true when doing interactively. The highlighted lines are where the problem comes from.

https://github.com/extendr/rextendr/blob/cbdb5b6f70b0db27f3ec97123883231f8af308f5/R/create_extendr_package.R#L34-L52

image
JosiahParry commented 8 months ago

Since this is not an exported function I am comfortable merging.

Ilia-Kosenkov commented 8 months ago

If you approved it and the author has no permissions to merge to this repo, it is your duty to merge once all the changes are in place (in case there are any not yet pushed) @JosiahParry