Skip to content

Commit b07525c

Browse files
authored
fix(rules): drop the unused argument (#1953)
It seems that there is an extra argument that is there but I am not sure about the reason, it is most likely a leftover. As part of this change we add an analysis test for non-windows zip building. I could reproduce the failure and now the newly added test passes. Fixes #1954
1 parent 2a19374 commit b07525c

File tree

3 files changed

+53
-2
lines changed

3 files changed

+53
-2
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ A brief description of the categories of changes:
3333
### Removed
3434
* Nothing yet
3535

36+
## [0.33.1] - 2024-06-13
37+
38+
[0.33.1]: https://github.com/bazelbuild/rules_python/releases/tag/0.33.1
39+
40+
### Fixed
41+
* (py_binary) Fix building of zip file when using `--build_python_zip`
42+
argument. Fixes [#1954](https://github.com/bazelbuild/rules_python/issues/1954).
43+
3644
## [0.33.0] - 2024-06-12
3745

3846
[0.33.0]: https://github.com/bazelbuild/rules_python/releases/tag/0.33.0

python/private/common/py_executable_bazel.bzl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,6 @@ def _create_executable(
270270
ctx,
271271
output = executable,
272272
zip_file = zip_file,
273-
python_binary_path = runtime_details.executable_interpreter_path,
274273
stage2_bootstrap = stage2_bootstrap,
275274
runtime_details = runtime_details,
276275
)

tests/base_rules/py_executable_base_tests.bzl

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ load("@rules_testing//lib:truth.bzl", "matching")
2020
load("@rules_testing//lib:util.bzl", rt_util = "util")
2121
load("//tests/base_rules:base_tests.bzl", "create_base_tests")
2222
load("//tests/base_rules:util.bzl", "WINDOWS_ATTR", pt_util = "util")
23-
load("//tests/support:support.bzl", "WINDOWS_X86_64")
23+
load("//tests/support:support.bzl", "LINUX_X86_64", "WINDOWS_X86_64")
2424

2525
_BuiltinPyRuntimeInfo = PyRuntimeInfo
2626

@@ -67,6 +67,50 @@ def _test_basic_windows_impl(env, target):
6767

6868
_tests.append(_test_basic_windows)
6969

70+
def _test_basic_zip(name, config):
71+
if rp_config.enable_pystar:
72+
target_compatible_with = select({
73+
# Disable the new test on windows because we have _test_basic_windows.
74+
"@platforms//os:windows": ["@platforms//:incompatible"],
75+
"//conditions:default": [],
76+
})
77+
else:
78+
target_compatible_with = ["@platforms//:incompatible"]
79+
rt_util.helper_target(
80+
config.rule,
81+
name = name + "_subject",
82+
srcs = ["main.py"],
83+
main = "main.py",
84+
)
85+
analysis_test(
86+
name = name,
87+
impl = _test_basic_zip_impl,
88+
target = name + "_subject",
89+
config_settings = {
90+
# NOTE: The default for this flag is based on the Bazel host OS, not
91+
# the target platform. For windows, it defaults to true, so force
92+
# it to that to match behavior when this test runs on other
93+
# platforms.
94+
"//command_line_option:build_python_zip": "true",
95+
"//command_line_option:cpu": "linux_x86_64",
96+
"//command_line_option:crosstool_top": Label("//tests/cc:cc_toolchain_suite"),
97+
"//command_line_option:extra_toolchains": [str(Label("//tests/cc:all"))],
98+
"//command_line_option:platforms": [LINUX_X86_64],
99+
},
100+
attr_values = {"target_compatible_with": target_compatible_with},
101+
)
102+
103+
def _test_basic_zip_impl(env, target):
104+
target = env.expect.that_target(target)
105+
target.runfiles().contains_predicate(matching.str_endswith(
106+
target.meta.format_str("/{name}.zip"),
107+
))
108+
target.runfiles().contains_predicate(matching.str_endswith(
109+
target.meta.format_str("/{name}"),
110+
))
111+
112+
_tests.append(_test_basic_zip)
113+
70114
def _test_executable_in_runfiles(name, config):
71115
rt_util.helper_target(
72116
config.rule,

0 commit comments

Comments
 (0)