MCPcopy Index your code
hub / github.com/go-python/gopy / init

Function init

main_windows_test.go:17–81  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

15)
16
17func init() {
18
19 testEnvironment = os.Environ()
20
21 var (
22 // py2 = "python2"
23 py3 = "python3"
24 // pypy2 = "pypy"
25 // pypy3 = "pypy3"
26 )
27
28 if os.Getenv("GOPY_TRAVIS_CI") == "1" {
29 log.Printf("Running in travis CI")
30 }
31
32 var (
33 disabled []string
34 missing int
35 )
36 for _, be := range []struct {
37 name string
38 vm string
39 module string
40 mandatory bool
41 }{
42 {"py3", py3, "", true},
43 } {
44 args := []string{"-c", ""}
45 if be.module != "" {
46 args[1] = "import " + be.module
47 }
48 log.Printf("checking testbackend: %q...", be.name)
49
50 py, err := exec.LookPath(be.vm)
51 if err != nil {
52 log.Printf("gopy: could not locate 'python' executable (err: %v)", err)
53 } else {
54 log.Printf("python executable found at: %s\n", py)
55 cmd := exec.Command(py, args...)
56 cmd.Stdin = os.Stdin
57 cmd.Stdout = os.Stdout
58 cmd.Stderr = os.Stderr
59 err = cmd.Run()
60 }
61 if err != nil {
62 log.Printf("disabling testbackend: %q, error: '%s'", be.name, err.Error())
63 testBackends[be.name] = ""
64 disabled = append(disabled, be.name)
65 if be.mandatory {
66 missing++
67 }
68 } else {
69 log.Printf("enabling testbackend: %q", be.name)
70 testBackends[be.name] = be.vm
71 }
72 }
73
74 if len(disabled) > 0 {

Callers

nothing calls this directly

Calls 2

PrintfMethod · 0.80
ErrorMethod · 0.80

Tested by

no test coverage detected