I've been working on an R package which interfaces with Python via a simple server script and socket connections. I can test in on my own machine just fine, but I'd like to test it on a Travis build as well (I don't want to go through the effort of setting up a Linux VM). To do this I would need a Python install that I can pass the path to in my R package tests, and a port number to use.
I've seen this answer which suggests installing multiple Python builds is possible, but I'm not sure how to approach
- Specifying the path(s) to the Python executable(s)
- choosing a port number for the test. It should also be noted that the Python script I am using for the Python 'server' uses 'localhost'.
Is it possible to do what I want on Travis? Should I want to do this with Travis?
EDIT Here's my Travis config:
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 the example in 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 a Python path, but fails with the error
Warning in socketConnection(port = self$port, open = "r+", blocking = TRUE, : localhost:6011 cannot be opened
Error socketConnection(port = self$port, open = "r+", blocking = TRUE, :
cannot open the connection
I tested this with another port and same error occurs.
EDIT 2
I've also tried it with host 127.0.0.1 and 0.0.0.0 but no dice. According to the Travis documentation, this should work... perhaps an issue with the R container?
 
     
    