Skip to content

Commit

Permalink
Revert "vpython: use realpath when invoking virtualenv"
Browse files Browse the repository at this point in the history
This reverts commit 988aaae.

Reason for revert: Change is breaking luci-go to infra autoroller. https://ci.chromium.org/ui/p/infra/builders/try/infra-try-jammy-64/b8750527694180069633/overview

Original change's description:
> vpython: use realpath when invoking virtualenv
>
> Use realpath for virtualenv.pyz to mitigate pypa/virtualenv#1949
>
> Change-Id: I4ddfb78bc435f9791ccae5e87cf5c0da404a110a
> Reviewed-on: https://chromium-review.googlesource.com/c/infra/luci/luci-go/+/5449147
> Reviewed-by: Brian Ryner <bryner@google.com>
> Commit-Queue: Chenlin Fan <fancl@chromium.org>
> Auto-Submit: Chenlin Fan <fancl@chromium.org>

Change-Id: I37d27f0fd80d93f722ed000985fa5b95f51c8c6d
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/infra/luci/luci-go/+/5458911
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Auto-Submit: Randy Maldonado <randymaldonado@google.com>
  • Loading branch information
randymaldonado authored and LUCI CQ committed Apr 16, 2024
1 parent f0b372e commit 7f1070f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 38 deletions.
2 changes: 1 addition & 1 deletion vpython/application/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func (a *Application) ParseEnvs(ctx context.Context) (err error) {
// Determine our VirtualEnv base directory.
if v, ok := e.Lookup(VirtualEnvRootENV); ok {
a.VpythonRoot = v
} else if a.VpythonRoot == "" {
} else {
cdir, err := a.userCacheDir()
if err != nil {
logging.Infof(ctx, "failed to get user cache dir: %s", err)
Expand Down
30 changes: 5 additions & 25 deletions vpython/application/application_py3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"os"
"os/exec"
"path/filepath"
"runtime"
"strings"
"testing"

Expand Down Expand Up @@ -59,9 +58,11 @@ func getPythonEnvironment(ver string) *python.Environment {
}

func setupApp(ctx context.Context, app *Application) context.Context {
if app.VpythonRoot == "" {
app.VpythonRoot = testStorageDir
}
app.Arguments = append([]string{
"-vpython-root",
testStorageDir,
}, app.Arguments...)

app.Initialize(ctx)

So(app.ParseEnvs(ctx), ShouldBeNil)
Expand Down Expand Up @@ -165,27 +166,6 @@ func TestPythonBasic(t *testing.T) {
So(has, ShouldBeTrue)
So(rc, ShouldEqual, 42)
})

if runtime.GOOS != "windows" {
// See https://github.com/pypa/virtualenv/issues/1949
Convey("Test symlink root", func() {
symlinkRoot := filepath.Join(t.TempDir(), "link")
err := os.Symlink(testStorageDir, symlinkRoot)
So(err, ShouldBeNil)

c := cmd(t, &Application{
Arguments: []string{
"-vpython-spec",
testData("default.vpython3"),
"-c",
"print(123)",
},
VpythonRoot: symlinkRoot,
}, env)

So(output(c), ShouldEqual, "123")
})
}
})
}
})
Expand Down
16 changes: 4 additions & 12 deletions vpython/python/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import os
import subprocess
import sys
import tempfile

if sys.version_info[0] > 2:
ISOLATION_FLAG = '-I'
Expand All @@ -28,17 +27,10 @@
# Create virtual environment in ${out} directory
virtualenv = glob.glob(
os.path.join(os.environ['virtualenv'], '*', 'virtualenv.py*'))[0]

with tempfile.TemporaryDirectory() as d:
args = [
sys.executable, '-B', ISOLATION_FLAG,
# Use realpath to mitigate https://github.com/pypa/virtualenv/issues/1949
os.path.realpath(virtualenv),
'--no-download', '--always-copy', os.environ['out'],
]
if virtualenv.endswith('.pyz'):
args.extend(['--app-data', d])
subprocess.check_call(args)
subprocess.check_call([
sys.executable, '-B', ISOLATION_FLAG, virtualenv,
'--no-download', '--always-copy', os.environ['out']
])

# Install wheels to virtual environment
if 'wheels' in os.environ:
Expand Down

0 comments on commit 7f1070f

Please sign in to comment.