Skip to content

Commit 27088fe

Browse files
committed
normpath, fix venv.interpreter_runfiles NPE
1 parent 98aa09d commit 27088fe

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

python/private/py_executable.bzl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ WARNING: Target: {}
476476

477477
# The interpreter is added this late in the process so that it isn't
478478
# added to the zipped files.
479-
if venv and venv.interpreter:
479+
if venv and venv.interpreter_runfiles:
480480
extra_runfiles = extra_runfiles.merge(venv.interpreter_runfiles)
481481
return struct(
482482
# depset[File] of additional files that should be included as default
@@ -494,8 +494,8 @@ WARNING: Target: {}
494494
app_runfiles = app_runfiles.build(ctx),
495495
# File|None; the venv `bin/python3` file, if any.
496496
venv_python_exe = venv.interpreter if venv else None,
497-
# runfiles; runfiles in the venv for the interpreter
498-
venv_interpreter_runfiles = venv.interpreter_runfiles,
497+
# runfiles|None; runfiles in the venv for the interpreter
498+
venv_interpreter_runfiles = venv.interpreter_runfiles if venv else None,
499499
)
500500

501501
def _create_zip_main(ctx, *, stage2_bootstrap, runtime_details, venv):

python/private/zipapp/zip_main_template.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,21 @@
4646
IS_WINDOWS = os.name == "nt"
4747

4848

49+
EXTRACT_ROOT = os.environ.get("RULES_PYTHON_EXTRACT_ROOT")
50+
51+
# Change the paths with Unix-style forward slashes to backslashes for windows.
52+
# Windows usually transparently rewrites them, but e.g. `\\?\` paths require
53+
# backslashes to be properly understood by Windows APIs.
54+
if IS_WINDOWS:
55+
from os.path import normpath
56+
_STAGE2_BOOTSTRAP = normpath(_STAGE2_BOOTSTRAP)
57+
if _PYTHON_BINARY_VENV:
58+
_PYTHON_BINARY_VENV = normpath(_PYTHON_BINARY_VENV)
59+
_PYTHON_BINARY_ACTUAL = normpath(_PYTHON_BINARY_ACTUAL)
60+
EXTRACT_DIR = normpath(EXTRACT_DIR)
61+
if EXTRACT_ROOT:
62+
EXTRACT_ROOT = normpath(EXTRACT_ROOT)
63+
4964
def print_verbose(*args, mapping=None, values=None):
5065
if not bool(os.environ.get("RULES_PYTHON_BOOTSTRAP_VERBOSE")):
5166
return

0 commit comments

Comments
 (0)