Skip to content

Commit 5cdfd85

Browse files
committed
disable windows for zipapp tests
1 parent 678ea62 commit 5cdfd85

3 files changed

Lines changed: 25 additions & 3 deletions

File tree

python/private/common.bzl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
load("@bazel_skylib//lib:paths.bzl", "paths")
1717
load("@rules_cc//cc/common:cc_common.bzl", "cc_common")
1818
load("@rules_cc//cc/common:cc_info.bzl", "CcInfo")
19+
load("@rules_python_internal//:rules_python_config.bzl", "config")
1920
load("//python/private:py_interpreter_program.bzl", "PyInterpreterProgramInfo")
2021
load("//python/private:toolchain_types.bzl", "EXEC_TOOLS_TOOLCHAIN_TYPE")
2122
load(":cc_helper.bzl", "cc_helper")
@@ -43,6 +44,17 @@ PYTHON_FILE_EXTENSIONS = [
4344
"so", # Python C modules, usually Linux
4445
]
4546

47+
BUILTIN_BUILD_PYTHON_ZIP = [] if config.bazel_10_or_later else [
48+
"//command_line_option:build_python_zip",
49+
]
50+
51+
def maybe_builtin_build_python_zip(value, settings = None):
52+
settings = settings or {}
53+
if not config.bazel_10_or_later:
54+
settings["//command_line_option:build_python_zip"] = value
55+
56+
return settings
57+
4658
def create_binary_semantics_struct(
4759
*,
4860
get_native_deps_dso_name,

python/private/zipapp/py_zipapp_rule.bzl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,16 +207,15 @@ def _transition_zipapp_impl(settings, attr):
207207

208208
# Force this to false, otherwise the binary is already a zipapp
209209
settings[labels.BUILD_PYTHON_ZIP] = False
210-
settings["//command_line_option:build_python_zip"] = "false"
210+
maybe_builtin_build_python_zip("false", settings)
211211
return settings
212212

213213
_zipapp_transition = transition(
214214
implementation = _transition_zipapp_impl,
215215
inputs = TRANSITION_LABELS,
216216
outputs = TRANSITION_LABELS + [
217217
labels.BUILD_PYTHON_ZIP,
218-
"//command_line_option:build_python_zip",
219-
],
218+
] + BUILTIN_BUILD_PYTHON_ZIP,
220219
)
221220

222221
_ATTRS = {

tests/py_zipapp/BUILD.bazel

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ load("//python:py_binary.bzl", "py_binary")
22
load("//python:py_test.bzl", "py_test")
33
load("//python/private:bzlmod_enabled.bzl", "BZLMOD_ENABLED") # buildifier: disable=bzl-visibility
44
load("//python/zipapp:py_zipapp_binary.bzl", "py_zipapp_binary")
5+
load("//tests/support:support.bzl", "NOT_WINDOWS")
6+
7+
# todo: add windows support. Windows support will be a bit odd.
8+
# It previously worked by having special logic in the exe launcher
9+
# that knew to look for .zip and running that through python
510

611
py_binary(
712
name = "venv_bin",
@@ -11,12 +16,14 @@ py_binary(
1116
"//python/config_settings:venvs_site_packages": "yes",
1217
},
1318
main = "main.py",
19+
target_compatible_with = NOT_WINDOWS,
1420
deps = ["@dev_pip//absl_py"],
1521
)
1622

1723
py_zipapp_binary(
1824
name = "venv_zipapp",
1925
binary = ":venv_bin",
26+
target_compatible_with = NOT_WINDOWS,
2027
)
2128

2229
py_test(
@@ -27,6 +34,7 @@ py_test(
2734
"BZLMOD_ENABLED": str(int(BZLMOD_ENABLED)),
2835
"TEST_ZIPAPP": "$(location :venv_zipapp)",
2936
},
37+
target_compatible_with = NOT_WINDOWS,
3038
)
3139

3240
py_binary(
@@ -37,12 +45,14 @@ py_binary(
3745
"//python/config_settings:venvs_site_packages": "no",
3846
},
3947
main = "main.py",
48+
target_compatible_with = NOT_WINDOWS,
4049
deps = ["@dev_pip//absl_py"],
4150
)
4251

4352
py_zipapp_binary(
4453
name = "system_python_zipapp",
4554
binary = ":system_python_bin",
55+
target_compatible_with = NOT_WINDOWS,
4656
)
4757

4858
py_test(
@@ -52,4 +62,5 @@ py_test(
5262
env = {
5363
"TEST_ZIPAPP": "$(location :system_python_zipapp)",
5464
},
65+
target_compatible_with = NOT_WINDOWS,
5566
)

0 commit comments

Comments
 (0)