[Rd] example package for devel newcomers
asaguiar at spsconsultoria.com
Tue Aug 2 08:01:12 CEST 2011
Em Segunda 01 Agosto 2011, você escreveu:
> Is there a preferred language you would like to use in your package
> development? I randomly downloaded packages until I found some that
> helped me along my way, and might be able to help you pick one. If you
> are just looking at building a package of R functions and data you
> have developed, possibly the following example will get you started
> till you feel comfortable with the "Writing R Extensions"
> documentation (http://cran.r-project.org/doc/manuals/R-exts.pdf):
Dan, your message is cool. Well, here is what my project is about: it is a
package to embed php into R. Named Rphp for now. It is mostly done from
scratch. I have loved R-exts.pdf. Great stuff.
Why embed php into R? My primary purpose is to use web content management
systems (WCMS) ready and extensively tested code from R cgi scripts.
Someone more experienced with php might think of other uses. My approach
is RAD(ical) and innovative (IMextremelyHO :-D) because:
a) *any* php based WCMS can be used from R code with no php or html
b) output fully compliant with the website appearance;
c) WCMS automatic upgrades and interfaces changes (skins or themes) will
be so unlikey to cause need for maintenance in R cgi scripts;
d) R cgi scripts will not demand changes in php code;
e) the builtin php session support obviates the need for any special
session coding by R (likely non-web) programmers;
f) potential for improved analysis of web databases and even of systems
During my explorations of the R interface for extensions and the time
spent in this tiny project, some questions emerged.
1. my code uses no recursion but I do not really know what is inside php
code. Stack size could be a concern. Has any of you there ever needed to
allocate a new stack for a package? Is it better to wait for complaints
(if anyone ever would like to try this package...)?
2. can R_registerRoutines be called more than once within the same library
(the same DllInfo data) so that it can reconfigure itself on the fly?
3. Is it safe (I guess it is) to "re-export" a function pointer retrieved
4. when loading a second library (in this case libphp5.so) is it better to
put it in the package library directory and load it using the 'char
*path' member of DllInfo? Using a second library has implications:
a) a given R setup can be limited to the user space without root access;
b) in the case of desktops where someone might use Rphp, most systems do
not have libphp5.so installed by default and installing it frequently
means to install apache and all (many) related packages;
c) many sysadmins do not have root access but can compile their own php
d) building the libphp5.so may not be an easy task for many.
5. Similar to 3, is it safe to "export" functions of the second library?
libphp5.so will not be registered to R and has some interesting functions
that can be "exported" directly or as pointers within Rphp library. A
stub function can be used.
6. related to 4, with the many machine architectures and operating systems
around I think it is neither desirable nor feasible to distribute
precompiled libphp5.so versions; the package itself can download (wget
and curl are everywhere) and compile php. Compiling php is not a lengthy
task (6m12.9s in my quadcore desktop) but is a lot tricky and demands
several development packages not installed by default in desktop systems.
Their installations would require root access. What is the suggested
approach to deploy libphp5.so?
7. I do not know how to produce a version for windows if requested. I have
only an old MSC++ 97 and lcc (current) and have xp in a virtual box. This
concern includes php. Can I get help regarding windows in this list? It
might mean actual work: adapting code, compiling, packaging, etc. Not
sure what is needed.
8. system safety does not seem a concern regarding this use of php, but...
I guess some manual steps will be necessary because of potential security
breaches related to the use of a second library. Patching php to produce
a special build to be used as the package library would not be a trivial
task and would demand updates at every new php version. Something I can't
assure I can do. And would have to distribute the whole php source code:
still have to study php licensing scheme.
BTW, I copied Rdynpriv.h by hand to my include path to get access
to 'struct _DllInfo' definition. The R install process did not copy this
file. Am I doing something wrong here?
Sorry for the lengthy message. Thanx for your help.
Alexandre Santos Aguiar, MD, SCT
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 198 bytes
Desc: This is a digitally signed message part.
More information about the R-devel