I am developing a python package that depends on rpy2
. I would like to run test with Travis CI. In .travis.yml
I install conda and run tests with green
:
language: python
# Be strict when checking our package
warnings_are_errors: true
# command to install dependencies
install:
# http://conda.pydata.org/docs/travis.html
- wget https://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh -O miniconda.sh;
- bash miniconda.sh -b -p $HOME/miniconda
- export PATH="$HOME/miniconda/bin:$PATH"
- hash -r
- conda config --set always_yes yes --set changeps1 no
- conda update -q conda
# Useful for debugging any issues with conda
- conda info -a
# Replace dep1 dep2 ... with your dependencies
- conda create -q -n test-environment python=$TRAVIS_PYTHON_VERSION numpy scipy matplotlib pandas cython
- source activate test-environment
- python setup.py install
# command to run tests
script:
- green ...
In setup.py
:
from setuptools import setup, find_packages
setup(
version="0.0.0",
name="...",
packages=find_packages(),
install_requires=[
...
"green>=2.0.7",
"rpy2>=2.7.7",
],
)
When Travis CI installs my package I get the following error:
Installed /home/travis/miniconda/envs/test-environment/lib/python2.7/site-packages/tubtrack-0.0.0-py2.7.egg
Processing dependencies for tubtrack==0.0.0
Searching for rpy2>=2.7.7
Reading https://pypi.python.org/simple/rpy2/
Best match: rpy2 2.7.7
Downloading https://pypi.python.org/packages/source/r/rpy2/rpy2-2.7.7.tar.gz#md5=be93432426744cdae8a0e5d2b157d371
Processing rpy2-2.7.7.tar.gz
Writing /tmp/easy_install-CF50ds/rpy2-2.7.7/setup.cfg
Running rpy2-2.7.7/setup.py -q bdist_egg --dist-dir /tmp/easy_install-CF50ds/rpy2-2.7.7/egg-dist-tmp-TTJjtB
error: Setup script exited with Error: Tried to guess R's HOME but no command (R) in the PATH.
I am wondering if anyone knows how to solve it? I tried to install r in .travis.yml
:
addons:
apt:
packages:
- r
However, it didn't change the error message...
EDIT: In the comments it was pointed that I need to specify at least one source in addons.apt.sources
for the APT addon to work and R package is named r-base
. I did the following modifications in .travis.yml
:
addons:
apt:
sources:
- r-packages-precise
packages:
- r-base
Now it seems that rpy2
can find R
, but I am still getting an error when it is imported while the tests are run with green
:
Traceback (most recent call last):
File "/home/travis/miniconda/envs/test-environment/lib/python2.7/site-packages/green-2.2.0-py2.7.egg/green/loader.py", line 212, in loadFromModuleFilename
__import__(dotted_module)
File "xxx/xxx/xxx.py", line 4, in <module>
from .. import tools
File "xxx/tools.py", line 5, in <module>
import rpy2.robjects as robjects
File "/home/travis/miniconda/envs/test-environment/lib/python2.7/site-packages/rpy2-2.7.7-py2.7-linux-x86_64.egg/rpy2/robjects/__init__.py", line 15, in <module>
import rpy2.rinterface as rinterface
File "/home/travis/miniconda/envs/test-environment/lib/python2.7/site-packages/rpy2-2.7.7-py2.7-linux-x86_64.egg/rpy2/rinterface/__init__.py", line 99, in <module>
from rpy2.rinterface._rinterface import *
ImportError: /home/travis/miniconda/envs/test-environment/lib/libreadline.so.6: undefined symbol: PC
However,on my laptop it works fine! So I guess the problem is still that rpy2
is not installed properly.
addons.apt.sources
for the APT addon to work (official list here), in this case - the source (PPA) in which ther
package is located (r-packages-precise
if it's in the "default" repo). Also, the R package looks like it's namedr-base
, so make sure this package actually exists.