r-lib / pkgbuild

Find tools needed to build R packages
https://pkgbuild.r-lib.org
Other
65 stars 33 forks source link

R package using compiled Pascal code #192

Closed JosephBARBIERDARNAL closed 1 month ago

JosephBARBIERDARNAL commented 1 month ago

Note: I'm not sure if I'm on the right repo for this question, so feel free to tell me I'm not.

Hi, I'm building an R package that uses Pascal executable files. I'm wondering if there are any problems associated with this as I haven't found any real resources on this type of project, as most R packages use C++. Are there any rules to be followed on how to architect the project, call my executables, etc? At the time of writing, I'm just calling executables from src/, depending on the user's operating system.

I have 2 compiled files (one for Windows and one for Unix) that work fine (the output of the program is to write a file, which I then analyse with R).

I have the impression that what I'm doing is very ‘manual’ and perhaps not very intelligent. I'm not looking for exact explanations but rather advice on the direction to take and the resources to look for.

Thanks.

Note 2: I also asked the same question on the POSIT forum, which is perhaps a more appropriate place to ask it.

gaborcsardi commented 1 month ago

Yes, this is not exactly the right repository. I guess the right place might be the R-package-help or the R-help mailing list.

Nevertheless I could not find any packages with code on CRAN or Bioconductor: https://github.com/search?q=org%3Acran+language%3APascal+&type=code https://github.com/search?q=org%3Abioc+language%3APascal+&type=code

According to https://cran.r-project.org/doc/manuals/R-exts.html#Package-subdirectories-1 you should put executables into bin:

On the other hand, executable programs could be installed along the lines of

execs <- c("one", "two", "three")
if(WINDOWS) execs <- paste0(execs, ".exe")
if ( any(file.exists(execs)) ) {
  dest <- file.path(R_PACKAGE_DIR,  paste0('bin', R_ARCH))
  dir.create(dest, recursive = TRUE, showWarnings = FALSE)
  file.copy(execs, dest, overwrite = TRUE)
}

OTOH I suspect that Pascal code is not supported on CRAN, so you are probably not going to put your package on CRAN, which gives you a lot of flexibility here.

JosephBARBIERDARNAL commented 1 month ago

OK, that's very helpful.

There are no plans for this project to be on CRAN yet, so that's fine with me.

Thank you for your quick response. I think we can close this issue.