github.com/jfrog/build-info-go@v1.9.26/utils/pythonutils/pipenvutils.go (about) 1 package pythonutils 2 3 import ( 4 "encoding/json" 5 6 "github.com/jfrog/gofrog/io" 7 ) 8 9 // Executes pipenv graph. 10 // Returns a dependency map of all the installed pipenv packages in the current environment and also another list of the top level dependencies 11 // 'dependenciesGraph' - map between all parent modules and their child dependencies 12 // 'topLevelPackagesList' - list of all top level dependencies ( root dependencies only) 13 func getPipenvDependencies(srcPath string) (dependenciesGraph map[string][]string, topLevelDependencies []string, err error) { 14 // Run pipenv graph 15 pipenvGraphCmd := io.NewCommand("pipenv", "graph", []string{"--json"}) 16 pipenvGraphCmd.Dir = srcPath 17 output, err := pipenvGraphCmd.RunWithOutput() 18 if err != nil { 19 return 20 } 21 // Parse into array. 22 packages := make([]pythonDependencyPackage, 0) 23 err = json.Unmarshal(output, &packages) 24 if err != nil { 25 return 26 } 27 dependenciesGraph, topLevelDependencies, err = parseDependenciesToGraph(packages) 28 return 29 }