Re: [R-pkg-devel] Formatting .Rbuildignore

2020-08-17 Thread William Dunlap
I just tried this out with R-4.0.2 on Linux and it looks like
.Rbuildignore does not treat lines with '#'s as comments.  E.g.,

% mkdir test test/inst
% touch 'test/inst/#octothorp.txt' 'test/inst/normal.txt'
% echo > test/DESCRIPTION 'Package: test\nVersion: 0.1\nTitle:
test\nDescription: A test of .Rbuildignore'
% touch test/NAMESPACE
% R CMD build test > /dev/null

% tar ztf test_0.1.tar.gz | grep '\.txt$'
test/inst/#octothorp.txt
test/inst/normal.txt
% echo '#.*[.]txt' > test/.Rbuildignore
% R CMD build test > /dev/null

% tar ztf test_0.1.tar.gz | grep '\.txt$'
test/inst/normal.txt

Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Mon, Aug 17, 2020 at 9:47 AM Ivan Krylov  wrote:
>
> On Mon, 17 Aug 2020 15:56:07 +0200
> Thierry Onkelinx  wrote:
>
> > Can we add blank lines in .Rbuildignore? Or lines with only comments
> > (line starting with #)?
>
> .Rbuildignore is not documented [1] to allow comments, but the
> current implementation does skip empty lines [2] since 2010 [3]
> (otherwise empty regular expressions would match all file names).
>
> It could be possible to get away with comment lines, since the
> resulting regular expressions are unlikely to ever match anything, but
> it would cost CPU cycles to match every file name against every
> regular expression, and some regular expressions may turn out to be
> really expensive on some inputs [4].
>
> I think that it's best not to try to add comments to .Rbuildignore, and
> to avoid blank lines unless not having them becomes really inconvenient.
>
> --
> Best regards,
> Ivan
>
> [1]
> https://cran.r-project.org/doc/manuals/R-exts.html#Building-package-tarballs
>
> [2]
> https://github.com/wch/r-source/blob/9d13622f41cfa0f36db2595bd6a5bf93e2010e21/src/library/tools/R/build.R#L85
>
> [3]
> https://github.com/wch/r-source/commit/b2065b2c36235b876977e405f567afec6ab644b3
>
> [4] https://en.wikipedia.org/wiki/ReDoS
>
> __
> 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] Formatting .Rbuildignore

2020-08-17 Thread Ivan Krylov
On Mon, 17 Aug 2020 15:56:07 +0200
Thierry Onkelinx  wrote:

> Can we add blank lines in .Rbuildignore? Or lines with only comments
> (line starting with #)?

.Rbuildignore is not documented [1] to allow comments, but the
current implementation does skip empty lines [2] since 2010 [3]
(otherwise empty regular expressions would match all file names).

It could be possible to get away with comment lines, since the
resulting regular expressions are unlikely to ever match anything, but
it would cost CPU cycles to match every file name against every
regular expression, and some regular expressions may turn out to be
really expensive on some inputs [4].

I think that it's best not to try to add comments to .Rbuildignore, and
to avoid blank lines unless not having them becomes really inconvenient.

-- 
Best regards,
Ivan

[1]
https://cran.r-project.org/doc/manuals/R-exts.html#Building-package-tarballs

[2]
https://github.com/wch/r-source/blob/9d13622f41cfa0f36db2595bd6a5bf93e2010e21/src/library/tools/R/build.R#L85

[3]
https://github.com/wch/r-source/commit/b2065b2c36235b876977e405f567afec6ab644b3

[4] https://en.wikipedia.org/wiki/ReDoS

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


Re: [R-pkg-devel] How to retrieve a flag set in configure.ac (filled in Makevars.in) during package installation in an R or C++ script ?

2020-08-17 Thread Ivan Krylov
On Sat, 15 Aug 2020 19:50:41 +0530
Akshit Achara  wrote:

> To access these files, I need to use the path of libminizinc (which
> can change per installation). I want to extract this path from either
> Makevars or configure to use it in my package. 

Just as Makevars is generated during ./configure run from Makefile.in,
you could generate a config.h from a config.h.in and substitute all the
necessary #defines in it. This is how GNU autoconf is typically used in
stand-alone programs [*].

A simpler option would be to add an equivalent of
-DMZN_PATH='"@MZN_PATH"' to PKG_CPPFLAGS in Makevars.in and make sure
that AC_SUBST is called for that variable in configure.ac [**]. Then
the C or C++ code would be able to use MZN_PATH as if it was #defined
in a header file.

-- 
Best regards,
Ivan

[*]
https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/Configuration-Headers.html

[**]
https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/Makefile-Substitutions.html

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


[R-pkg-devel] Formatting .Rbuildignore

2020-08-17 Thread Thierry Onkelinx
Dear all,

Can we add blank lines in .Rbuildignore? Or lines with only comments (line
starting with #)?

Best regards,

ir. Thierry Onkelinx
Statisticus / Statistician

Vlaamse Overheid / Government of Flanders
INSTITUUT VOOR NATUUR- EN BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE AND
FOREST
Team Biometrie & Kwaliteitszorg / Team Biometrics & Quality Assurance
thierry.onkel...@inbo.be
Havenlaan 88 bus 73, 1000 Brussel
www.inbo.be

///
To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to say
what the experiment died of. ~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data. ~ Roger Brinner
The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey
///



[[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] How to retrieve a flag set in configure.ac (filled in Makevars.in) during package installation in an R or C++ script ?

2020-08-17 Thread Akshit Achara
Dear Andreas,

Thanks for your answer!

I also got an answer from Rcpp-devel list by Nik Pocuca. He suggested me to
create an .RData or .rda file
(say config.RData) in the data folder of my package and then execute the
statement given below in Makevars.in
to save the flag in the .RData file.
$(R_HOME)/bin/Rscript -e "LIBMINIZINC_PATH <- '@MZN_LIBS@';
save(LIBMINIZINC_PATH, file='../data/config.RData')"

This way the flag would be saved in the data file. Then in the script I
call data("config") and the LIBMINIZINC_PATH flag is
loaded in the global environment from where I can access and use it. I am
currently using this solution and haven't faced
any issues.

Thanks,
Akshit


On Mon, Aug 17, 2020 at 3:36 PM Blätte, Andreas 
wrote:

> Dear Akshit,
>
> in the configure script of my package RcppCWB, I use the command line call
> 'R CMD config ...' to get the installation flags.
>
> Calling 'R CMD config' will display options. For your scenario, you can
> use 'R CMD config CPPFLAGS' to get the value of CPPFLAGS.
>
> To call R CMD config safely, you will need to prepend $R_HOME/bin. In the
> configure script of RcppCWB, I need to detect the compiler used and I do it
> using this snippet:
> CC_R=`$R_HOME/bin/R CMD config CC`
>
> More experienced people following R-package-devel than myself may be aware
> of a better solution, and I would also be happy to learn about it.
>
> Kind regards
> Andreas
>
>
> Am 15.08.20, 16:25 schrieb "R-package-devel im Auftrag von Akshit Achara"
>  acharaaks...@gmail.com>:
>
> Hi everyone,
>
> Background:
>
> The package rminizinc 
> provides
> an interface to MiniZinc
>  in R. The
> package
> provides various functionalities to parse, solve and manipulate
> MiniZinc
> models. This is done by using the MiniZinc C++ API (libminizinc
> ).
>
> The installation requires linking of the library an including the
> header
> files for which PKG_LIBS flag(-L/path/to/libminizinc -lmzn) , and
> PKG_CPPFLAGS (-I/path/to/libminizinc/include) are filled in Makevars.in
> which is set by configure based on the path of the library provided by
> the
> user using --configure-args or if the user doesn't provide any
> arguments, a
> default path is passed from configure (using configure.ac).
>
> Question:
>
> In one of my Rcpp functions mzn_parse() which is used to parse MiniZinc
> models, I sometimes need to use the files in the subdirectories of the
> libminizinc library. To access these files, I need to use the path of
> libminizinc (which can change per installation). I want to extract this
> path from either Makevars or configure to use it in my package. Is
> there
> any way I could retrieve this path in my scripts?
>
> Please let me know if this question is not relevant to the mailing
> list.
>
> The Makevars.in looks like this:
>
> CXX_STD = CXX11
> PKG_CPPFLAGS = -I. @MZN_INCLUDE@
> PKG_LIBS = @MZN_LIBS@
> OBJECTS.tests = cpp_tests/test-runner.o cpp_tests/test-mzn_parse.o
> cpp_tests/test-
> set_params.o cpp_tests/test-mzn_eval.o cpp_tests/test-sol_parse.o
> cpp_tests/test-
> getMissingPars.o
> OBJECTS.sources = RcppExports.o set_params.o mzn_parse.o mzn_eval.o
> sol_parse.o
> getMissingPars.o
> OBJECTS.helpers = filetoString.o helper_parse.o expDetails.o
> pathStringcheck.o
> OBJECTS = $(OBJECTS.sources) $(OBJECTS.tests) $(OBJECTS.helpers)
> $(SOURCES:.cpp=.o)
> strippedLib: $(SHLIB)
> if test -e "/usr/bin/strip"; then /usr/bin/strip --strip-debug
> $(SHLIB); fi.phony: strippedLib
> all: clean
> clean:
> rm -f $(OBJECTS.sources) $(OBJECTS.tests) $(OBJECTS.helpers)  *.so
>
> Thanks!
>
> [[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] Etiquette for package submissions that do not automatically pass checks?

2020-08-17 Thread Ivan Krylov
Dear Cesko,

On Fri, 14 Aug 2020 21:08:55 +0200
Cesko Voeten  wrote:

> The package contains functionality to run on cluster nodes that were
> set up by the user and needs to access its own internal functions
> from there.

Apologies for derailing the thread, but I had a similar problem a few
months ago [*], found what looks like a different solution but did not
have time to investigate it further.

Given that serialize() does not send package namespaces over the wire
[**], why would it be a bad idea to pass actual functions (instead of
character strings naming functions) to parallel::parLapply and friends?
This seems to avoid the need to export the worker functions or use :::
in calls to parallel functions from package functions. Unless I am
missing something, which I probably am.

-- 
Best regards,
Ivan

[*] https://stat.ethz.ch/pipermail/r-package-devel/2020q2/005468.html

[**]
https://cran.r-project.org/doc/manuals/r-release/R-ints.html#Serialization-Formats

"Package and namespace environments are written with pseudo-SEXPTYPEs
followed by the name."

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


Re: [R-pkg-devel] How to retrieve a flag set in configure.ac (filled in Makevars.in) during package installation in an R or C++ script ?

2020-08-17 Thread Blätte , Andreas
Dear Akshit,

in the configure script of my package RcppCWB, I use the command line call 'R 
CMD config ...' to get the installation flags. 

Calling 'R CMD config' will display options. For your scenario, you can use 'R 
CMD config CPPFLAGS' to get the value of CPPFLAGS. 

To call R CMD config safely, you will need to prepend $R_HOME/bin. In the 
configure script of RcppCWB, I need to detect the compiler used and I do it 
using this snippet:
CC_R=`$R_HOME/bin/R CMD config CC`

More experienced people following R-package-devel than myself may be aware of a 
better solution, and I would also be happy to learn about it.

Kind regards
Andreas 


Am 15.08.20, 16:25 schrieb "R-package-devel im Auftrag von Akshit Achara" 
:

Hi everyone,

Background:

The package rminizinc  provides
an interface to MiniZinc
 in R. The package
provides various functionalities to parse, solve and manipulate MiniZinc
models. This is done by using the MiniZinc C++ API (libminizinc
).

The installation requires linking of the library an including the header
files for which PKG_LIBS flag(-L/path/to/libminizinc -lmzn) , and
PKG_CPPFLAGS (-I/path/to/libminizinc/include) are filled in Makevars.in
which is set by configure based on the path of the library provided by the
user using --configure-args or if the user doesn't provide any arguments, a
default path is passed from configure (using configure.ac).

Question:

In one of my Rcpp functions mzn_parse() which is used to parse MiniZinc
models, I sometimes need to use the files in the subdirectories of the
libminizinc library. To access these files, I need to use the path of
libminizinc (which can change per installation). I want to extract this
path from either Makevars or configure to use it in my package. Is there
any way I could retrieve this path in my scripts?

Please let me know if this question is not relevant to the mailing list.

The Makevars.in looks like this:

CXX_STD = CXX11
PKG_CPPFLAGS = -I. @MZN_INCLUDE@
PKG_LIBS = @MZN_LIBS@
OBJECTS.tests = cpp_tests/test-runner.o cpp_tests/test-mzn_parse.o
cpp_tests/test-
set_params.o cpp_tests/test-mzn_eval.o cpp_tests/test-sol_parse.o
cpp_tests/test-
getMissingPars.o
OBJECTS.sources = RcppExports.o set_params.o mzn_parse.o mzn_eval.o 
sol_parse.o
getMissingPars.o
OBJECTS.helpers = filetoString.o helper_parse.o expDetails.o 
pathStringcheck.o
OBJECTS = $(OBJECTS.sources) $(OBJECTS.tests) $(OBJECTS.helpers)
$(SOURCES:.cpp=.o)
strippedLib: $(SHLIB)
if test -e "/usr/bin/strip"; then /usr/bin/strip --strip-debug
$(SHLIB); fi.phony: strippedLib
all: clean
clean:
rm -f $(OBJECTS.sources) $(OBJECTS.tests) $(OBJECTS.helpers)  *.so

Thanks!

[[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