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

Side by Side Diff: vpython/options.go

Issue 2971403002: [vpython] Enable base wheels, spec merging. (Closed)
Patch Set: Created 3 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The LUCI Authors. All rights reserved. 1 // Copyright 2017 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 package vpython 5 package vpython
6 6
7 import ( 7 import (
8 "os" 8 "os"
9 9
10 "golang.org/x/net/context" 10 "golang.org/x/net/context"
(...skipping 12 matching lines...) Expand all
23 // Options is the set of options to use to construct and execute a VirtualEnv 23 // Options is the set of options to use to construct and execute a VirtualEnv
24 // Python application. 24 // Python application.
25 type Options struct { 25 type Options struct {
26 // EnvConfig is the VirtualEnv configuration to run from. 26 // EnvConfig is the VirtualEnv configuration to run from.
27 EnvConfig venv.Config 27 EnvConfig venv.Config
28 28
29 // DefaultSpec is the default specification to use, if no specification was 29 // DefaultSpec is the default specification to use, if no specification was
30 // supplied or probed. 30 // supplied or probed.
31 DefaultSpec vpython.Spec 31 DefaultSpec vpython.Spec
32 32
33 // BaseWheels is the set of wheels to include in the spec. These will al ways
34 // be merged into the runtime spec and normalized, such that any duplica te
35 // wheels will be deduplicated.
36 BaseWheels []*vpython.Spec_Package
37
33 // SpecLoader is the spec.Loader to use to load a specification file for a 38 // SpecLoader is the spec.Loader to use to load a specification file for a
34 // given script. 39 // given script.
35 // 40 //
36 // The empty value is a valid default spec.Loader. 41 // The empty value is a valid default spec.Loader.
37 SpecLoader spec.Loader 42 SpecLoader spec.Loader
38 43
39 // Args are the arguments to forward to the Python process. 44 // Args are the arguments to forward to the Python process.
40 Args []string 45 Args []string
41 46
42 // WaitForEnv, if true, means that if another agent holds a lock on the target 47 // WaitForEnv, if true, means that if another agent holds a lock on the target
(...skipping 22 matching lines...) Expand all
65 o.WorkDir = wd 70 o.WorkDir = wd
66 } 71 }
67 if err := filesystem.AbsPath(&o.WorkDir); err != nil { 72 if err := filesystem.AbsPath(&o.WorkDir); err != nil {
68 return errors.Annotate(err, "failed to resolve absolute path of WorkDir").Err() 73 return errors.Annotate(err, "failed to resolve absolute path of WorkDir").Err()
69 } 74 }
70 75
71 // Resolve our target python script. 76 // Resolve our target python script.
72 if err := o.ResolveSpec(c); err != nil { 77 if err := o.ResolveSpec(c); err != nil {
73 return errors.Annotate(err, "failed to resolve Python script").E rr() 78 return errors.Annotate(err, "failed to resolve Python script").E rr()
74 } 79 }
80 if len(o.BaseWheels) > 0 {
81 o.EnvConfig.Spec = o.EnvConfig.Spec.Clone()
82 o.EnvConfig.Spec.Wheel = append(o.EnvConfig.Spec.Wheel, o.BaseWh eels...)
83 }
75 84
76 // If no environment base directory was supplied, create one under the c urrent 85 // If no environment base directory was supplied, create one under the c urrent
77 // working directory. 86 // working directory.
78 if o.EnvConfig.BaseDir == "" { 87 if o.EnvConfig.BaseDir == "" {
79 // Is one specified in our environment? 88 // Is one specified in our environment?
80 if v, ok := o.Environ.Get(EnvironmentStampPathENV); ok { 89 if v, ok := o.Environ.Get(EnvironmentStampPathENV); ok {
81 var err error 90 var err error
82 if o.EnvConfig.BaseDir, err = venv.EnvRootFromStampPath( v); err != nil { 91 if o.EnvConfig.BaseDir, err = venv.EnvRootFromStampPath( v); err != nil {
83 return errors.Annotate(err, "failed to get env r oot from environment: %s", v).Err() 92 return errors.Annotate(err, "failed to get env r oot from environment: %s", v).Err()
84 } 93 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 logging.Infof(c, "Loaded spec from environment: %s", v) 158 logging.Infof(c, "Loaded spec from environment: %s", v)
150 o.EnvConfig.Spec = &sp 159 o.EnvConfig.Spec = &sp
151 return nil 160 return nil
152 } 161 }
153 162
154 // If standard resolution doesn't yield a spec, fall back on our default spec. 163 // If standard resolution doesn't yield a spec, fall back on our default spec.
155 logging.Infof(c, "Unable to resolve specification path. Using default sp ecification.") 164 logging.Infof(c, "Unable to resolve specification path. Using default sp ecification.")
156 o.EnvConfig.Spec = &o.DefaultSpec 165 o.EnvConfig.Spec = &o.DefaultSpec
157 return nil 166 return nil
158 } 167 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698