From j@goreck| @end|ng |rom w|t@edu@p|  Thu Jan 31 16:56:48 2019
From: j@goreck| @end|ng |rom w|t@edu@p| (Jan Gorecki)
Date: Thu, 31 Jan 2019 21:26:48 +0530
Subject: [Rd] Runnable R packages
In-Reply-To: <CANVKczOZcSz0YLuKiWfdU0x3qMP0GvUAdqDgp32rmrPfHmK1tA@mail.gmail.com>
References: <CAKtMxAFYFafUHOitKEUbRSPxXVgHd+sWe_937YHNHJOyNEm_3g@mail.gmail.com>
 <CAKtMxAHmoT=L211CJbyB034bY0ddyY8jg_QqB+LgWZCm_XgL3Q@mail.gmail.com>
 <CAPvvxJX_EFOE26vU4zBH_T2LuP7tRgV_CJx4LsvP6eN8PLZNLQ@mail.gmail.com>
 <CALEXWq2mJ=r7t4Z2akQGe1vDhu9RdHikYCGqdZy_xS1nx=YMnw@mail.gmail.com>
 <72b511b92df64f69ab43f2ce5c654584@LNXP265MB1705.GBRP265.PROD.OUTLOOK.COM>
 <CANVKczOZcSz0YLuKiWfdU0x3qMP0GvUAdqDgp32rmrPfHmK1tA@mail.gmail.com>
Message-ID: <CAOO9MKWMPw8gT_G=UGx0T6Arm7q_1KiFgF7nXt7N0zmyiNoPYQ@mail.gmail.com>

Quoting:

"In summary, I'm convinced R would benefit from something similar to Java's
`Main-Class` header or Python's `__main__()` function. A new R CMD command
would take a package, install its dependencies, and run its "main"
function."

This kind of increase the scope of your idea. New command in R CMD to
redirect to "main" is interesting idea. On the other hand it will
impose limitation on user comparing to the way how you could do it
now: Rscript -e 'mypkg::mymain("myparam")' (or littler, it should be
shipped with R IMO).
For production system one doesn't want to just "install its
dependencies". First dependencies has to be mirrored and their version
frozen. Then testing your package on that set of dependencies. Once
successfully done then same set of packages should be used for
production deployment. For those processes you might find tools4pkgs
branch in base R useful (packages.dcf, mirror.packages functions),
unfortunately not merged:
https://github.com/wch/r-source/compare/tools4pkgs

Jan Gorecki

On Thu, Jan 31, 2019 at 9:08 PM Barry Rowlingson
<b.rowlingson at lancaster.ac.uk> wrote:
>
> On Thu, Jan 31, 2019 at 3:14 PM David Lindelof <lindelof at ieee.org> wrote:
>
> >
> > In summary, I'm convinced R would benefit from something similar to Java's
> > `Main-Class` header or Python's `__main__()` function. A new R CMD command
> > would take a package, install its dependencies, and run its "main"
> > function.
>
>
>
> I just created and built a very boilerplate R package called "runme". I can
> install its dependencies and run its "main" function with:
>
>  $ R CMD INSTALL runme_0.0.0.9000.tar.gz
>  $ R -e 'runme::main()'
>
> No new R CMDs needed. Now my choice of "main" is arbitrary, whereas with
> python and java and C the entrypoint is more tightly specified (__name__ ==
> "__main__" in python, int main(..) in C and so on). But I don't think
> that's much of a problem.
>
> Does that not satisfy your requirements close enough? If you want it in one
> line then:
>
> R CMD INSTALL runme_0.0.0.9000.tar.gz && R -e 'runme::main()'
>
> will do the second if the first succeeds (Unix shells).
>
> You could write a script for $RHOME/bin/RUN which would be a two-liner and
> that could mandate the use of "main" as an entry point. But good luck
> getting anything into base R.
>
> Barry
>
>
>
>
> > If we have this machinery available, we could even consider
> > reaching out to Spark (and other tech stacks) developers and make it easier
> > to develop R applications for those platforms.
> >
> >
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



[Rd] Runnable R packages
Jan Gorecki