jove.PythonZMQKernel.scala Maven / Gradle / Ivy
The newest version!
package jove
import java.io.File
import jove.helpers.zmq.ZMQKernel
import scala.sys.process._
object PythonZMQKernel {
val iPythonProfileDir = (new File(System.getProperty("user.home")) /: List(".ipython", "profile_default"))(new File(_, _))
val iPythonConnectionDir = new File(iPythonProfileDir, "security")
def apply(pythonPath: String): ZMQKernel = new ZMQKernel(iPythonConnectionDir) {
override def preStart(connectionFile: File): Unit = {
val cmd = List(
pythonPath,
"-m",
"IPython.kernel",
"-f",
connectionFile.getAbsolutePath,
"--profile-dir",
iPythonProfileDir.getAbsolutePath
)
logger debug s"Running command $cmd"
cmd.run()
}
}
}