@@ -61,9 +61,14 @@ func (a PipAnalyzer) getPackages(image pkgutil.Image) (map[string]map[string]uti
61
61
return packages , nil
62
62
}
63
63
64
+ // default python package installation directories in unix
65
+ // these are hardcoded in the python source; unfortunately no way to retrieve them from env
64
66
for _ , pythonVersion := range pythonVersions {
65
- packagesPath := filepath .Join (path , "usr/local/lib" , pythonVersion , "site-packages" )
66
- pythonPaths = append (pythonPaths , packagesPath )
67
+ pythonPaths = append (pythonPaths , filepath .Join (path , "usr/lib" , pythonVersion ))
68
+ pythonPaths = append (pythonPaths , filepath .Join (path , "usr/lib" , pythonVersion , "dist-packages" ))
69
+ pythonPaths = append (pythonPaths , filepath .Join (path , "usr/lib" , pythonVersion , "site-packages" ))
70
+ pythonPaths = append (pythonPaths , filepath .Join (path , "usr/local/lib" , pythonVersion , "dist-packages" ))
71
+ pythonPaths = append (pythonPaths , filepath .Join (path , "usr/local/lib" , pythonVersion , "site-packages" ))
67
72
}
68
73
69
74
for _ , pythonPath := range pythonPaths {
@@ -77,7 +82,7 @@ func (a PipAnalyzer) getPackages(image pkgutil.Image) (map[string]map[string]uti
77
82
c := contents [i ]
78
83
fileName := c .Name ()
79
84
// check if package
80
- packageDir := regexp .MustCompile ("^([a-z|A-Z|0-9|_]+)-(([0-9]+?\\ .){2,3})dist-info$" )
85
+ packageDir := regexp .MustCompile ("^([a-z|A-Z|0-9|_]+)-(([0-9]+?\\ .){2,3})( dist-info|egg-info) $" )
81
86
packageMatch := packageDir .FindStringSubmatch (fileName )
82
87
if len (packageMatch ) != 0 {
83
88
packageName := packageMatch [1 ]
@@ -91,7 +96,6 @@ func (a PipAnalyzer) getPackages(image pkgutil.Image) (map[string]map[string]uti
91
96
size = pkgutil .GetSize (packagePath )
92
97
} else if i + 1 < len (contents ) && contents [i + 1 ].Name () == packageName + ".py" {
93
98
size = contents [i + 1 ].Size ()
94
-
95
99
} else {
96
100
glog .Errorf ("Could not find Python package %s for corresponding metadata info" , packageName )
97
101
continue
0 commit comments