| OLD | NEW |
| 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 application | 5 package application |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "flag" | 8 "flag" |
| 9 "fmt" | 9 "fmt" |
| 10 "io/ioutil" | 10 "io/ioutil" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 type VerificationFunc func(context.Context, string, venv.PackageLoader, *vpython
API.Environment) | 63 type VerificationFunc func(context.Context, string, venv.PackageLoader, *vpython
API.Environment) |
| 64 | 64 |
| 65 // Config is an application's default configuration. | 65 // Config is an application's default configuration. |
| 66 type Config struct { | 66 type Config struct { |
| 67 // PackageLoader is the package loader to use. | 67 // PackageLoader is the package loader to use. |
| 68 PackageLoader venv.PackageLoader | 68 PackageLoader venv.PackageLoader |
| 69 | 69 |
| 70 // VENVPackage is the VirtualEnv package to use for bootstrap generation
. | 70 // VENVPackage is the VirtualEnv package to use for bootstrap generation
. |
| 71 VENVPackage vpythonAPI.Spec_Package | 71 VENVPackage vpythonAPI.Spec_Package |
| 72 | 72 |
| 73 // BaseWheels is the set of wheels to include in the spec. These will al
ways |
| 74 // be merged into the runtime spec and normalized, such that any duplica
te |
| 75 // wheels will be deduplicated. |
| 76 BaseWheels []*vpythonAPI.Spec_Package |
| 77 |
| 73 // RelativePathOverride is a series of forward-slash-delimited paths to | 78 // RelativePathOverride is a series of forward-slash-delimited paths to |
| 74 // directories relative to the "vpython" executable that will be checked | 79 // directories relative to the "vpython" executable that will be checked |
| 75 // for Python targets prior to checking PATH. This allows bundles (e.g.,
CIPD) | 80 // for Python targets prior to checking PATH. This allows bundles (e.g.,
CIPD) |
| 76 // that include both the wrapper and a real implementation, to force the | 81 // that include both the wrapper and a real implementation, to force the |
| 77 // wrapper to use the bundled implementation if present. | 82 // wrapper to use the bundled implementation if present. |
| 78 // | 83 // |
| 79 // See "github.com/luci/luci-go/common/wrapper/prober.Probe"'s | 84 // See "github.com/luci/luci-go/common/wrapper/prober.Probe"'s |
| 80 // RelativePathOverride member for more information. | 85 // RelativePathOverride member for more information. |
| 81 RelativePathOverride []string | 86 RelativePathOverride []string |
| 82 | 87 |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 logging.WithError(err).Warningf(c, "Failed to resolve 'self'") | 199 logging.WithError(err).Warningf(c, "Failed to resolve 'self'") |
| 195 } | 200 } |
| 196 a.opts.EnvConfig.LookPathFunc = lp.look | 201 a.opts.EnvConfig.LookPathFunc = lp.look |
| 197 | 202 |
| 198 if a.help { | 203 if a.help { |
| 199 return a.showPythonHelp(c, fs, &lp) | 204 return a.showPythonHelp(c, fs, &lp) |
| 200 } | 205 } |
| 201 | 206 |
| 202 c = a.logConfig.Set(c) | 207 c = a.logConfig.Set(c) |
| 203 | 208 |
| 204 » // If an spec path was manually specified, load and use it. | 209 » // If a spec path was manually specified, load and use it. |
| 205 if a.specPath != "" { | 210 if a.specPath != "" { |
| 206 var sp vpythonAPI.Spec | 211 var sp vpythonAPI.Spec |
| 207 if err := spec.Load(a.specPath, &sp); err != nil { | 212 if err := spec.Load(a.specPath, &sp); err != nil { |
| 208 return err | 213 return err |
| 209 } | 214 } |
| 210 a.opts.EnvConfig.Spec = &sp | 215 a.opts.EnvConfig.Spec = &sp |
| 211 } else if specPath := a.opts.Environ.GetEmpty(DefaultSpecENV); specPath
!= "" { | 216 } else if specPath := a.opts.Environ.GetEmpty(DefaultSpecENV); specPath
!= "" { |
| 212 if err := spec.Load(specPath, &a.opts.DefaultSpec); err != nil { | 217 if err := spec.Load(specPath, &a.opts.DefaultSpec); err != nil { |
| 213 return errors.Annotate(err, "failed to load default spec
ification file (%s) from %s", | 218 return errors.Annotate(err, "failed to load default spec
ification file (%s) from %s", |
| 214 DefaultSpecENV, specPath).Err() | 219 DefaultSpecENV, specPath).Err() |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 opts: vpython.Options{ | 301 opts: vpython.Options{ |
| 297 EnvConfig: venv.Config{ | 302 EnvConfig: venv.Config{ |
| 298 BaseDir: "", // (Determined below). | 303 BaseDir: "", // (Determined below). |
| 299 MaxHashLen: 6, | 304 MaxHashLen: 6, |
| 300 Package: cfg.VENVPackage, | 305 Package: cfg.VENVPackage, |
| 301 PruneThreshold: cfg.PruneThreshold, | 306 PruneThreshold: cfg.PruneThreshold, |
| 302 MaxPrunesPerSweep: cfg.MaxPrunesPerSweep, | 307 MaxPrunesPerSweep: cfg.MaxPrunesPerSweep, |
| 303 MaxScriptPathLen: cfg.MaxScriptPathLen, | 308 MaxScriptPathLen: cfg.MaxScriptPathLen, |
| 304 Loader: cfg.PackageLoader, | 309 Loader: cfg.PackageLoader, |
| 305 }, | 310 }, |
| 311 BaseWheels: cfg.BaseWheels, |
| 306 WaitForEnv: true, | 312 WaitForEnv: true, |
| 307 Environ: env, | 313 Environ: env, |
| 308 }, | 314 }, |
| 309 logConfig: logging.Config{ | 315 logConfig: logging.Config{ |
| 310 Level: logging.Error, | 316 Level: logging.Error, |
| 311 }, | 317 }, |
| 312 } | 318 } |
| 313 | 319 |
| 314 return run(c, func(c context.Context) error { | 320 return run(c, func(c context.Context) error { |
| 315 return a.mainImpl(c, os.Args[0], os.Args[1:]) | 321 return a.mainImpl(c, os.Args[0], os.Args[1:]) |
| 316 }) | 322 }) |
| 317 } | 323 } |
| OLD | NEW |