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

Unified Diff: vpython/application/subcommand_verify.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/api/vpython/spec.pb.go ('k') | vpython/spec/match.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: vpython/application/subcommand_verify.go
diff --git a/vpython/application/subcommand_verify.go b/vpython/application/subcommand_verify.go
index b9c3e43abe278c302a94f8fbe4fc85594c428e78..08998af7df35f8fd57bdb6c5d641d2cd617194aa 100644
--- a/vpython/application/subcommand_verify.go
+++ b/vpython/application/subcommand_verify.go
@@ -42,13 +42,21 @@ func (cr *verifyCommandRun) Run(app subcommands.Application, args []string, env
if err := a.opts.ResolveSpec(c); err != nil {
return errors.Annotate(err).Reason("failed to resolve specification").Err()
}
- if a.opts.EnvConfig.Spec.Virtualenv == nil {
- a.opts.EnvConfig.Spec.Virtualenv = &a.opts.EnvConfig.Package
+
+ s := a.opts.EnvConfig.Spec
+ if s == nil {
+ s = &vpython.Spec{}
}
- if err := spec.NormalizeSpec(a.opts.EnvConfig.Spec); err != nil {
+ if s.Virtualenv == nil {
+ s.Virtualenv = &a.opts.EnvConfig.Package
+ }
+
+ // Verify that the spec can be normalized. This may modify it, so we will
+ // normalize a clone.
+ if err := spec.NormalizeSpec(s.Clone(), nil); err != nil {
return errors.Annotate(err).Reason("failed to normalize specification").Err()
}
- s := a.opts.EnvConfig.Spec
+
renderedSpec := spec.Render(s)
logging.Infof(c, "Successfully verified specification:\n%s", renderedSpec)
@@ -69,6 +77,11 @@ func (cr *verifyCommandRun) Run(app subcommands.Application, args []string, env
Spec: s.Clone(),
Pep425Tag: []*vpython.Pep425Tag{vs},
}
+ if err := spec.NormalizeEnvironment(&e); err != nil {
+ logging.Errorf(c, "Failed to normalize environment against %q: %s", vs.TagString(), err)
+ failures = append(failures, vs.TagString())
+ continue
+ }
if err := cfg.PackageLoader.Resolve(c, &e); err != nil {
logging.Errorf(c, "Failed to resolve against %q: %s", vs.TagString(), err)
« no previous file with comments | « vpython/api/vpython/spec.pb.go ('k') | vpython/spec/match.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698