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
warnings_are_errors: true
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?