Files
admin e6956aa001 Initial commit: TaskPool React panel
- React frontend with route-level code splitting
- Backend rebranded from Baihu to TaskPool
- DB brand migration script and local compatibility
2026-07-26 08:43:52 +08:00

48 lines
1.1 KiB
Go

package deps
import (
"strings"
"github.com/engigu/taskpool/internal/logger"
"github.com/engigu/taskpool/internal/models"
)
type PythonManager struct {
BaseManager
}
func NewPythonManager(language string) *PythonManager {
return &PythonManager{
BaseManager: BaseManager{
Language: language,
InstallCmd: []string{"pip", "install"},
UninstallCmd: []string{"pip", "uninstall", "-y"},
ListCmd: []string{"pip", "list", "--format=freeze"},
Separator: "==",
},
}
}
func (m *PythonManager) GetInstalledPackages(language, langVersion string) ([]models.Dependency, error) {
output, err := m.runMiseCommand(langVersion, m.ListCmd)
if err != nil {
logger.Warnf("GetInstalledPackages for %s failed: %v", language, err)
}
var packages []models.Dependency
lines := strings.Split(string(output), "\n")
for _, line := range lines {
line = strings.TrimSpace(line)
if line == "" {
continue
}
parts := strings.SplitN(line, "==", 2)
pkg := models.Dependency{Name: parts[0], Language: language}
if len(parts) > 1 {
pkg.Version = parts[1]
}
packages = append(packages, pkg)
}
return packages, nil
}