@@ -64,6 +64,7 @@ var removePatterns = []glob.Glob{
64
64
glob .MustCompile ("**.pdb" ),
65
65
glob .MustCompile ("**.pyc" ),
66
66
glob .MustCompile ("**/test_*.py" ),
67
+ glob .MustCompile ("**/*.dist-info" ),
67
68
}
68
69
69
70
var keepNixPatterns = []glob.Glob {
@@ -124,23 +125,31 @@ func downloadAndCopy(osName string, arch string, out string, keepPatterns []glob
124
125
125
126
extract (downloadPath , extractPath )
126
127
128
+ installPath := filepath .Join (extractPath , "python" , "install" )
129
+
130
+ var libPath string
131
+ if osName == "windows" {
132
+ libPath = filepath .Join (installPath , "Lib" )
133
+ } else {
134
+ libPath = filepath .Join (installPath , "lib" , fmt .Sprintf ("python%s" , pythonVersionBase ))
135
+ }
136
+
137
+ pipInstallRequirements (libPath , "requirements.txt" )
138
+
127
139
var removes []string
128
140
129
141
for _ , lib := range removeLibs {
130
- removes = append (removes , filepath .Join ("lib" , fmt .Sprintf ("python%s" , pythonVersionBase ), lib ))
131
- removes = append (removes , filepath .Join ("Lib" , lib ))
142
+ removes = append (removes , filepath .Join (libPath , lib ))
132
143
}
133
144
134
- installPath := filepath .Join (extractPath , "python" , "install" )
135
-
136
145
err = filepath .Walk (installPath , func (path string , info fs.FileInfo , err error ) error {
137
146
relPath , err := filepath .Rel (installPath , path )
138
147
if err != nil {
139
148
log .Panic (err )
140
149
}
141
150
for _ , p := range removePatterns {
142
- if p .Match (path ) {
143
- removes = append (removes , relPath )
151
+ if p .Match (relPath ) {
152
+ removes = append (removes , path )
144
153
}
145
154
}
146
155
if ! info .Mode ().IsDir () {
@@ -152,7 +161,7 @@ func downloadAndCopy(osName string, arch string, out string, keepPatterns []glob
152
161
}
153
162
}
154
163
if ! keep {
155
- removes = append (removes , relPath )
164
+ removes = append (removes , path )
156
165
}
157
166
}
158
167
return nil
@@ -162,7 +171,7 @@ func downloadAndCopy(osName string, arch string, out string, keepPatterns []glob
162
171
}
163
172
164
173
for _ , r := range removes {
165
- _ = os .RemoveAll (filepath . Join ( installPath , r ) )
174
+ _ = os .RemoveAll (r )
166
175
}
167
176
168
177
err = removeEmptyDirs (installPath )
0 commit comments