Skip to content

[R-pkg-devel] Proper CRAN way - How to handle dependency of java jar file?

7 messages · Duncan Murdoch, Hong Ooi, Rainer M Krug

#
Hi

I have a package called `plantuml` (https://github.com/rkrug/plantuml) which converts plantuml code to UML graphs. It uses for this the java program https://plantuml.com which is Open Source. 

As it is not allowed to distribute a binary with an R package, I use the approach of a function which downloads the jar file into the directory `system.file("jar/plantuml.jar", package = "plantuml?)`. 

This works nicely, and at the moment, the function is called automatically before the plantuml.jar is used.

Now I would like to submit the package to CRAN. I can?t find the guidelines anymore, so I am asking here: 

What is the appropriate way of handling this?

I can think of a at least two ways of making it obvious to the user, that a binary is downloaded:

1) if the file plantuml.jar is not present, ask the user to run the function `updatePlantumlJar()` which downloads the jar to the original location in the package directory

2) tell the user to download the file manually and to put it somewhere, where the package will find it

I would prefer the first version, as the plantuml.jar would be in the package directory, where usually nobody but the package is doing stuff.

Any suggestions on how I could make this ?CRAN conform??

Thanks a lot,

Rainer

--
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany)

Orcid ID: 0000-0002-7490-0066

Department of Evolutionary Biology and Environmental Studies
University of Z?rich
Office Y34-J-74
Winterthurerstrasse 190
8075 Z?rich
Switzerland

Office:	+41 (0)44 635 47 64
Cell:       	+41 (0)78 630 66 57
email:      Rainer.Krug at uzh.ch
		Rainer at krugs.de
Skype:     RMkrug

PGP: 0x0F52F982





--
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany)

Orcid ID: 0000-0002-7490-0066

Department of Evolutionary Biology and Environmental Studies
University of Z?rich
Office Y34-J-74
Winterthurerstrasse 190
8075 Z?rich
Switzerland

Office:	+41 (0)44 635 47 64
Cell:       	+41 (0)78 630 66 57
email:      Rainer.Krug at uzh.ch
		Rainer at krugs.de
Skype:     RMkrug

PGP: 0x0F52F982
#
Your assumption that .jar files are not allowed is wrong:  a number of 
packages contain them:  rscala, J4R, Rbgs, bartMachine, OpenStreetMap, 
...  There's a specific mention about how to include them in the CRAN 
policy document:

"For Java .class and .jar files, the sources should be in a top-level 
java directory in the source package (or that directory should explain 
how they can be obtained)."

If you still decide not to include your .jar file (maybe it is too big, 
for example), then I think your option 1 is unusable for those people 
who can't write to the library location because of permission problems. 
(Admin privileges are often necessary to install packages in the main 
library.)  Generally I think everyone can install packages somewhere, 
but users do really get confused when they have multiple library 
locations, possibly each containing a different version of a package.

Duncan Murdoch
On 23/06/2020 8:18 a.m., Rainer M Krug wrote:
#
Thanks Duncan.
That?s good to know.
So a tet file in the inst/jar directory giving the link to the GitHub repo would be fine in this case?
I guess it would be stretching it a bit, as the jar file is 8.2 MB, and plantuml has regular continuous updates, so I would prefer to keep it dynamic.
So the suggested option would be to have a function, which 
1) ask the user to create a directory in the home folder 
2) download the jar file into that directory or, when no permission is granted, into the tmpdir()

Thanks, no major changes necessary for that,

Rainer
--
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany)

Orcid ID: 0000-0002-7490-0066

Department of Evolutionary Biology and Environmental Studies
University of Z?rich
Office Y34-J-74
Winterthurerstrasse 190
8075 Z?rich
Switzerland

Office:	+41 (0)44 635 47 64
Cell:       	+41 (0)78 630 66 57
email:      Rainer.Krug at uzh.ch
		Rainer at krugs.de
Skype:     RMkrug

PGP: 0x0F52F982
#
Another possibility, if you want the jar to be dynamic and also have a standard location for it, is to write it to the R config/user dir. This is available via R_user_dir() in R 4.0 (and earlier versions via the backports package). An older alternative that still works is to use the rappdirs package.


-----Original Message-----
From: R-package-devel <r-package-devel-bounces at r-project.org> On Behalf Of Rainer M Krug
Sent: Tuesday, 23 June 2020 10:48 PM
To: Duncan Murdoch <murdoch.duncan at gmail.com>
Cc: R Package Devel <r-package-devel at r-project.org>
Subject: [EXTERNAL] Re: [R-pkg-devel] Proper CRAN way - How to handle dependency of java jar file?

Thanks Duncan.
That?s good to know.
So a tet file in the inst/jar directory giving the link to the GitHub repo would be fine in this case?
I guess it would be stretching it a bit, as the jar file is 8.2 MB, and plantuml has regular continuous updates, so I would prefer to keep it dynamic.
So the suggested option would be to have a function, which 
1) ask the user to create a directory in the home folder 
2) download the jar file into that directory or, when no permission is granted, into the tmpdir()

Thanks, no major changes necessary for that,

Rainer
--
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany)

Orcid ID: 0000-0002-7490-0066

Department of Evolutionary Biology and Environmental Studies
University of Z?rich
Office Y34-J-74
Winterthurerstrasse 190
8075 Z?rich
Switzerland

Office:	+41 (0)44 635 47 64
Cell:       	+41 (0)78 630 66 57
email:      Rainer.Krug at uzh.ch
		Rainer at krugs.de
Skype:     RMkrug

PGP: 0x0F52F982





______________________________________________
R-package-devel at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel
#
Thanks Hong - I like that.

I found that package in the tools::R_user_dir() package - us that the one?

Rainer
--
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany)

Orcid ID: 0000-0002-7490-0066

Department of Evolutionary Biology and Environmental Studies
University of Z?rich
Office Y34-J-74
Winterthurerstrasse 190
8075 Z?rich
Switzerland

Office:	+41 (0)44 635 47 64
Cell:       	+41 (0)78 630 66 57
email:      Rainer.Krug at uzh.ch
		Rainer at krugs.de
Skype:     RMkrug

PGP: 0x0F52F982
#
Yes, that?s the one.

From: Rainer M Krug <Rainer at krugs.de>
Sent: Tuesday, 23 June 2020 11:12 PM
To: Hong Ooi <hongooi at microsoft.com>
Cc: R Package Devel <r-package-devel at r-project.org>
Subject: Re: [EXTERNAL] [R-pkg-devel] Proper CRAN way - How to handle dependency of java jar file?

Thanks Hong - I like that.

I found that package in the tools::R_user_dir() package - us that the one?

Rainer
On 23 Jun 2020, at 15:07, Hong Ooi <hongooi at microsoft.com<mailto:hongooi at microsoft.com>> wrote:
Another possibility, if you want the jar to be dynamic and also have a standard location for it, is to write it to the R config/user dir. This is available via R_user_dir() in R 4.0 (and earlier versions via the backports package). An older alternative that still works is to use the rappdirs package.


-----Original Message-----
From: R-package-devel <r-package-devel-bounces at r-project.org<mailto:r-package-devel-bounces at r-project.org>> On Behalf Of Rainer M Krug
Sent: Tuesday, 23 June 2020 10:48 PM
To: Duncan Murdoch <murdoch.duncan at gmail.com<mailto:murdoch.duncan at gmail.com>>
Cc: R Package Devel <r-package-devel at r-project.org<mailto:r-package-devel at r-project.org>>
Subject: [EXTERNAL] Re: [R-pkg-devel] Proper CRAN way - How to handle dependency of java jar file?

Thanks Duncan.
On 23 Jun 2020, at 14:35, Duncan Murdoch <murdoch.duncan at gmail.com<mailto:murdoch.duncan at gmail.com>> wrote:
Your assumption that .jar files are not allowed is wrong:  a number of packages contain them:  rscala, J4R, Rbgs, bartMachine, OpenStreetMap, ...  There's a specific mention about how to include them in the CRAN policy document:

That?s good to know.



"For Java .class and .jar files, the sources should be in a top-level java directory in the source package (or that directory should explain how they can be obtained)."

So a tet file in the inst/jar directory giving the link to the GitHub repo would be fine in this case?



If you still decide not to include your .jar file (maybe it is too big, for example),


I guess it would be stretching it a bit, as the jar file is 8.2 MB, and plantuml has regular continuous updates, so I would prefer to keep it dynamic.



then I think your option 1 is unusable for those people who can't write to the library location because of permission problems. (Admin privileges are often necessary to install packages in the main library.)  Generally I think everyone can install packages somewhere, but users do really get confused when they have multiple library locations, possibly each containing a different version of a package.

So the suggested option would be to have a function, which
1) ask the user to create a directory in the home folder
2) download the jar file into that directory or, when no permission is granted, into the tmpdir()

Thanks, no major changes necessary for that,

Rainer




Duncan Murdoch
On 23/06/2020 8:18 a.m., Rainer M Krug wrote:
Hi
I have a package called `plantuml` (https://github.com/rkrug/plantuml<https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Frkrug%2Fplantuml&data=02%7C01%7Chongooi%40microsoft.com%7C590b1587b3394bb6a8fd08d817770dc9%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637285147406339418&sdata=tDq%2Fnri4fwPoPvupKmloF47d5QH1Vb3J0lb5L17%2Fu%2FY%3D&reserved=0>) which converts plantuml code to UML graphs. It uses for this the java program https://plantuml.com<https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fplantuml.com%2F&data=02%7C01%7Chongooi%40microsoft.com%7C590b1587b3394bb6a8fd08d817770dc9%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637285147406339418&sdata=5vv%2B%2BXZCPuoblNQUH9%2Fyaz8Fg39aV8XlNIMh1RawoU0%3D&reserved=0> which is Open Source.
As it is not allowed to distribute a binary with an R package, I use the approach of a function which downloads the jar file into the directory `system.file("jar/plantuml.jar", package = "plantuml?)`.
This works nicely, and at the moment, the function is called automatically before the plantuml.jar is used.
Now I would like to submit the package to CRAN. I can?t find the guidelines anymore, so I am asking here:
What is the appropriate way of handling this?
I can think of a at least two ways of making it obvious to the user, that a binary is downloaded:
1) if the file plantuml.jar is not present, ask the user to run the function `updatePlantumlJar()` which downloads the jar to the original location in the package directory
2) tell the user to download the file manually and to put it somewhere, where the package will find it
I would prefer the first version, as the plantuml.jar would be in the package directory, where usually nobody but the package is doing stuff.
Any suggestions on how I could make this ?CRAN conform??
Thanks a lot,
Rainer
--
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany)
Orcid ID: 0000-0002-7490-0066
Department of Evolutionary Biology and Environmental Studies
University of Z?rich
Office Y34-J-74
Winterthurerstrasse 190
8075 Z?rich
Switzerland
Office:   +41 (0)44 635 47 64
Cell:          +41 (0)78 630 66 57
email:      Rainer.Krug at uzh.ch<mailto:Rainer.Krug at uzh.ch>
   Rainer at krugs.de<mailto:Rainer at krugs.de>
Skype:     RMkrug
PGP: 0x0F52F982
--
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany)
Orcid ID: 0000-0002-7490-0066
Department of Evolutionary Biology and Environmental Studies
University of Z?rich
Office Y34-J-74
Winterthurerstrasse 190
8075 Z?rich
Switzerland
Office:   +41 (0)44 635 47 64
Cell:          +41 (0)78 630 66 57
email:      Rainer.Krug at uzh.ch<mailto:Rainer.Krug at uzh.ch>
   Rainer at krugs.de<mailto:Rainer at krugs.de>
Skype:     RMkrug
PGP: 0x0F52F982
______________________________________________
R-package-devel at r-project.org<mailto:R-package-devel at r-project.org> mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


--
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany)

Orcid ID: 0000-0002-7490-0066

Department of Evolutionary Biology and Environmental Studies
University of Z?rich
Office Y34-J-74
Winterthurerstrasse 190
8075 Z?rich
Switzerland

Office:   +41 (0)44 635 47 64
Cell:                    +41 (0)78 630 66 57
email:      Rainer.Krug at uzh.ch<mailto:Rainer.Krug at uzh.ch>
                           Rainer at krugs.de<mailto:Rainer at krugs.de>
Skype:     RMkrug

PGP: 0x0F52F982





______________________________________________
R-package-devel at r-project.org<mailto:R-package-devel at r-project.org> mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel

--
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany)
Orcid ID: 0000-0002-7490-0066

Department of Evolutionary Biology and Environmental Studies
University of Z?rich
Office Y34-J-74
Winterthurerstrasse 190
8075 Z?rich
Switzerland

Office:   +41 (0)44 635 47 64
Cell:                    +41 (0)78 630 66 57
email:      Rainer.Krug at uzh.ch<mailto:Rainer.Krug at uzh.ch>
                           Rainer at krugs.de<mailto:Rainer at krugs.de>
Skype:     RMkrug

PGP: 0x0F52F982
#
Perfect. You also mention the ?backports?  package - how can I use that one to be able to also support old versions of R?

Thanks,

Rainer
--
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany)

Orcid ID: 0000-0002-7490-0066

Department of Evolutionary Biology and Environmental Studies
University of Z?rich
Office Y34-J-74
Winterthurerstrasse 190
8075 Z?rich
Switzerland

Office:	+41 (0)44 635 47 64
Cell:       	+41 (0)78 630 66 57
email:      Rainer.Krug at uzh.ch
		Rainer at krugs.de
Skype:     RMkrug

PGP: 0x0F52F982