All Downloads are FREE. Search and download functionalities are using the official Maven repository.

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()
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy