Skip to content

Commit

Permalink
Update PythonInterface.scala
Browse files Browse the repository at this point in the history
  • Loading branch information
ducky64 committed Jul 25, 2024
1 parent 4d005cf commit 9426c7a
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions compiler/src/main/scala/edg/compiler/PythonInterface.scala
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,14 @@ class ProtobufStdioSubprocess[RequestType <: scalapb.GeneratedMessage, ResponseT
* This invokes "python -m edg.hdl_server", using either the local or global (pip) module as available.
*/
class PythonInterface(interpreter: String = "python", pythonPaths: Seq[String] = Seq()) {
val submoduleSearchPaths = if (pythonPaths.nonEmpty) pythonPaths else Seq(".")
val isSubmoduled = submoduleSearchPaths.map { searchPath => // check if submoduled, if so prepend the submodule name
new File(new File(searchPath), "PolymorphicBlocks/edg/hdl_server/__init__.py").exists()
}.exists(identity)
private val packageName = if (isSubmoduled) {
"PolymorphicBlocks.edg.hdl_server"
} else {
"edg.hdl_server"
}
private val submoduleSearchPaths = if (pythonPaths.nonEmpty) pythonPaths else Seq(".")
private val isSubmoduled =
submoduleSearchPaths.map { searchPath => // check if submoduled, if so prepend the submodule name
new File(new File(searchPath), "PolymorphicBlocks/edg/hdl_server/__init__.py").exists()
}.exists(identity)
val packagePrefix = if (isSubmoduled) "PolymorphicBlocks." else ""
private val packageName = packagePrefix + "edg.hdl_server"

private val command = Seq(interpreter, "-u", "-m", packageName)
protected val process = new ProtobufStdioSubprocess[edgrpc.HdlRequest, edgrpc.HdlResponse](
edgrpc.HdlResponse,
Expand Down

0 comments on commit 9426c7a

Please sign in to comment.