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

Side by Side Diff: recipe_engine/env.py

Issue 2154943002: Assert using realpath when confirming "env". (Closed) Base URL: https://github.com/luci/recipes-py@master
Patch Set: Created 4 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
« no previous file with comments | « no previous file | 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 2016 The LUCI Authors. All rights reserved. 1 # Copyright 2016 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 """Sets up recipe engine Python environment.""" 5 """Sets up recipe engine Python environment."""
6 6
7 import contextlib 7 import contextlib
8 import os 8 import os
9 import sys 9 import sys
10 10
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 # In a temporary environment where "sys.path" consists solely of our 52 # In a temporary environment where "sys.path" consists solely of our
53 # "third_party" directory, register the google namespace. By restricting the 53 # "third_party" directory, register the google namespace. By restricting the
54 # options in "sys.path", "pkg_resources" will not cache or prefer system 54 # options in "sys.path", "pkg_resources" will not cache or prefer system
55 # resources for this namespace or its derivatives. 55 # resources for this namespace or its derivatives.
56 sys.path = [THIRD_PARTY] 56 sys.path = [THIRD_PARTY]
57 pkg_resources.declare_namespace('google') 57 pkg_resources.declare_namespace('google')
58 pkg_resources.fixup_namespace_packages(THIRD_PARTY) 58 pkg_resources.fixup_namespace_packages(THIRD_PARTY)
59 59
60 # From here on out, we're back to normal imports. Let's assert that the we're 60 # From here on out, we're back to normal imports. Let's assert that the we're
61 # using the correct protobuf package, though. 61 # using the correct protobuf package, though.
62 #
63 # We use "realpath" here because the importer may resolve the path differently
64 # based on symlinks, and we want to make sure our calculated path matches the
65 # impoter's path regardless.
62 import google.protobuf 66 import google.protobuf
63 assert THIRD_PARTY in google.protobuf.__path__[0] 67 assert (os.path.realpath(THIRD_PARTY) in
68 os.path.realpath(google.protobuf.__path__[0]))
64 69
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698