@@ -44,8 +44,16 @@ func InstallTool(name string, toolInfo *plugins.ToolInfo) error {
4444 return installDownloadBasedTool (toolInfo )
4545 }
4646
47- // This is a runtime-based tool, proceed with regular installation
47+ // Handle Python tools differently
48+ if toolInfo .Runtime == "python" {
49+ return installPythonTool (name , toolInfo )
50+ }
51+
52+ // Handle other runtime-based tools
53+ return installRuntimeTool (name , toolInfo )
54+ }
4855
56+ func installRuntimeTool (name string , toolInfo * plugins.ToolInfo ) error {
4957 // Get the runtime for this tool
5058 runtimeInfo , ok := Config .Runtimes ()[toolInfo .Runtime ]
5159 if ! ok {
@@ -159,6 +167,38 @@ func installDownloadBasedTool(toolInfo *plugins.ToolInfo) error {
159167 return nil
160168}
161169
170+ func installPythonTool (name string , toolInfo * plugins.ToolInfo ) error {
171+ log .Printf ("Installing %s v%s...\n " , toolInfo .Name , toolInfo .Version )
172+
173+ runtimeInfo , ok := Config .Runtimes ()[toolInfo .Runtime ]
174+ if ! ok {
175+ return fmt .Errorf ("required runtime %s not found for tool %s" , toolInfo .Runtime , name )
176+ }
177+
178+ pythonBinary , ok := runtimeInfo .Binaries ["python3" ]
179+ if ! ok {
180+ return fmt .Errorf ("python3 binary not found in runtime" )
181+ }
182+
183+ // Create venv
184+ cmd := exec .Command (pythonBinary , "-m" , "venv" , filepath .Join (toolInfo .InstallDir , "venv" ))
185+ output , err := cmd .CombinedOutput ()
186+ if err != nil {
187+ return fmt .Errorf ("failed to create venv: %s\n Error: %w" , string (output ), err )
188+ }
189+
190+ // Install the tool using pip from venv
191+ pipPath := filepath .Join (toolInfo .InstallDir , "venv" , "bin" , "pip" )
192+ cmd = exec .Command (pipPath , "install" , fmt .Sprintf ("%s==%s" , toolInfo .Name , toolInfo .Version ))
193+ output , err = cmd .CombinedOutput ()
194+ if err != nil {
195+ return fmt .Errorf ("failed to install tool: %s\n Error: %w" , string (output ), err )
196+ }
197+
198+ log .Printf ("Successfully installed %s v%s\n " , toolInfo .Name , toolInfo .Version )
199+ return nil
200+ }
201+
162202// isToolInstalled checks if a tool is already installed by checking for the binary
163203func isToolInstalled (toolInfo * plugins.ToolInfo ) bool {
164204 // If there are no binaries, check the install directory
0 commit comments