Skip to content

Commit f80d42f

Browse files
author
Omar Aldrroubi
committed
fix: Fix whl_library in bazel vendor mode
- Added PYTHONHOME to whl_library execution enviornment. Without it the python interpretter is getting confused where it's running from when bazel --vendor_dir is used - In _get_toolchain_unix_cflags, the real path for python is used instead of the symlink.
1 parent 9555ba8 commit f80d42f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

python/private/pypi/whl_library.bzl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,11 @@ def _get_toolchain_unix_cflags(rctx, python_interpreter, logger = None):
109109
stdout = pypi_repo_utils.execute_checked_stdout(
110110
rctx,
111111
op = "GetPythonVersionForUnixCflags",
112-
python = python_interpreter,
112+
# python_interpreter by default points to a symlink, however when using bazel in vendor mode,
113+
# and the vendored directory moves around, the execution of python fails, as it's getting confused
114+
# where it's running from. More to the fact that we are executing it in isolated mode "-I", which
115+
# results in PYTHONHOME being ignored. The solution is to run python from it's real directory.
116+
python = python_interpreter.realpath,
113117
arguments = [
114118
# Run the interpreter in isolated mode, this options implies -E, -P and -s.
115119
# Ensures environment variables are ignored that are set in userspace, such as PYTHONPATH,
@@ -214,6 +218,7 @@ def _create_repository_execution_environment(rctx, python_interpreter, logger =
214218
rctx,
215219
entries = rctx.attr._python_path_entries,
216220
),
221+
"PYTHONHOME": str(python_interpreter.dirname),
217222
}
218223

219224
# Gather any available CPPFLAGS values

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy