[R-pkg-devel] Appropriate usage of 'Suggests' -- package installed conditional on other software not found

2019-10-03 Thread Driver, Charles
I have a function that outputs / compiles some latex. To do this I use 
Sys.which('pdflatex') and if nothing is found, prompt the user whether to 
install tinytex package. So, normally I understand the use of 'Suggests' in the 
package description to be for when there are only certain functions / tests 
that require the package. In this case, the package requirement is also 
conditional on other software (ie a tex distribution) not being found, 
otherwise it is unnecessary. There are no tests or examples that depend on the 
package. Should tinytex be in the 'Suggests' list?


Cheers,

Charles

[[alternative HTML version deleted]]

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] Appropriate usage of 'Suggests' -- package installed conditional on other software not found

2019-10-03 Thread Michael Dewey

Dear Charles

If your package prints a message to the user suggesting how to get a 
Latex installation then I do not think you need to do anything else. 
After all they could install Latex some other way if they pleased or try 
to work out why the installation they thought they had is not working.


Michael

On 03/10/2019 11:10, Driver, Charles wrote:

I have a function that outputs / compiles some latex. To do this I use 
Sys.which('pdflatex') and if nothing is found, prompt the user whether to 
install tinytex package. So, normally I understand the use of 'Suggests' in the 
package description to be for when there are only certain functions / tests 
that require the package. In this case, the package requirement is also 
conditional on other software (ie a tex distribution) not being found, 
otherwise it is unnecessary. There are no tests or examples that depend on the 
package. Should tinytex be in the 'Suggests' list?


Cheers,

Charles

[[alternative HTML version deleted]]

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel

---
This email has been checked for viruses by AVG.
https://www.avg.com




--
Michael
http://www.dewey.myzen.co.uk/home.html

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] consider running tools::compactPDF(gs_quality = "ebook")

2019-10-03 Thread Juhee Lee
Maybe "vignette.pdf" is rebuilt by R CMD build.

Juhee Lee

2019년 10월 2일 (수) 오후 10:09, Duncan Murdoch 님이 작성:

> On 02/10/2019 8:34 a.m., Juhee Lee wrote:
> > Dear all.
> >
> > I checked my package on win-builder, and got this message:
> >
> > * checking sizes of PDF files under 'inst/doc' ... WARNING
> >'gs+qpdf' made some significant size reductions:
> >   compacted 'vignette.pdf' from 541Kb to 234Kb
> >consider running tools::compactPDF(gs_quality = "ebook") on these
> files
> >
> >
> > But, I run R CMD build --compact-vignettes="gs+qpdf", and
> >
> > I installed gs and qpdf on my system.
> >
> > How can I solve this problem?
>
> Is vignette.pdf in inst/doc before calling R CMD build?  Is it rebuilt
> by R CMD build?
>
> Duncan Murdoch
>
> >
> >
> > Best regards
> >
> >
> > Juhee Lee.
> >
> > ---
> >
> >> Sys.which(Sys.getenv("R_GSCMD"))
> > C:\\Program Files\\gs\\gs9.27\\bin\\gswin64c.exe
> > "C:\\PROGRA~1\\gs\\gs9.27\\bin\\gswin64c.exe"
> >> Sys.which(Sys.getenv("R_QPDF"))
> > C:\\Program Files\\qpdf-9.0.1\\bin\\qpdf.exe
> > "C:\\PROGRA~1\\QPDF-9~1.1\\bin\\qpdf.exe"
> >> sessionInfo()
> > R version 3.6.1 (2019-07-05)
> > Platform: x86_64-w64-mingw32/x64 (64-bit)
> > Running under: Windows 10 x64 (build 18362)
> >
> > Matrix products: default
> >
> > locale:
> > [1] LC_COLLATE=Korean_Korea.949  LC_CTYPE=Korean_Korea.949
> > LC_MONETARY=Korean_Korea.949
> > [4] LC_NUMERIC=C LC_TIME=Korean_Korea.949
> >
> > attached base packages:
> > [1] stats graphics  grDevices utils datasets  methods   base
> >
> > other attached packages:
> > [1] LARisk_0.1.1
> >
> > loaded via a namespace (and not attached):
> > [1] compiler_3.6.1 tools_3.6.1Rcpp_1.0.2
> >
> >   [[alternative HTML version deleted]]
> >
> > __
> > R-package-devel@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-package-devel
> >
>
>

[[alternative HTML version deleted]]

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] Appropriate usage of 'Suggests' -- package installed conditional on other software not found

2019-10-03 Thread Dirk Eddelbuettel


Charles,

On 3 October 2019 at 10:10, Driver, Charles wrote:
| I have a function that outputs / compiles some latex. To do this I use 
Sys.which('pdflatex') and if nothing is found, prompt the user whether to 
install tinytex package. So, normally I understand the use of 'Suggests' in the 
package description to be for when there are only certain functions / tests 
that require the package. In this case, the package requirement is also 
conditional on other software (ie a tex distribution) not being found, 
otherwise it is unnecessary. There are no tests or examples that depend on the 
package. Should tinytex be in the 'Suggests' list?

A few suggestions:

 - IIRC CRAN Policy asks you to not have interactive prompts, and clearly
   prohibits messing with the system.  So no to the prompt to install.

 - CRAN and R have a perfectly working dependency system [1] so just use
   'Suggests: tinytex' and _then please condition your code on whether it is
   present_. [2]

 - Maybe add line breaks to your post?  ;-)

Dirk

[1] I continue to argue, as recently as yesterday in private mail with a
junior dev, that people misuse / misunderstand Depends and Suggests.
[2] Because if you don't your Suggests: really is a Depends:.

-- 
http://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] consider running tools::compactPDF(gs_quality = "ebook")

2019-10-03 Thread Juhee Lee
If what you say is the PATH of a system variable, there are in it.

And in R console, I can get this result:
   > Sys.getenv("R_GSCMD")
  [1] "C:\\Program Files\\gs\\gs9.27\\bin\\gswin64c.exe"
  > Sys.getenv("R_QPDF")
  [1] "C:\\Program Files\\qpdf-9.0.1\\bin\\qpdf.exe"


Juhee Lee

2019년 10월 2일 (수) 오후 11:40, Uwe Ligges 님이
작성:

>
>
> On 02.10.2019 15:09, Duncan Murdoch wrote:
> > On 02/10/2019 8:34 a.m., Juhee Lee wrote:
> >> Dear all.
> >>
> >> I checked my package on win-builder, and got this message:
> >>
> >> * checking sizes of PDF files under 'inst/doc' ... WARNING
> >>'gs+qpdf' made some significant size reductions:
> >>   compacted 'vignette.pdf' from 541Kb to 234Kb
> >>consider running tools::compactPDF(gs_quality = "ebook") on these
> >> files
> >>
> >>
> >> But, I run R CMD build --compact-vignettes="gs+qpdf", and
> >>
> >> I installed gs and qpdf on my system.
> >>
> >> How can I solve this problem?
> >
> > Is vignette.pdf in inst/doc before calling R CMD build?  Is it rebuilt
> > by R CMD build?
>
> ... and are ghostscript and qpdf on your PATH so that R picks it up?
>
> Best,
> Uwe Ligges
>
> >
> > Duncan Murdoch
> >
> >>
> >>
> >> Best regards
> >>
> >>
> >> Juhee Lee.
> >>
> >> ---
> >>
> >>> Sys.which(Sys.getenv("R_GSCMD"))
> >> C:\\Program Files\\gs\\gs9.27\\bin\\gswin64c.exe
> >> "C:\\PROGRA~1\\gs\\gs9.27\\bin\\gswin64c.exe"
> >>> Sys.which(Sys.getenv("R_QPDF"))
> >> C:\\Program Files\\qpdf-9.0.1\\bin\\qpdf.exe
> >> "C:\\PROGRA~1\\QPDF-9~1.1\\bin\\qpdf.exe"
> >>> sessionInfo()
> >> R version 3.6.1 (2019-07-05)
> >> Platform: x86_64-w64-mingw32/x64 (64-bit)
> >> Running under: Windows 10 x64 (build 18362)
> >>
> >> Matrix products: default
> >>
> >> locale:
> >> [1] LC_COLLATE=Korean_Korea.949  LC_CTYPE=Korean_Korea.949
> >> LC_MONETARY=Korean_Korea.949
> >> [4] LC_NUMERIC=C LC_TIME=Korean_Korea.949
> >>
> >> attached base packages:
> >> [1] stats graphics  grDevices utils datasets  methods   base
> >>
> >> other attached packages:
> >> [1] LARisk_0.1.1
> >>
> >> loaded via a namespace (and not attached):
> >> [1] compiler_3.6.1 tools_3.6.1Rcpp_1.0.2
> >>
> >> [[alternative HTML version deleted]]
> >>
> >> __
> >> R-package-devel@r-project.org mailing list
> >> https://stat.ethz.ch/mailman/listinfo/r-package-devel
> >>
> >
> > __
> > R-package-devel@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-package-devel
>

[[alternative HTML version deleted]]

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] Appropriate usage of 'Suggests' -- package installed conditional on other software not found

2019-10-03 Thread Fox, John
Dear Dirk,

> On Oct 3, 2019, at 9:11 AM, Dirk Eddelbuettel  wrote:
> 
> 
> Charles,
> 
> On 3 October 2019 at 10:10, Driver, Charles wrote:
> | I have a function that outputs / compiles some latex. To do this I use 
> Sys.which('pdflatex') and if nothing is found, prompt the user whether to 
> install tinytex package. So, normally I understand the use of 'Suggests' in 
> the package description to be for when there are only certain functions / 
> tests that require the package. In this case, the package requirement is also 
> conditional on other software (ie a tex distribution) not being found, 
> otherwise it is unnecessary. There are no tests or examples that depend on 
> the package. Should tinytex be in the 'Suggests' list?
> 
> A few suggestions:
> 
> - IIRC CRAN Policy asks you to not have interactive prompts, and clearly
>   prohibits messing with the system.  So no to the prompt to install.

Can you point to where in the CRAN policies this behaviour is prohibited?

The closest I can see is: "Packages should not write in the user’s home 
filespace (including clipboards), nor anywhere else on the file system apart 
from the R session’s temporary directory ... " But then, "Limited exceptions 
may be allowed in interactive sessions if the package obtains confirmation from 
the user."

Moreover, the tinytex package does precisely these kinds of things, including 
installing LaTeX.

Best,
 John


> 
> - CRAN and R have a perfectly working dependency system [1] so just use
>   'Suggests: tinytex' and _then please condition your code on whether it is
>   present_. [2]
> 
> - Maybe add line breaks to your post?  ;-)
> 
> Dirk
> 
> [1] I continue to argue, as recently as yesterday in private mail with a
> junior dev, that people misuse / misunderstand Depends and Suggests.
> [2] Because if you don't your Suggests: really is a Depends:.
> 
> -- 
> http://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org
> 
> __
> R-package-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] Appropriate usage of 'Suggests' -- package installed conditional on other software not found

2019-10-03 Thread Dirk Eddelbuettel


Hi John,

On 3 October 2019 at 13:56, Fox, John wrote:
| > On Oct 3, 2019, at 9:11 AM, Dirk Eddelbuettel  wrote:
| > On 3 October 2019 at 10:10, Driver, Charles wrote:
| > | I have a function that outputs / compiles some latex. To do this I use 
Sys.which('pdflatex') and if nothing is found, prompt the user whether to 
install tinytex package. So, normally I understand the use of 'Suggests' in the 
package description to be for when there are only certain functions / tests 
that require the package. In this case, the package requirement is also 
conditional on other software (ie a tex distribution) not being found, 
otherwise it is unnecessary. There are no tests or examples that depend on the 
package. Should tinytex be in the 'Suggests' list?
| > 
| > A few suggestions:
| > 
| > - IIRC CRAN Policy asks you to not have interactive prompts, and clearly
| >   prohibits messing with the system.  So no to the prompt to install.
| 
| Can you point to where in the CRAN policies this behaviour is prohibited?

Well I hedged my bet with "IIRC". Interactive prompts are neither explicitly
allowed, nor disallowed, but the larger paragraph you quote from gives some
hints.  Now, turning from the 'letter of the law' to the 'spirit of the law',
how many packages have you checked in the 25+ years of using R? How often
would you have wanted an interactive prompt?  I just ran reverse depends for
both Rcpp and RcppArmadillo in the last 48 hours so that is 2000+ packages --
and I am rather glad I didn't face prompts for any one of those 2000+.

| The closest I can see is: "Packages should not write in the user’s home 
filespace (including clipboards), nor anywhere else on the file system apart 
from the R session’s temporary directory ... " But then, "Limited exceptions 
may be allowed in interactive sessions if the package obtains confirmation from 
the user."
| 
| Moreover, the tinytex package does precisely these kinds of things, including 
installing LaTeX.

And tinytex is something I keep finding problematic as it creates an
obfuscation layer. There was a recent (purely latex-side) bug I fixed in one
of my packages after an alert from CRAN.  But the additional tinytex layer
made the latex-side error incomprehensible to misleading to the point where
the CRAN maintainer was mislead (as I was later).  Running plain tex is
better. I so wish tinytex would let me opt out and render directly via
tools::texi2pdf but sadly I have no such option.  I understand that tinytex
seems to help on some platforms without working infrastruture; I have always
had working (and extensible) texlive around due to the OS/distro I use.

Anyway, this is going off-topic.  It might be nice for R to offer a query
whether 'is tex available?' just how capabilities() and extSoftVersion()
gives hint on some other optional capabilities (which are arguably closer to
its core).

Dirk

-- 
http://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] consider running tools::compactPDF(gs_quality = "ebook")

2019-10-03 Thread Duncan Murdoch

On 03/10/2019 9:00 a.m., Juhee Lee wrote:

Maybe "vignette.pdf" is rebuilt by R CMD build.


Can't you tell by looking at what is printed?  You should see

* installing the package to build vignettes
* creating vignettes ... OK

(You can save this output to a file by adding the option --log to the R 
CMD build call).


Duncan Murdoch



Juhee Lee

2019년 10월 2일 (수) 오후 10:09, Duncan Murdoch 
mailto:murdoch.dun...@gmail.com>>님이 작성:


On 02/10/2019 8:34 a.m., Juhee Lee wrote:
 > Dear all.
 >
 > I checked my package on win-builder, and got this message:
 >
 > * checking sizes of PDF files under 'inst/doc' ... WARNING
 >    'gs+qpdf' made some significant size reductions:
 >       compacted 'vignette.pdf' from 541Kb to 234Kb
 >    consider running tools::compactPDF(gs_quality = "ebook") on
these files
 >
 >
 > But, I run R CMD build --compact-vignettes="gs+qpdf", and
 >
 > I installed gs and qpdf on my system.
 >
 > How can I solve this problem?

Is vignette.pdf in inst/doc before calling R CMD build?  Is it rebuilt
by R CMD build?

Duncan Murdoch

 >
 >
 > Best regards
 >
 >
 > Juhee Lee.
 >
 > ---
 >
 >> Sys.which(Sys.getenv("R_GSCMD"))
 > C:\\Program Files\\gs\\gs9.27\\bin\\gswin64c.exe
 >     "C:\\PROGRA~1\\gs\\gs9.27\\bin\\gswin64c.exe"
 >> Sys.which(Sys.getenv("R_QPDF"))
 > C:\\Program Files\\qpdf-9.0.1\\bin\\qpdf.exe
 >     "C:\\PROGRA~1\\QPDF-9~1.1\\bin\\qpdf.exe"
 >> sessionInfo()
 > R version 3.6.1 (2019-07-05)
 > Platform: x86_64-w64-mingw32/x64 (64-bit)
 > Running under: Windows 10 x64 (build 18362)
 >
 > Matrix products: default
 >
 > locale:
 > [1] LC_COLLATE=Korean_Korea.949  LC_CTYPE=Korean_Korea.949
 > LC_MONETARY=Korean_Korea.949
 > [4] LC_NUMERIC=C                 LC_TIME=Korean_Korea.949
 >
 > attached base packages:
 > [1] stats     graphics  grDevices utils     datasets  methods   base
 >
 > other attached packages:
 > [1] LARisk_0.1.1
 >
 > loaded via a namespace (and not attached):
 > [1] compiler_3.6.1 tools_3.6.1    Rcpp_1.0.2
 >
 >       [[alternative HTML version deleted]]
 >
 > __
 > R-package-devel@r-project.org
 mailing list
 > https://stat.ethz.ch/mailman/listinfo/r-package-devel
 >



__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] Appropriate usage of 'Suggests' -- package installed conditional on other software not found

2019-10-03 Thread Fox, John
Hi Dirk,

> On Oct 3, 2019, at 10:20 AM, Dirk Eddelbuettel  wrote:
> 
> 
> Hi John,
> 
> On 3 October 2019 at 13:56, Fox, John wrote:
> | > On Oct 3, 2019, at 9:11 AM, Dirk Eddelbuettel  wrote:
> | > On 3 October 2019 at 10:10, Driver, Charles wrote:
> | > | I have a function that outputs / compiles some latex. To do this I use 
> Sys.which('pdflatex') and if nothing is found, prompt the user whether to 
> install tinytex package. So, normally I understand the use of 'Suggests' in 
> the package description to be for when there are only certain functions / 
> tests that require the package. In this case, the package requirement is also 
> conditional on other software (ie a tex distribution) not being found, 
> otherwise it is unnecessary. There are no tests or examples that depend on 
> the package. Should tinytex be in the 'Suggests' list?
> | > 
> | > A few suggestions:
> | > 
> | > - IIRC CRAN Policy asks you to not have interactive prompts, and clearly
> | >   prohibits messing with the system.  So no to the prompt to install.
> | 
> | Can you point to where in the CRAN policies this behaviour is prohibited?
> 
> Well I hedged my bet with "IIRC". 

Yes, I noticed that, but didn't want people to be potentially misled since you 
didn't "RC"  ;)

> Interactive prompts are neither explicitly
> allowed, nor disallowed, but the larger paragraph you quote from gives some
> hints.  Now, turning from the 'letter of the law' to the 'spirit of the law',
> how many packages have you checked in the 25+ years of using R?

As it turns out, a lot, but I'm sure vastly fewer than you. The car package, 
e.g., has many reverse dependencies that I check before a new version of the 
package goes to CRAN.

> How often
> would you have wanted an interactive prompt?  

Well, never of course, but shouldn't interactive prompts only appear in 
interactive sessions -- e.g., enclosed in if (interactive()) {} in an example?

Moreover, I wasn't trying to argue that one *should* necessarily do this, just 
point out that one can in certain circumstances without violating CRAN 
policies. In the original context of this thread, a simple error message 
indicating that LaTeX is absent probably would suffice.

Best,
 John

> I just ran reverse depends for
> both Rcpp and RcppArmadillo in the last 48 hours so that is 2000+ packages --
> and I am rather glad I didn't face prompts for any one of those 2000+.
> 
> | The closest I can see is: "Packages should not write in the user’s home 
> filespace (including clipboards), nor anywhere else on the file system apart 
> from the R session’s temporary directory ... " But then, "Limited exceptions 
> may be allowed in interactive sessions if the package obtains confirmation 
> from the user."
> | 
> | Moreover, the tinytex package does precisely these kinds of things, 
> including installing LaTeX.
> 
> And tinytex is something I keep finding problematic as it creates an
> obfuscation layer. There was a recent (purely latex-side) bug I fixed in one
> of my packages after an alert from CRAN.  But the additional tinytex layer
> made the latex-side error incomprehensible to misleading to the point where
> the CRAN maintainer was mislead (as I was later).  Running plain tex is
> better. I so wish tinytex would let me opt out and render directly via
> tools::texi2pdf but sadly I have no such option.  I understand that tinytex
> seems to help on some platforms without working infrastruture; I have always
> had working (and extensible) texlive around due to the OS/distro I use.
> 
> Anyway, this is going off-topic.  It might be nice for R to offer a query
> whether 'is tex available?' just how capabilities() and extSoftVersion()
> gives hint on some other optional capabilities (which are arguably closer to
> its core).
> 
> Dirk
> 
> -- 
> http://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] Appropriate usage of 'Suggests' -- package installed conditional on other software not found

2019-10-03 Thread Dirk Eddelbuettel


John,

On 3 October 2019 at 15:26, Fox, John wrote:
| In the original context of this thread, a simple error message indicating 
that LaTeX is absent probably would suffice.

Yes, I agree. Hence this earlier comment of mine you choose not to reply to:

| > Anyway, this is going off-topic.  It might be nice for R to offer a query
| > whether 'is tex available?' just how capabilities() and extSoftVersion()
| > gives hint on some other optional capabilities (which are arguably closer to
| > its core).

That still holds because it's actually complicated -- pdflatex is a default,
but some styles require xelatex for other fonts, and there are other front
ends such as lualatex and so on.

R knows what it is doing. So if you (or Charles) look at tools::texi2dvi
(which is called by tools::texi2pdf) then you see it already tries quite a
few things to find a suitable latex drivers. Other (though IIRC not base R)
use latexmk. And the long and the short of it is that Charles probably just
wanted a Suggests: for tinytex followed by an if (requireNamespace("tinytex"))

But then "kids these days" don't care as they go from Rmd to html. Which may
be another reason not to prompt for 'pdflatex'.

Dirk

-- 
http://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] Appropriate usage of 'Suggests' -- package installed conditional on other software not found

2019-10-03 Thread Driver, Charles
Thanks for the thoughts all. In some ideal world I agree a simple message and 
leave it up to the user would be cleanest, in a world where I / others already 
have to deal with random compiler problems and other excitement in the middle 
of teaching workshops, I can see the benefits of an optional 'take care of it 
for me please' step.


I don't really see why this should be problematic / unappealing, if only asked 
during interactive sessions.


Since texi2dvi does more advanced checking than my simple Sys.which('pdflatex') 
, it sounds like I should rely on an error from that as cause for the message / 
prompt.


html / Mathjax was quite a pain for the matrix notation, so the kids are still 
stuck with latex in this case :)


While the answer seems to be 'include it in Suggests', it's still not 100% 
clear to me from the answers so far.  The more I think on it the more I think 
it doesn't really make sense, since all the code in my package can run without 
tinytex, and it is preferable to not install tinytex unless the compile error 
occurs and the user desires the install.


The code would look something like this -- if the general scope is actually 
violating CRAN policies then sure, it doesn't matter anyway, but so far I don't 
see that that's the case:


hastex <- !Sys.which('pdflatex') %in% ''
a=try(tools::texi2pdf(file=paste0(filename,'.tex'),quiet=FALSE, clean=TRUE))
if('try-error' %in% class(a) && !hastex) {
  message('Could not compile tex -- do you want to install tinytex? Will 
require a manual restart of R.')
  dotiny <- readline('Y/N?')
  if(dotiny %in% c('Y','y') && !requireNamespace('tinytex') ){
install.packages('tinytex')
requireNamespace('tinytex') #can perhaps leave this line out?
tinytex::install_tinytex()
  }
}




Cheers,

Charles



From: Dirk Eddelbuettel 
Sent: Thursday, October 3, 2019 5:45:20 PM
To: Fox, John
Cc: Dirk Eddelbuettel; Driver, Charles; r-package-devel@r-project.org
Subject: Re: [R-pkg-devel] Appropriate usage of 'Suggests' -- package installed 
conditional on other software not found


John,

On 3 October 2019 at 15:26, Fox, John wrote:
| In the original context of this thread, a simple error message indicating 
that LaTeX is absent probably would suffice.

Yes, I agree. Hence this earlier comment of mine you choose not to reply to:

| > Anyway, this is going off-topic.  It might be nice for R to offer a query
| > whether 'is tex available?' just how capabilities() and extSoftVersion()
| > gives hint on some other optional capabilities (which are arguably closer to
| > its core).

That still holds because it's actually complicated -- pdflatex is a default,
but some styles require xelatex for other fonts, and there are other front
ends such as lualatex and so on.

R knows what it is doing. So if you (or Charles) look at tools::texi2dvi
(which is called by tools::texi2pdf) then you see it already tries quite a
few things to find a suitable latex drivers. Other (though IIRC not base R)
use latexmk. And the long and the short of it is that Charles probably just
wanted a Suggests: for tinytex followed by an if (requireNamespace("tinytex"))

But then "kids these days" don't care as they go from Rmd to html. Which may
be another reason not to prompt for 'pdflatex'.

Dirk

--
http://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org

[[alternative HTML version deleted]]

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] Appropriate usage of 'Suggests' -- package installed conditional on other software not found

2019-10-03 Thread Dirk Eddelbuettel


On 3 October 2019 at 21:38, Driver, Charles wrote:
| Since texi2dvi does more advanced checking than my simple 
Sys.which('pdflatex') , it sounds like I should rely on an error from that as 
cause for the message / prompt.

Right.

The corrolary is that if texi2dvi fails, simply installing tinytex may not
help you either. AFAIK tinytex was primarily aimed at complementing an
existing texlive / miktex installation by noticing if any, and then which,
latex styles or fonts were missing and to then add them for the user -- which
is a good idea in principle.  I don't think it can act as a wholesale "oh you
have no (la)tex at all let's fix that in one command" magic potion.  Maybe it
does -- I just don't know as I tend to install texlive from my distro.
 
| html / Mathjax was quite a pain for the matrix notation, so the kids are 
still stuck with latex in this case :)

:)  
 
| While the answer seems to be 'include it in Suggests', it's still not 100% 
clear to me from the answers so far.  The more I think on it the more I think 
it doesn't really make sense, since all the code in my package can run without 
tinytex, and it is preferable to not install tinytex unless the compile error 
occurs and the user desires the install.

I still get back to the basic point of (la)tex simply being optional in the
context of an R installation which is your real issue so ...
 
| The code would look something like this -- if the general scope is actually 
violating CRAN policies then sure, it doesn't matter anyway, but so far I don't 
see that that's the case:
| 
| hastex <- !Sys.which('pdflatex') %in% ''
| a=try(tools::texi2pdf(file=paste0(filename,'.tex'),quiet=FALSE, clean=TRUE))
| if('try-error' %in% class(a) && !hastex) {
|   message('Could not compile tex -- do you want to install tinytex? Will 
require a manual restart of R.')
|   dotiny <- readline('Y/N?')
|   if(dotiny %in% c('Y','y') && !requireNamespace('tinytex') ){
| install.packages('tinytex')
| requireNamespace('tinytex') #can perhaps leave this line out?
| tinytex::install_tinytex()
|   }
| }

... while the diagnostics are right and well done, I am not sure the
suggested fix is all that helpful.  

Cheers, Dirk

-- 
http://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel