简体   繁体   English

准备具有外部依赖关系的CRAN R包(nlopt)

[英]Prepare CRAN R package with external dependencies (nlopt)

I am trying to submit a package to CRAN that fails during the pretest process on Debian. 我正在尝试向CRAN提交一个在Debian预测试过程中失败的软件包。

I use some C++ code that interfaces to the nlopt optimization library with Rcpp/RcppArmadillo (using <nlopt.hpp> ). 我使用一些C ++代码与Rcpp / RcppArmadillo(使用<nlopt.hpp> )连接到nlopt优化库。 Thus, my package requires a system version of nlopt that can be installed via the deb package libnlopt-dev (I added this to the SystemRequirements field). 因此,我的软件包需要一个系统版本的nlopt,可以通过deb软件包libnlopt-dev安装(我将它添加到SystemRequirements字段)。

I use a configure script and pkg-config to retrieve the (hopefully) appropriate compiler flags which I then send to src/Makevars 我使用配置脚本和pkg-config来检索(希望)适当的编译器标志,然后我将其发送到src / Makevars

NLOPT_LIBS=`pkg-config --libs ${PKG_CONFIG_NAME}`
NLOPT_FLAG=`pkg-config --cflags ${PKG_CONFIG_NAME}`

This approach works on my system (Ubuntu 18.04, R 3.5.2) and on Travis (linux and mac OS), but fails on the Debian CRAN server : https://win-builder.r-project.org/incoming_pretest/PLNmodels_0.7_20190119_161032/Debian/00install.out 这种方法适用于我的系统(Ubuntu 18.04,R 3.5.2)和Travis(linux和mac OS),但在Debian CRAN服务器上失败: https ://win-builder.r-project.org/incoming_pretest/PLNmodels_0 .7_20190119_161032 / Debian的/ 00install.out

I added some verbosity to check that the flags were correctly exported on CRAN servers, and they seems alright to me: at least, a version of nlopt is found on the system (see below, NLOPT_LIBS=-lnlopt -lm ). 我添加了一些详细信息来检查标志是否在CRAN服务器上正确导出,它们对我来说似乎没问题:至少在系统上找到了nlopt的版本(参见下文, NLOPT_LIBS=-lnlopt -lm )。 However, the <nlopt.hpp> is not found latter on... 但是, <nlopt.hpp>没有找到<nlopt.hpp> ......

Any help would be greatly appreciated. 任何帮助将不胜感激。 Thank for taking the time to read this. 感谢您抽出宝贵时间阅读本文。

* installing *source* package ‘PLNmodels’ ...
Using NLOPT_LIBS=-lnlopt -lm
Using NLOPT_FLAG=
** libs
g++-8  -std=gnu++11 -I"/home/hornik/tmp/R/include" -DNDEBUG -fopenmp
-I"/home/hornik/lib/R/Library/3.6/x86_64-linux-gnu/Rcpp/include"
-I"/home/hornik/lib/R/Library/3.6/x86_64-linux-gnu/RcppArmadillo/include"
-I/usr/local/include -fopenmp  -fpic  -g -O2 -Wall -pedantic
-mtune=native -c RcppExports.cpp -o RcppExports.o
g++-8  -std=gnu++11 -I"/home/hornik/tmp/R/include" -DNDEBUG -fopenmp
-I"/home/hornik/lib/R/Library/3.6/x86_64-linux-gnu/Rcpp/include"
-I"/home/hornik/lib/R/Library/3.6/x86_64-linux-gnu/RcppArmadillo/include"
-I/usr/local/include -fopenmp  -fpic  -g -O2 -Wall -pedantic
-mtune=native -c call_nlopt_PLN_VE.cpp -o call_nlopt_PLN_VE.o
In file included from call_nlopt_PLN_VE.cpp:6:
utils.h:5:10: fatal error: nlopt.hpp: No such file or directory
 #include <nlopt.hpp>
          ^~~~~~~~~~~
compilation terminated.
make: *** [/home/hornik/tmp/R/etc/Makeconf:173: call_nlopt_PLN_VE.o] Error 1
ERROR: compilation failed for package ‘PLNmodels’
* removing ‘/srv/hornik/tmp/CRAN/PLNmodels.Rcheck/PLNmodels’

The C++ interface for nlopt has migrated to a separate package in Debian, cf https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=855600 . nlopt的C ++接口已经迁移到Debian中的一个单独的包,参见https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=855600 So it looks like that particular CRAN machine uses either Debian Testing or Stable + Backports and has only libnlopt-dev but not libnlopt-cxx-dev installed. 所以看起来特定的CRAN机器使用Debian Testing或Stable + libnlopt-dev并且只安装了libnlopt-dev但没有安装libnlopt-cxx-dev You will have to contact the CRAN maintainers to install this dependency. 您必须联系CRAN维护者才能安装此依赖项。

BTW, ideally such errors should be cought in the configure script, ie you should try to compile a simple program that requires nlopt.hpp . 顺便说一句,理想情况下,这样的错误应该在configure脚本中,即你应该尝试编译一个需要nlopt.hpp的简单程序。

You asked the same question here on r-package-devel and I had no good answer for you. 在r-package-devel上问了同样的问题,我对你没有好的答案。

In essence, you have fine variation within one required upstream package. 实质上,您在一个必需的上游包中有很好的变化。 That is very delicate. 这非常微妙。 I cannot think of anything but what @Ralf suggested: test for it . 除了@Ralf的建议,我想不出任何东西: 测试它

Or maybe you just fail in communicating the requirements of your package to CRAN. 或者您可能无法将包的要求传达给CRAN。 But that would be an even simpler question, and when the wrong version is encountered, you are bound to fail installation. 但这将是一个更简单的问题,当遇到错误的版本时,您将无法安装失败。

So overall, my recommendation is the same as previously: work with Jelmer, and wait for him to release an updated nloptr release. 总的来说,我的建议与以前一样:与Jelmer合作,并等待他发布更新的nloptr版本。 Until then, all solutions are bound to be fudges as you cannot control what version of nloptr your package may encounter . 在此之前,所有解决方案都必然是捏造, 因为您无法控制您的软件包可能遇到的nloptr版本

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM