Skip to content

Commit e2433c1

Browse files
authored
Merge pull request #6 from xucong053/bugfix
fix: check whether the package is installed by importing package
2 parents 7db9efb + 1cf7c48 commit e2433c1

4 files changed

Lines changed: 9 additions & 10 deletions

File tree

funppy/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = '0.4.8'
1+
__version__ = '0.4.9'
22

33
from funppy.plugin import register, serve
44

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "funppy"
3-
version = "0.4.8"
3+
version = "0.4.9"
44
description = "Python plugin over gRPC for funplugin"
55
license = "Apache-2.0"
66
authors = ["debugtalk <mail@debugtalk.com>"]

shared/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"github.com/hashicorp/go-plugin"
55
)
66

7-
const Version = "v0.4.8"
7+
const Version = "v0.4.9"
88

99
// PluginTypeEnvName is used to specify hashicorp go plugin type, rpc/grpc
1010
const PluginTypeEnvName = "HRP_PLUGIN_TYPE"

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)