mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-27 11:20:08 +08:00
change: venv priority: specified > /Users/debugtalk/.hrp/venv
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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{
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user