Skip to content

Commit 711f758

Browse files
committed
format
1 parent 6f26953 commit 711f758

4 files changed

Lines changed: 24 additions & 15 deletions

File tree

python/private/py_executable.bzl

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,10 @@ This is only needed on Windows, where Bazel doesn't preserve declare_symlink
8181
with relative paths.
8282
""",
8383
fields = {
84+
"link_to": "Path the symlink should point to",
8485
"rf_path": "runfile-root-relative path for the link",
8586
"venv_rel_path": "venv-root-relative path for the link",
86-
"link_to": "Path the symlink should point to"
87-
}
87+
},
8888
)
8989

9090
# Non-Google-specific attributes for executables
@@ -754,11 +754,11 @@ def _create_venv_windows(ctx, *, venv_ctx_rel_root, runtime, interpreter_actual_
754754
rf_path = rf_path,
755755
venv_rel_path = venv_rel_path,
756756
link_to = relative_path(
757-
# dirname is necessary because a relative symlink is relative to
758-
# the directory the symlink resides within.
757+
# dirname is necessary because a relative symlink is relative to
758+
# the directory the symlink resides within.
759759
from_ = paths.dirname(rf_path),
760760
to = interpreter_actual_path,
761-
)
761+
),
762762
))
763763
else:
764764
interpreter = ctx.actions.declare_symlink("{}/{}".format(venv_bin_ctx_rel_path, py_exe_basename))
@@ -782,7 +782,7 @@ def _create_venv_windows(ctx, *, venv_ctx_rel_root, runtime, interpreter_actual_
782782
# the directory the symlink resides within.
783783
from_ = paths.dirname(rf_path),
784784
to = runfiles_root_path(ctx, f.short_path),
785-
)
785+
),
786786
))
787787

788788
# See site.py logic: Windows uses a version/build agnostic site-packages path
@@ -806,8 +806,7 @@ def _venv_details(
806806
bin_dir,
807807
recreate_venv_at_runtime,
808808
interpreter_runfiles,
809-
interpreter_symlinks,
810-
):
809+
interpreter_symlinks):
811810
"""Helper to create a struct of platform-specific venv details."""
812811
return struct(
813812
# File; the `bin/python` executable (or equivalent) within the venv.
@@ -931,8 +930,12 @@ def _create_stage1_bootstrap(
931930
}
932931
computed_subs = ctx.actions.template_dict()
933932
if venv:
934-
computed_subs.add_joined("%runtime_venv_symlinks%",
935-
venv.interpreter_symlinks, join_with = "\n", map_each = _map_runtime_venv_symlink)
933+
computed_subs.add_joined(
934+
"%runtime_venv_symlinks%",
935+
venv.interpreter_symlinks,
936+
join_with = "\n",
937+
map_each = _map_runtime_venv_symlink,
938+
)
936939

937940
if stage2_bootstrap:
938941
subs["%stage2_bootstrap%"] = runfiles_root_path(ctx, stage2_bootstrap.short_path)

python/private/zipapp/py_zipapp_rule.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def _create_zip(ctx, py_runtime, py_executable, stage2_bootstrap):
155155
zipper_args.add(ctx.attr.compression, format = "--compression=%s")
156156
zipper_args.add("--runfiles-dir=runfiles")
157157

158-
zipper_args.add("\\" if is_windows else "/", format="--pathsep=%s")
158+
zipper_args.add("\\" if is_windows else "/", format = "--pathsep=%s")
159159

160160
actions_run(
161161
ctx,

python/private/zipapp/zip_main_template.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,10 @@
5151
# Windows usually transparently rewrites them, but e.g. `\\?\` paths require
5252
# backslashes to be properly understood by Windows APIs.
5353
if IS_WINDOWS:
54+
5455
def norm_slashes(s):
55-
if not s: return s
56+
if not s:
57+
return s
5658
return s.replace("/", "\\")
5759

5860
_STAGE2_BOOTSTRAP = norm_slashes(_STAGE2_BOOTSTRAP)

tools/private/zipapp/zipper.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99
# S_IFLNK is usually 0o120000
1010
S_IFLNK = 0o120000
1111

12+
1213
def unix_join(*parts):
1314
return "/".join(parts)
1415

16+
1517
def _get_zip_runfiles_path(
1618
path, workspace_name, legacy_external_runfiles, runfiles_dir
1719
):
@@ -95,12 +97,14 @@ def read_manifest(
9597
entries.sort(key=lambda x: (x[2], 0 if x[0] == "symlink" else 1))
9698
return entries
9799

100+
98101
def path_norm(path, pathsep):
99102
if pathsep == "/":
100103
return path.replace("\\", pathsep)
101104
else:
102105
return path.replace("/", "\\")
103106

107+
104108
def _write_entry(zf, entry, compress_type, seen, pathsep):
105109
type_, is_symlink_str, zip_path, content_path = entry
106110
# Normalize slashes, otherwise the `seen` logic doesn't
@@ -133,7 +137,6 @@ def _write_entry(zf, entry, compress_type, seen, pathsep):
133137
zf.writestr(zi, target)
134138
return
135139

136-
137140
if is_symlink_str == "-1":
138141
if not os.path.exists(content_path):
139142
is_symlink_str = "1"
@@ -249,7 +252,8 @@ def main():
249252
"--runfiles-dir", default="runfiles", help="Name of the runfiles directory"
250253
)
251254
parser.add_argument(
252-
"--pathsep", default="/",
255+
"--pathsep",
256+
default="/",
253257
)
254258
args = parser.parse_args()
255259

@@ -261,7 +265,7 @@ def main():
261265
workspace_name=args.workspace_name,
262266
legacy_external_runfiles=args.legacy_external_runfiles == "1",
263267
runfiles_dir=args.runfiles_dir,
264-
pathsep = args.pathsep,
268+
pathsep=args.pathsep,
265269
)
266270
except Exception as e:
267271
e.add_note(f"Error creating zip {args.output}")

0 commit comments

Comments
 (0)