Skip to content

Commit ca98773

Browse files
authored
chore: load specific bzl files instead of generic defs.bzl (#2483)
Update code and examples to load the object-specific bzl files instead of the generic `defs.bzl`. This is mostly for code hygiene, but came out of trying to diagnose why Bazel 9 workspace builds kept erroing with defs.bzl somehow related. Removing the internal usages of defs.bzl doesn't seem to fully fix it, but does seem to eliminate some errors, make some progress, and narrow down what's going on. Work towards #2469
1 parent 0fb4ce1 commit ca98773

File tree

42 files changed

+58
-48
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+58
-48
lines changed

docs/getting-started.md

Lines changed: 1 addition & 1 deletion

docs/index.md

Lines changed: 1 addition & 1 deletion

examples/build_file_generation/BUILD.bazel

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
# ruleset. When the symbol is loaded you can use the rule.
55
load("@bazel_gazelle//:def.bzl", "gazelle")
66
load("@pip//:requirements.bzl", "all_whl_requirements")
7-
load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test")
87
load("@rules_python//python:pip.bzl", "compile_pip_requirements")
8+
load("@rules_python//python:py_binary.bzl", "py_binary")
9+
load("@rules_python//python:py_library.bzl", "py_library")
10+
load("@rules_python//python:py_test.bzl", "py_test")
911
load("@rules_python_gazelle_plugin//manifest:defs.bzl", "gazelle_python_manifest")
1012
load("@rules_python_gazelle_plugin//modules_mapping:def.bzl", "modules_mapping")
1113

examples/build_file_generation/random_number_generator/BUILD.bazel

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
load("@rules_python//python:defs.bzl", "py_library", "py_test")
1+
load("@rules_python//python:py_library.bzl", "py_library")
2+
load("@rules_python//python:py_test.bzl", "py_test")
23

34
py_library(
45
name = "random_number_generator",

examples/bzlmod/BUILD.bazel

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ load("@bazel_skylib//rules:build_test.bzl", "build_test")
99
load("@pip//:requirements.bzl", "all_data_requirements", "all_requirements", "all_whl_requirements", "requirement")
1010
load("@python_3_9//:defs.bzl", py_test_with_transition = "py_test")
1111
load("@python_versions//3.10:defs.bzl", compile_pip_requirements_3_10 = "compile_pip_requirements")
12-
load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test")
12+
load("@rules_python//python:py_binary.bzl", "py_binary")
13+
load("@rules_python//python:py_library.bzl", "py_library")
14+
load("@rules_python//python:py_test.bzl", "py_test")
1315

1416
# This stanza calls a rule that generates targets for managing pip dependencies
1517
# with pip-compile for a particular python version.

examples/bzlmod/entry_points/tests/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
load("@bazel_skylib//rules:run_binary.bzl", "run_binary")
2-
load("@rules_python//python:defs.bzl", "py_test")
2+
load("@rules_python//python:py_test.bzl", "py_test")
33

44
# Below are targets for testing the `py_console_script_binary` feature and are
55
# not part of the example how to use the feature.

examples/bzlmod/libs/my_lib/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
load("@pip//:requirements.bzl", "requirement")
2-
load("@rules_python//python:defs.bzl", "py_library")
2+
load("@rules_python//python:py_library.bzl", "py_library")
33

44
py_library(
55
name = "my_lib",

examples/bzlmod/other_module/other_module/pkg/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ load(
22
"@python_3_11//:defs.bzl",
33
py_binary_311 = "py_binary",
44
)
5-
load("@rules_python//python:defs.bzl", "py_library")
5+
load("@rules_python//python:py_library.bzl", "py_library")
66

77
py_library(
88
name = "lib",

examples/bzlmod/runfiles/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("@rules_python//python:defs.bzl", "py_test")
1+
load("@rules_python//python:py_test.bzl", "py_test")
22

33
py_test(
44
name = "runfiles_test",

examples/bzlmod/tests/BUILD.bazel

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ load("@python_versions//3.10:defs.bzl", py_binary_3_10 = "py_binary", py_test_3_
22
load("@python_versions//3.11:defs.bzl", py_binary_3_11 = "py_binary", py_test_3_11 = "py_test")
33
load("@python_versions//3.9:defs.bzl", py_binary_3_9 = "py_binary", py_test_3_9 = "py_test")
44
load("@pythons_hub//:versions.bzl", "MINOR_MAPPING")
5-
load("@rules_python//python:defs.bzl", "py_binary", "py_test")
5+
load("@rules_python//python:py_binary.bzl", "py_binary")
6+
load("@rules_python//python:py_test.bzl", "py_test")
67
load("@rules_python//python/config_settings:transition.bzl", py_versioned_binary = "py_binary", py_versioned_test = "py_test")
78
load("@rules_shell//shell:sh_test.bzl", "sh_test")
89

0 commit comments

Comments
 (0)