Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test use_extendr() on CI #54

Closed
Ilia-Kosenkov opened this issue Mar 6, 2021 · 18 comments
Closed

Test use_extendr() on CI #54

Ilia-Kosenkov opened this issue Mar 6, 2021 · 18 comments

Comments

@Ilia-Kosenkov
Copy link
Member

In light of #53, I suggest adding a separate step that creates an empty package and adds extendr dependencies.
If we add a simple test (expect_equal(hello_world(), "Hello world!")), then R CMD check will reveal any potential problems with extendr setup.

@yutannihilation
Copy link
Contributor

Sounds good. I think we can use usethis::create_package() to create an empty package.

https://usethis.r-lib.org/reference/create_package.html

@Ilia-Kosenkov
Copy link
Member Author

@yutannihilation
Copy link
Contributor

Thanks, I have some questions.

I think we should do this outside of the repository.

d <- tempfile()
dir.create(d)
setwd(d)

Shouldn't this be done in use_extendr()?

usethis::use_build_ignore(".*\\.o$", escape = FALSE)

What's the intent of these two devtools::document()? I'm wondering if it should be like this instead:

devtools::install()
rextendr::register_extendr()
devtools::document()

@Ilia-Kosenkov
Copy link
Member Author

@yutannihilation,
I made a quick prototype. I am not sure about buildignore - devtools::document builds Rust source so package contains also build artifacts, like .o and .dll.

First devtools::document builds source and produces R code. Second call updates NAMESPACES and *rd docs.

If your solution is better, I have no objections.

@yutannihilation
Copy link
Contributor

I made a quick prototype. I am not sure about buildignore - devtools::document builds Rust source so package contains also build artifacts, like .o and .dll.

Ah, I see. Sorry, I was a bit confused.

First devtools::document builds source and produces R code.

I mean, if I understand correctly, it doesn't. You need to call rextendr::register_extendr() explicitly to produce R code, and it needs the package to be installed to let .Call() find the symbol wrap__make_<package>_wrappers.

@Ilia-Kosenkov
Copy link
Member Author

@yutannihilation,
Then I am lost as this script works fine in my local environment. We need to test both approaches.

@yutannihilation
Copy link
Contributor

Yes, it works, but I think it's because use_extendr() creates R/extendr-wrappers.R, not that the compiled rust code.

(Sorry, I didn't follow the discussions around the wrapper generation, so I might be wrong...)

@Ilia-Kosenkov
Copy link
Member Author

Ilia-Kosenkov commented Mar 6, 2021

@yutannihilation,
I also do not understand fully at what point wrapper generation happens.
However,

devtools::install()
rextendr::register_extendr()
devtools::document()

does not work for me -- last document() call complains about no function wrap__make_testpkg_wrappers.
Maybe I am doing something wrong. Double devtools::document works fine though.

@Ilia-Kosenkov
Copy link
Member Author

@yutannihilation
Copy link
Contributor

Double devtools::document works fine though.

What do you mean by "works" here? devtools::document() doesn't generate R/extendr-wrappers.R (e.g. if you tweak the roxygen strings on lib.rs, you'll notice it won't be reflected to R/extendr-wrappers.R). So, if we are testing "whether the default files created by rextendr::use_extendr() is correct," it's fine. But, if we want to test if the wrapper generation from Rust code is correct, devtools::document() is not enough.

But, sorry, the steps I proposed was incorrect... It seems we definitely need double devtools::document() AND installing and executing rextendr::register_extendr(). So, maybe the following?

# Generate NAMESPACE from the default wrapper created by use_extendr()
devtools::document()

# Install the package so that register_extendr() can find `wrap__make_testpkg_wrappers`.
devtools::install()

# Re-generate R/extendr-wrappers.R
rextendr::register_extendr()

# Re-generate documentation
devtools::document()

@Ilia-Kosenkov
Copy link
Member Author

@yutannihilation,
I will test your example later today.

@yutannihilation
Copy link
Contributor

Thanks (and sorry for taking your time), but I'm rethinking the mechanism to generate the wrapper R code, so could you wait for a while?

#56

@clauswilke
Copy link
Member

Just to confirm: With the current setup, this is the correct sequence if you want to test both use_extendr() and register_extendr():

rextendr::use_extendr()
devtools::document()
devtools::install()
rextendr::register_extendr()
devtools::document()

@yutannihilation
Copy link
Contributor

@Ilia-Kosenkov
Sorry for stopping you, now that #56 reached a conclusion, at least at the moment, that we should stick with the steps @clauswilke described here, we can start implementing the test.

@Ilia-Kosenkov
Copy link
Member Author

@yutannihilation,
No problems, I opened a PR, we can discuss test setup there.

@yutannihilation
Copy link
Contributor

Is this already solved by #61?

@Ilia-Kosenkov
Copy link
Member Author

I missed the latest comment here.
Yes, I believe it was solved in #61 and then improved afterward.

@yutannihilation
Copy link
Contributor

Thanks for confirming, let's close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants