How to call R Script from CRAN description file?

Hi,

I have a package which is dependent on some file. So, I have written a script to download the file and set the env's.

But how to call that file from the description file?

Thanks,
sai

Even I am facing same problem. I need to download some file if not present from HTTPS website and then continue with the Build or package installation process.

There exist different places where you can hook into the installation process: You could use configure(.win) or, if the package contains compiled code, Makevars(.win). The latter approach is used by many packages to download static libraries on Windows, e.g. https://github.com/jeroen/curl/blob/master/src/Makevars.win.

2 Likes

Hi,
Plz forgive if I sound ridiculous as I am new to R. But how to use this in my package? How will I add this to my package binary so that during installation the .win file is called? Hope I have made my self clear.

Thanks for the help !

The configure(.win) file is called during installation of a source package, which is the same process used to create a binary package from a source package, c.f. https://cran.r-project.org/doc/manuals/R-exts.html#Configure-and-cleanup. So with this approach the file will become part of the binary package.

Hi,
Thanks for your help with the configure file. Can you please suggest how to configure the "makevars.win" content to "makevars.in" to be used in linux as I am trying to work in LINUX environment.
The content of "makevars.win" is as follows:

PKG_CPPFLAGS=-I"$(R_HOME)/foobar/include" -I"$(FOO_HOME)/foobar/include" -I.
PKG_LIBS=-L"$(R_HOME)/foobar/bin" -L"$(FOO_HOME)/foobar/bin" -lfooexec

I am trying to include C library in my source package to be used during installation of my R package using makevars.

Thanks for your help.

I am missing a bit of context here. Is the C library packaged with your package or do you expect it to be installed in the system, e.g. in $FOO_HOME?

Hi Thanks for asking this.
In my case, C library can be present in system classpath i.e. already present in system like you can see in the makevar.win i.e. "(FOO_HOME)/foobar/include" and "(FOO_HOME)/foobar/bin". If not present in system, my package need to download the same from a URL("https://xyz.com/test.tar.gz") and then unzip the downloaded package and then use the same to compile the R package.

Please let me know if you have any other queries.

Thanks for help

You might consider the approach taken by nloptr, c.f. https://github.com/jyypma/nloptr. In the configure script, it for a usable version of the nlopt library in the system. If none is found, it downloads and compiles the library from source. In the end a Makevars file is created based on Makevars.in and the correct library location.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.