Install Python and R to build Travis?

I worked on an R package that interacts with Python using a simple script server and sockets. I can test on my machine just fine, but I also want to test it on the Travis assembly (I don't want to try to configure Linux VM). To do this, I will need a Python installation, which I can go through in the R-package tests and the port number to use.

I saw this answer that suggests installing multiple Python assemblies, but I'm not sure how to approach

  • Specifying the path (s) to the Python executable
  • selection of port number for test. It should also be noted that the Python script that I use for the Python server uses "localhost".

Can I do what I want on Travis? Should I do this with Travis?

EDIT Here is my Travis configuration:

language: r
r:
  - release
  - devel
cache: packages
sudo: false

matrix:
  include:
    - python:2.7
    - python:3.6

# Be strict when checking our package
warnings_are_errors: true

# System dependencies for HTTP calling
r_binary_packages:
 - jsonlite
 - R6

And here is an example of my R package:

pypath = Sys.which('python') 
if(nchar(pypath) > 0) {
  py = PythonEnv$new(port = 6011, path = pypath)
  py$start
  py$running
  py$set(a = 5)
  py$get('a')
  py$stop
} else {
  message("No Python environment available")
}

My example definitely finds the Python path, but with an error

Warning in socketConnection (port = self $ port, open = "r +", blocking = TRUE ,: localhost: 6011 cannot be opened

SocketConnection error (port = self $ port, open = "r +", blocking = TRUE ,:
cannot open connection

I tested this with a different port and the same error occurred.

EDIT 2

I also tried it with the host 127.0.0.1and 0.0.0.0, but without the dice. According to Travis documentation, this should work ... maybe a problem with the R container?

+6
source share
2 answers

travis.yml, pyrle. R usinq ubuntu:

language: python
python:
  - "3.6"
install:
  - pip install cython pytest hypothesis
  - sudo apt-get install -y r-base
  - echo 'source("https://bioconductor.org/biocLite.R"); biocLite("S4Vectors"); biocLite("GenomicRanges")' > install.R
  - python setup.py install

script:
  - py.test tests/

- R conda. pyranges:

# Stolen from http://conda.pydata.org/docs/travis.html
language: python
python:
  # We don't actually use the Travis Python, but this keeps it organized.
  - "3.6"
install:
  - sudo apt-get update
  # We do this conditionally because it saves us some downloading if the
  # version is the same.
  - wget https://repo.continuum.io/miniconda/Miniconda3-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
  - conda config --add channels bioconda
  - conda config --add channels r
  # Useful for debugging any issues with conda
  - conda info -a
  - conda create -q -n test-environment python=$TRAVIS_PYTHON_VERSION numpy scipy pandas pytest pytest-cov cython tabulate hypothesis bedtools # ray
  - source activate test-environment
  - python setup.py install # will install ncls
  - python --version
  - python -c 'import pandas as pd; print(pd.__version__)'
  - ls tests

script: py.test -v tests # verbose to see that tests run and so that travis does not time out on hypothesis tests
+2

.

+ R

Unfun Cat, travis python R apt, travis R python apt:

language: r
install:
  - sudo apt-get install -y python2.7 python3.6

, travis , .yaml (, , ).

language: r
addons:
  apt:
    packages:
    - python2.7
    - python3.6

Python Sys.which python2.7 python3.6 "python". which python , python2*.


, . , . 6011 X Window (ref), , travis.

, , -

sudo lsof -i -P -n | grep LISTEN | grep 6011

travis.yaml , . .

github, R; , .

0

Source: https://habr.com/ru/post/1678374/


All Articles