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

Side by Side Diff: vpython/venv/venv.go

Issue 2927573002: [vpython] Fix PEP425 naming. (Closed)
Patch Set: rebase and update 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 unified diff | Download patch
« no previous file with comments | « vpython/spec/spec_test.go ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 venv 5 package venv
6 6
7 import ( 7 import (
8 "bytes" 8 "bytes"
9 "encoding/json" 9 "encoding/json"
10 "io/ioutil" 10 "io/ioutil"
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 if err := cmd.Run(); err != nil { 559 if err := cmd.Run(); err != nil {
560 return errors.Annotate(err).Reason("failed to create VirtualEnv" ).Err() 560 return errors.Annotate(err).Reason("failed to create VirtualEnv" ).Err()
561 } 561 }
562 562
563 return nil 563 return nil
564 } 564 }
565 565
566 // getPEP425Tags calls Python's pip.pep425tags package to retrieve the tags. 566 // getPEP425Tags calls Python's pip.pep425tags package to retrieve the tags.
567 // 567 //
568 // This must be run while "pip" is installed in the VirtualEnv. 568 // This must be run while "pip" is installed in the VirtualEnv.
569 func (e *Env) getPEP425Tags(c context.Context) ([]*vpython.Pep425Tag, error) { 569 func (e *Env) getPEP425Tags(c context.Context) ([]*vpython.PEP425Tag, error) {
570 // This script will return a list of 3-entry lists: 570 // This script will return a list of 3-entry lists:
571 // [0]: version (e.g., "cp27") 571 // [0]: version (e.g., "cp27")
572 // [1]: abi (e.g., "cp27mu", "none") 572 // [1]: abi (e.g., "cp27mu", "none")
573 // [2]: arch (e.g., "x86_64", "armv7l", "any") 573 // [2]: arch (e.g., "x86_64", "armv7l", "any")
574 const script = `import json;` + 574 const script = `import json;` +
575 `import pip.pep425tags;` + 575 `import pip.pep425tags;` +
576 `import sys;` + 576 `import sys;` +
577 `sys.stdout.write(json.dumps(pip.pep425tags.get_supported()))` 577 `sys.stdout.write(json.dumps(pip.pep425tags.get_supported()))`
578 type pep425TagEntry []string 578 type pep425TagEntry []string
579 579
580 cmd := e.Interpreter().IsolatedCommand(c, "-c", script) 580 cmd := e.Interpreter().IsolatedCommand(c, "-c", script)
581 581
582 var stdout bytes.Buffer 582 var stdout bytes.Buffer
583 cmd.Stdout = &stdout 583 cmd.Stdout = &stdout
584 584
585 attachOutputForLogging(c, logging.Debug, cmd) 585 attachOutputForLogging(c, logging.Debug, cmd)
586 if err := cmd.Run(); err != nil { 586 if err := cmd.Run(); err != nil {
587 return nil, errors.Annotate(err).Reason("failed to get PEP425 ta gs").Err() 587 return nil, errors.Annotate(err).Reason("failed to get PEP425 ta gs").Err()
588 } 588 }
589 589
590 var tagEntries []pep425TagEntry 590 var tagEntries []pep425TagEntry
591 if err := json.Unmarshal(stdout.Bytes(), &tagEntries); err != nil { 591 if err := json.Unmarshal(stdout.Bytes(), &tagEntries); err != nil {
592 return nil, errors.Annotate(err).Reason("failed to unmarshal PEP 425 tag output: %(output)s"). 592 return nil, errors.Annotate(err).Reason("failed to unmarshal PEP 425 tag output: %(output)s").
593 D("output", stdout.String()). 593 D("output", stdout.String()).
594 Err() 594 Err()
595 } 595 }
596 596
597 » tags := make([]*vpython.Pep425Tag, len(tagEntries)) 597 » tags := make([]*vpython.PEP425Tag, len(tagEntries))
598 for i, te := range tagEntries { 598 for i, te := range tagEntries {
599 if len(te) != 3 { 599 if len(te) != 3 {
600 return nil, errors.Reason("invalid PEP425 tag entry: %(e ntry)v"). 600 return nil, errors.Reason("invalid PEP425 tag entry: %(e ntry)v").
601 D("entry", te). 601 D("entry", te).
602 D("index", i). 602 D("index", i).
603 Err() 603 Err()
604 } 604 }
605 605
606 » » tags[i] = &vpython.Pep425Tag{ 606 » » tags[i] = &vpython.PEP425Tag{
607 » » » Version: te[0], 607 » » » Python: te[0],
608 » » » Abi: te[1], 608 » » » Abi: te[1],
609 » » » Arch: te[2], 609 » » » Platform: te[2],
610 } 610 }
611 } 611 }
612 612
613 // If we're Debug-logging, calculate and display the tags that were prob ed. 613 // If we're Debug-logging, calculate and display the tags that were prob ed.
614 if logging.IsLogging(c, logging.Debug) { 614 if logging.IsLogging(c, logging.Debug) {
615 tagStr := make([]string, len(tags)) 615 tagStr := make([]string, len(tags))
616 for i, t := range tags { 616 for i, t := range tags {
617 tagStr[i] = t.TagString() 617 tagStr[i] = t.TagString()
618 } 618 }
619 logging.Debugf(c, "Loaded PEP425 tags: [%s]", strings.Join(tagSt r, ", ")) 619 logging.Debugf(c, "Loaded PEP425 tags: [%s]", strings.Join(tagSt r, ", "))
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 // panic, since the locking state can no longer be determined. 772 // panic, since the locking state can no longer be determined.
773 func mustReleaseLock(c context.Context, lock fslock.Handle, fn func() error) err or { 773 func mustReleaseLock(c context.Context, lock fslock.Handle, fn func() error) err or {
774 defer func() { 774 defer func() {
775 if err := lock.Unlock(); err != nil { 775 if err := lock.Unlock(); err != nil {
776 errors.Log(c, errors.Annotate(err).Reason("failed to rel ease lock").Err()) 776 errors.Log(c, errors.Annotate(err).Reason("failed to rel ease lock").Err())
777 panic(err) 777 panic(err)
778 } 778 }
779 }() 779 }()
780 return fn() 780 return fn()
781 } 781 }
OLDNEW
« no previous file with comments | « vpython/spec/spec_test.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698