File tree Expand file tree Collapse file tree 3 files changed +17
-4
lines changed
Expand file tree Collapse file tree 3 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -232,6 +232,7 @@ point.print()
232232package main
233233
234234import (
235+ " fmt"
235236 " os"
236237
237238 . " github.com/cpunion/go-python"
@@ -273,8 +274,9 @@ func updateExamples(country string) Object {
273274
274275func main () {
275276 if len (os.Args ) > 2 {
276- // avoid gradio start subprocesses
277- return
277+ // start subprocesses
278+ fmt.Println (" start subprocess:" , os.Args )
279+ os.Exit (RunMain (os.Args ))
278280 }
279281
280282 Initialize ()
Original file line number Diff line number Diff line change 11package main
22
33import (
4+ "fmt"
45 "os"
56
67 . "github.com/cpunion/go-python"
@@ -42,8 +43,9 @@ func updateExamples(country string) Object {
4243
4344func main () {
4445 if len (os .Args ) > 2 {
45- // avoid gradio start subprocesses
46- return
46+ // start subprocesses
47+ fmt .Println ("start subprocess:" , os .Args )
48+ os .Exit (RunMain (os .Args ))
4749 }
4850
4951 Initialize ()
Original file line number Diff line number Diff line change @@ -111,6 +111,15 @@ func RunString(code string) error {
111111 return nil
112112}
113113
114+ func RunMain (args []string ) int {
115+ argc := len (args )
116+ argv := make ([]* C.char , argc + 1 )
117+ for i , arg := range args {
118+ argv [i ] = AllocCStr (arg )
119+ }
120+ return int (C .Py_BytesMain (C .int (argc ), & argv [0 ]))
121+ }
122+
114123// ----------------------------------------------------------------------------
115124
116125func check (b bool , msg string ) {
You can’t perform that action at this time.
0 commit comments