Skip to content

Commit 04fd4ee

Browse files
committed
format code
1 parent 1f47ab5 commit 04fd4ee

7 files changed

Lines changed: 28 additions & 22 deletions

File tree

python/private/hermetic_runtime_repo_setup.bzl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,11 +243,11 @@ def define_hermetic_runtime_toolchain_impl(
243243
# On Windows, a symlink-style venv requires supporting .dll files.
244244
venv_bin_files = select({
245245
"@platforms//os:windows": native.glob(
246-
include=["*.dll", "*.pdb"],
247-
allow_empty=True,
246+
include = ["*.dll", "*.pdb"],
247+
allow_empty = True,
248248
),
249249
"//conditions:default": [],
250-
})
250+
}),
251251
)
252252

253253
py_runtime_pair(

python/private/py_executable.bzl

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -535,12 +535,16 @@ def _create_venv(ctx, output_prefix, imports, runtime_details, add_runfiles_root
535535

536536
is_windows = target_platform_has_any_constraint(ctx, ctx.attr._windows_constraints)
537537
if is_windows:
538-
venv_details = _create_venv_windows(ctx, venv_root = venv_root,
538+
venv_details = _create_venv_windows(
539+
ctx,
540+
venv_root = venv_root,
539541
interpreter_actual_path = interpreter_actual_path,
540542
runtime = runtime,
541543
)
542544
else:
543-
venv_details = _create_venv_unixy(ctx, venv_root= venv_root,
545+
venv_details = _create_venv_unixy(
546+
ctx,
547+
venv_root = venv_root,
544548
interpreter_actual_path = interpreter_actual_path,
545549
runtime = runtime,
546550
)
@@ -614,6 +618,7 @@ def _create_venv_unixy(ctx, *, venv_root, runtime, interpreter_actual_path):
614618
interpreter_runfiles = builders.RunfilesBuilder()
615619
is_bootstrap_script = BootstrapImplFlag.get_value(ctx) == BootstrapImplFlag.SCRIPT
616620
create_full_venv = True
621+
617622
# The legacy build_python_zip codepath (enabled by default on windows) isn't
618623
# compatible with full venv.
619624
# TODO: Use non-build_python_zip codepath for Windows
@@ -736,14 +741,14 @@ def _create_venv_windows(ctx, *, venv_root, runtime, interpreter_actual_path):
736741
interpreter_runfiles = interpreter_runfiles.build(ctx),
737742
)
738743

739-
def _venv_details(*,
744+
def _venv_details(
745+
*,
740746
interpreter,
741747
pyvenv_cfg,
742748
venv_site_packages,
743749
bin_dir,
744750
recreate_venv_at_runtime,
745-
interpreter_runfiles,
746-
):
751+
interpreter_runfiles):
747752
"""Helper to create a struct of platform-specific venv details."""
748753
return struct(
749754
# File; the `bin/python` executable (or equivalent) within the venv.
@@ -851,7 +856,6 @@ def _create_stage1_bootstrap(
851856
else:
852857
resolve_python_binary_at_runtime = "1"
853858

854-
855859
subs = {
856860
"%interpreter_args%": "\n".join(ctx.attr.interpreter_args),
857861
"%is_zipfile%": "1" if is_for_zip else "0",

python/private/py_runtime_info.bzl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ def _PyRuntimeInfo_init(
120120
"stage2_bootstrap_template": stage2_bootstrap_template,
121121
"stub_shebang": stub_shebang,
122122
"supports_build_time_venv": supports_build_time_venv,
123-
"zip_main_template": zip_main_template,
124123
"venv_bin_files": venv_bin_files,
124+
"zip_main_template": zip_main_template,
125125
}
126126

127127
PyRuntimeInfo, _unused_raw_py_runtime_info_ctor = provider(
@@ -336,6 +336,14 @@ to meet two criteria:
336336
337337
:::{versionadded} 1.5.0
338338
:::
339+
""",
340+
"venv_bin_files": """
341+
:type: list[File]
342+
343+
Files that should be added to the venv's `bin/` (or platform-specific equivalent)
344+
directory (using the file's basename).
345+
346+
:::{versionadded} VERSION_NEXT_FEATURE
339347
""",
340348
"zip_main_template": """
341349
:type: File
@@ -357,14 +365,6 @@ The following substitutions are made during template expansion:
357365
358366
:::{versionadded} 0.33.0
359367
:::
360-
""",
361-
"venv_bin_files": """
362-
:type: list[File]
363-
364-
Files that should be added to the venv's `bin/` (or platform-specific equivalent)
365-
directory (using the file's basename).
366-
367-
:::{versionadded} VERSION_NEXT_FEATURE
368368
""",
369369
},
370370
)

python/private/py_runtime_rule.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ See {obj}`PyRuntimeInfo.supports_build_time_venv` for docs.
361361
""",
362362
default = True,
363363
),
364+
"venv_bin_files": attr.label_list(allow_files = True),
364365
"zip_main_template": attr.label(
365366
default = "//python/private/zipapp:zip_main_template",
366367
allow_single_file = True,
@@ -380,7 +381,6 @@ The {obj}`PyRuntimeInfo.zip_main_template` field.
380381
"_python_version_flag": attr.label(
381382
default = labels.PYTHON_VERSION,
382383
),
383-
"venv_bin_files": attr.label_list(allow_files=True),
384384
},
385385
),
386386
)

python/private/stage2_bootstrap_template.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@ def find_runfiles_root(main_rel_path):
186186
# not found. These can be correctly set for a parent Python process, but
187187
# inherited by the child, and not correct for it. Later bootstrap code
188188
# assumes they're are correct if set.
189-
os.environ.pop('RUNFILES_DIR', None)
190-
os.environ.pop('RUNFILES_MANIFEST_FILE', None)
189+
os.environ.pop("RUNFILES_DIR", None)
190+
os.environ.pop("RUNFILES_MANIFEST_FILE", None)
191191

192192
stub_filename = sys.argv[0]
193193
if not os.path.isabs(stub_filename):

tests/bootstrap_impls/sys_path_order_test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import sys
1818
import unittest
1919

20+
2021
class SysPathOrderTest(unittest.TestCase):
2122
def test_sys_path_order(self):
2223
last_stdlib = None
@@ -34,7 +35,7 @@ def test_sys_path_order(self):
3435
for i, value in enumerate(sys.path):
3536
# On windows, the `pythonXY.zip` entry shows up as `$venv/Scripts/pythonXY.zip`
3637
# While it's technically part of the venv, it's considered the stdlib.
37-
if os.name == 'nt' and re.search("python.*[.]zip$", value):
38+
if os.name == "nt" and re.search("python.*[.]zip$", value):
3839
category = "stdlib"
3940
elif value in (sys.prefix, sys.base_prefix):
4041
# The runtime's root repo may be added to sys.path, but it
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
print("Hello, world")
22
import pathlib
3+
34
print(pathlib)

0 commit comments

Comments
 (0)