Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(133)

Unified Diff: vpython/spec/spec.go

Issue 2921133002: [vpython] Add conditional packages based on PEP425 (Closed)
Patch Set: rebase Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « vpython/spec/match_test.go ('k') | vpython/spec/spec_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: vpython/spec/spec.go
diff --git a/vpython/spec/spec.go b/vpython/spec/spec.go
index 97abe5a416423c0c3168657c87a6ee5f3bb28524..1f8fa80f4cabbe1196e289baa2257e79504c6f0e 100644
--- a/vpython/spec/spec.go
+++ b/vpython/spec/spec.go
@@ -27,7 +27,7 @@ func NormalizeEnvironment(env *vpython.Environment) error {
if env.Spec == nil {
env.Spec = &vpython.Spec{}
}
- if err := NormalizeSpec(env.Spec); err != nil {
+ if err := NormalizeSpec(env.Spec, env.Pep425Tag); err != nil {
return err
}
@@ -41,7 +41,29 @@ func NormalizeEnvironment(env *vpython.Environment) error {
// NormalizeSpec normalizes the specification Message such that two messages
// with identical meaning will have identical representation.
-func NormalizeSpec(spec *vpython.Spec) error {
+//
+// NormalizeSpec will prune any Wheel entries that don't match the specified
+// tags, and will remove the match entries from any remaining Wheel entries.
+func NormalizeSpec(spec *vpython.Spec, tags []*vpython.Pep425Tag) error {
+ if spec.Virtualenv != nil && len(spec.Virtualenv.MatchTag) > 0 {
+ // The VirtualEnv package may not specify a match tag.
+ spec.Virtualenv.MatchTag = nil
+ }
+
+ // Apply match filters, prune any entries that don't match, and clear the
+ // MatchTag entries for those that do.
+ pos := 0
+ for _, wheel := range spec.Wheel {
+ if !PackageMatches(wheel, tags) {
+ continue
+ }
+
+ wheel.MatchTag = nil
+ spec.Wheel[pos] = wheel
+ pos++
+ }
+ spec.Wheel = spec.Wheel[:pos]
+
sort.Sort(specPackageSlice(spec.Wheel))
// No duplicate packages. Since we're sorted, we can just check for no
« no previous file with comments | « vpython/spec/match_test.go ('k') | vpython/spec/spec_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698