Skip to content

Commit 89507df

Browse files
committed
fix: check whether the package is installed by importing package
1 parent 7db9efb commit 89507df

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

shared/utils.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,20 +133,19 @@ func InstallPythonPackage(python3 string, pkg string) (err error) {
133133
}
134134
}()
135135

136+
// check if package installed
137+
err = exec.Command(python3, "-c", fmt.Sprintf("import %s", pkgName)).Run()
138+
if err == nil {
139+
return nil
140+
}
141+
136142
// check if pip available
137143
err = execCommand(python3, "-m", "pip", "--version")
138144
if err != nil {
139145
log.Warn().Msg("pip is not available")
140146
return errors.Wrap(err, "pip is not available")
141147
}
142148

143-
// check if funppy installed
144-
err = execCommand(python3, "-m", "pip", "show", pkgName, "--quiet")
145-
if err == nil {
146-
// package is installed
147-
return nil
148-
}
149-
150149
log.Info().Str("package", pkg).Msg("installing python package")
151150

152151
// install package

0 commit comments

Comments
 (0)