diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 60611491..db8a18f8 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,11 +1,10 @@ # Release History -## v4.1.3 (2022-06-13) +## v4.1.3 (2022-06-14) **go version** -- feat #1342: support specify custom python3 venv -- feat: support python3 venv priority, specified > projectDir/.venv > $HOME/.hrp/venv +- feat #1342: support specify custom python3 venv, priority is greater than $HOME/.hrp/venv - feat: assert python3 package is ready with specified version - refactor: build plugin mechanism, cancel automatic installation of dependencies - fix: pip upgrade httprunner when installing hrp diff --git a/hrp/internal/builtin/utils.go b/hrp/internal/builtin/utils.go index c8d8fcc0..f145989c 100644 --- a/hrp/internal/builtin/utils.go +++ b/hrp/internal/builtin/utils.go @@ -178,7 +178,7 @@ func InstallPythonPackage(python3 string, pkg string) (err error) { return errors.Wrap(err, "pip is not available") } - log.Info().Str("package", pkg).Msg("installing python package") + log.Info().Str("pkgName", pkgName).Str("pkgVersion", pkgVersion).Msg("installing python package") // install package err = ExecCommand(python3, "-m", "pip", "install", "--upgrade", pkg, diff --git a/hrp/internal/scaffold/main.go b/hrp/internal/scaffold/main.go index 46e21b76..59557128 100644 --- a/hrp/internal/scaffold/main.go +++ b/hrp/internal/scaffold/main.go @@ -8,10 +8,10 @@ import ( "path/filepath" "time" + "github.com/httprunner/funplugin/fungo" "github.com/pkg/errors" "github.com/rs/zerolog/log" - "github.com/httprunner/funplugin/fungo" "github.com/httprunner/httprunner/v4/hrp" "github.com/httprunner/httprunner/v4/hrp/internal/builtin" "github.com/httprunner/httprunner/v4/hrp/internal/sdk" @@ -206,7 +206,11 @@ func createPythonPlugin(projectName, venv string) error { } if venv == "" { - venv = filepath.Join(projectName, ".venv") + home, err := os.UserHomeDir() + if err != nil { + return errors.Wrap(err, "get user home dir failed") + } + venv = filepath.Join(home, ".hrp", "venv") } log.Info().Str("venv", venv).Msg("create python3 venv") packages := []string{ diff --git a/hrp/plugin.go b/hrp/plugin.go index 2af298c3..bc7d0241 100644 --- a/hrp/plugin.go +++ b/hrp/plugin.go @@ -49,10 +49,7 @@ func initPlugin(path, venv string, logOn bool) (plugin funplugin.IPlugin, err er } pluginPath = genPyPluginPath - // priority: specified > projectDir/.venv > $HOME/.hrp/venv - if venv == "" && builtin.IsFolderPathExists(filepath.Join(filepath.Dir(pluginPath), ".venv")) { - venv = filepath.Join(filepath.Dir(pluginPath), ".venv") - } + // priority: specified > $HOME/.hrp/venv err = builtin.PrepareVenv(venv) if err != nil { log.Error().Err(err).Msg("prepare python3 venv failed")