Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3c98b36

Browse filesBrowse files
author
Jonathon Belotti
authored
Fix bazel-contrib#507 - Always run from WORKSPACE root in compile_pip_requirements update exe (bazel-contrib#564)
1 parent 7d092c0 commit 3c98b36
Copy full SHA for 3c98b36

File tree

1 file changed

+14
-3
lines changed
Filter options

1 file changed

+14
-3
lines changed

‎python/pip_install/pip_compile.py

Copy file name to clipboardExpand all lines: python/pip_install/pip_compile.py
+14-3Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,22 @@
4141
)
4242
copyfile(requirements_txt, requirements_out)
4343

44-
elif "BUILD_WORKING_DIRECTORY" in os.environ:
45-
os.chdir(os.environ['BUILD_WORKING_DIRECTORY'])
44+
elif "BUILD_WORKSPACE_DIRECTORY" in os.environ:
45+
# This value, populated when running under `bazel run`, is a path to the
46+
# "root of the workspace where the build was run."
47+
# This matches up with the values passed in via the macro using the 'rootpath' Make variable,
48+
# which for source files provides a path "relative to your workspace root."
49+
#
50+
# Changing to the WORKSPACE root avoids 'file not found' errors when the `.update` target is run
51+
# from different directories within the WORKSPACE.
52+
os.chdir(os.environ['BUILD_WORKSPACE_DIRECTORY'])
4653
else:
54+
err_msg = (
55+
"Expected to find BUILD_WORKSPACE_DIRECTORY (running under `bazel run`) or "
56+
"TEST_TMPDIR (running under `bazel test`) in environment."
57+
)
4758
print(
48-
"Expected to find BUILD_WORKING_DIRECTORY in environment",
59+
err_msg,
4960
file=sys.stderr,
5061
)
5162
sys.exit(1)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.