Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ buildifier:
build_flags:
- "--keep_going"
- "--build_tag_filters=-integration-test"
- "--announce_rc"
test_targets:
- "--"
- "..."
Expand Down Expand Up @@ -170,6 +171,7 @@ tasks:
# their package path is qualified with the repo name.
- "@rules_python//examples/wheel/..."
build_flags:
- "--action_env=PATH"
- "--noenable_bzlmod"
- "--enable_workspace"
- "--keep_going"
Expand All @@ -194,6 +196,8 @@ tasks:
<<: *reusable_config
name: "Default: Windows"
platform: windows
build_flags:
- "--action_env=PATH"
test_flags:
- "--test_tag_filters=-integration-test,-fix-windows"
rbe_min:
Expand Down Expand Up @@ -536,6 +540,8 @@ tasks:
platform: windows
build_targets: ["//tests/integration:local_toolchains_test_bazel_self"]
test_targets: ["//tests/integration:local_toolchains_test_bazel_self"]
build_flags:
- "--action_env=PATH"

integration_test_compile_pip_requirements_ubuntu:
<<: *reusable_build_test_all
Expand Down
2 changes: 2 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ build --//python/config_settings:incompatible_default_to_explicit_init_py=True
# Ensure ongoing compatibility with this flag.
common --incompatible_disallow_struct_provider_syntax

common --incompatible_strict_action_env

# Windows makes use of runfiles for some rules
build --enable_runfiles

Expand Down
1 change: 1 addition & 0 deletions examples/bzlmod/.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ test --test_output=errors --enable_runfiles

# Windows requires these for multi-python support:
build --enable_runfiles
build --incompatible_strict_action_env
common:bazel7.x --incompatible_python_disallow_native_rules
5 changes: 5 additions & 0 deletions python/private/attributes.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,11 @@ environment when the test is executed by bazel test.
"@platforms//os:watchos",
],
),
"_windows_constraints": lambda: attrb.LabelList(
default = [
"@platforms//os:windows",
],
),
})

# Attributes specific to Python test-equivalent executable rules. Such rules may
Expand Down
2 changes: 2 additions & 0 deletions python/private/common.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,8 @@ def maybe_add_test_execution_info(providers, ctx):
# TODO(b/176993122): Remove when bazel automatically knows to run on darwin.
if target_platform_has_any_constraint(ctx, ctx.attr._apple_constraints):
providers.append(_testing.ExecutionInfo({"requires-darwin": ""}))
if target_platform_has_any_constraint(ctx, ctx.attr._windows_constraints):
providers.append(RunEnvironmentInfo(inherited_environment = ["PATH"]))

_BOOL_TYPE = type(True)

Expand Down
4 changes: 4 additions & 0 deletions tests/bootstrap_impls/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ sh_py_run_test(
build_python_zip = False,
py_src = "bin.py",
sh_src = "run_binary_zip_no_test.sh",
target_compatible_with = select({
"@platforms//os:windows": ["@platforms//:incompatible"],
"//conditions:default": [],
}),
)

sh_py_run_test(
Expand Down
9 changes: 7 additions & 2 deletions tests/integration/custom_commands_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import logging
import unittest

from tests.integration import runner
Expand All @@ -21,7 +20,13 @@
class CustomCommandsTest(runner.TestCase):
# Regression test for https://github.com/bazel-contrib/rules_python/issues/1840
def test_run_build_python_zip_false(self):
result = self.run_bazel("run", "--build_python_zip=false", "--@rules_python//python/config_settings:build_python_zip=false", "//:bin")
result = self.run_bazel(
"run",
"--build_python_zip=false",
"--@rules_python//python/config_settings:build_python_zip=false",
"--action_env=PATH",
"//:bin",
)
self.assert_result_matches(result, "bazel-out")


Expand Down
1 change: 1 addition & 0 deletions tests/integration/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ def setUp(self):
self.tmp_dir = outer_test_tmpdir / "bit_tmp"
self.bazel_env = {
"PATH": os.environ["PATH"],
"HOME": os.environ["HOME"],
"TEST_TMPDIR": str(self.test_tmp_dir),
"TMP": str(self.tmp_dir),
# For some reason, this is necessary for Bazel 6.4 to work.
Expand Down