diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index 119ad498b0..6ed93b083d 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -329,20 +329,20 @@ tasks: <<: *minimum_supported_version <<: *reusable_build_test_all <<: *coverage_targets_example_bzlmod_build_file_generation - name: "examples/bzlmod_build_file_generation: Ubuntu, minimum Bazel" - working_directory: examples/bzlmod_build_file_generation + name: "gazelle/examples/bzlmod_build_file_generation: Ubuntu, minimum Bazel" + working_directory: gazelle/examples/bzlmod_build_file_generation platform: ubuntu2204 bazel: 7.x integration_test_bzlmod_generation_build_files_ubuntu: <<: *reusable_build_test_all <<: *coverage_targets_example_bzlmod_build_file_generation - name: "examples/bzlmod_build_file_generation: Ubuntu" - working_directory: examples/bzlmod_build_file_generation + name: "gazelle/examples/bzlmod_build_file_generation: Ubuntu" + working_directory: gazelle/examples/bzlmod_build_file_generation platform: ubuntu2204 integration_test_bzlmod_generation_build_files_ubuntu_run: <<: *reusable_build_test_all - name: "examples/bzlmod_build_file_generation: Ubuntu, Gazelle and pip" - working_directory: examples/bzlmod_build_file_generation + name: "gazelle/examples/bzlmod_build_file_generation: Ubuntu, Gazelle and pip" + working_directory: gazelle/examples/bzlmod_build_file_generation platform: ubuntu2204 shell_commands: - "bazel run //:gazelle_python_manifest.update" @@ -350,20 +350,20 @@ tasks: integration_test_bzlmod_build_file_generation_debian: <<: *reusable_build_test_all <<: *coverage_targets_example_bzlmod_build_file_generation - name: "examples/bzlmod_build_file_generation: Debian" - working_directory: examples/bzlmod_build_file_generation + name: "gazelle/examples/bzlmod_build_file_generation: Debian" + working_directory: gazelle/examples/bzlmod_build_file_generation platform: debian11 integration_test_bzlmod_build_file_generation_macos: <<: *reusable_build_test_all <<: *coverage_targets_example_bzlmod_build_file_generation - name: "examples/bzlmod_build_file_generation: MacOS" - working_directory: examples/bzlmod_build_file_generation + name: "gazelle/examples/bzlmod_build_file_generation: MacOS" + working_directory: gazelle/examples/bzlmod_build_file_generation platform: macos integration_test_bzlmod_build_file_generation_windows: <<: *reusable_build_test_all # coverage is not supported on Windows - name: "examples/bzlmod_build_file_generation: Windows" - working_directory: examples/bzlmod_build_file_generation + name: "gazelle/examples/bzlmod_build_file_generation: Windows" + working_directory: gazelle/examples/bzlmod_build_file_generation platform: windows integration_test_multi_python_versions_ubuntu_workspace: diff --git a/.bazelignore b/.bazelignore index fb999097f5..dd58b79e3c 100644 --- a/.bazelignore +++ b/.bazelignore @@ -26,6 +26,10 @@ examples/pip_parse_vendored/bazel-pip_parse_vendored examples/pip_repository_annotations/bazel-pip_repository_annotations examples/py_proto_library/bazel-py_proto_library gazelle/bazel-gazelle +gazelle/examples/bzlmod_build_file_generation/bazel-bin +gazelle/examples/bzlmod_build_file_generation/bazel-bzlmod_build_file_generation +gazelle/examples/bzlmod_build_file_generation/bazel-out +gazelle/examples/bzlmod_build_file_generation/bazel-testlog tests/integration/compile_pip_requirements/bazel-compile_pip_requirements tests/integration/ignore_root_user_error/bazel-ignore_root_user_error tests/integration/local_toolchains/bazel-local_toolchains diff --git a/.bazelrc b/.bazelrc index 801b963ad5..b5c9c7c1e2 100644 --- a/.bazelrc +++ b/.bazelrc @@ -9,6 +9,9 @@ query --deleted_packages=examples/build_file_generation,examples/build_file_gene test --test_output=errors +common --deleted_packages=gazelle/examples/bzlmod_build_file_generation +common --deleted_packages=gazelle/examples/bzlmod_build_file_generation/runfiles + # Do NOT implicitly create empty __init__.py files in the runfiles tree. # By default, these are created in every directory containing Python source code # or shared libraries, and every parent directory of those directories, diff --git a/.bcr/gazelle/presubmit.yml b/.bcr/gazelle/presubmit.yml index bceed4f9e1..ff1c9e7d58 100644 --- a/.bcr/gazelle/presubmit.yml +++ b/.bcr/gazelle/presubmit.yml @@ -13,7 +13,7 @@ # limitations under the License. bcr_test_module: - module_path: "../examples/bzlmod_build_file_generation" + module_path: "examples/bzlmod_build_file_generation" matrix: platform: ["debian11", "macos", "ubuntu2004", "windows"] # last_rc is to get latest 8.x release. Replace with 8.x when available. @@ -23,6 +23,8 @@ bcr_test_module: name: "Run test module" platform: ${{ platform }} bazel: ${{ bazel }} + shell_commands: + - "echo 'common --override_module=rules_python=' >> .bazelrc" build_targets: - "//..." - ":modules_map" diff --git a/examples/bzlmod_build_file_generation/other_module/MODULE.bazel b/examples/bzlmod_build_file_generation/other_module/MODULE.bazel deleted file mode 100644 index 992e120760..0000000000 --- a/examples/bzlmod_build_file_generation/other_module/MODULE.bazel +++ /dev/null @@ -1,5 +0,0 @@ -module( - name = "other_module", -) - -bazel_dep(name = "rules_python", version = "") diff --git a/gazelle/.bazelignore b/gazelle/.bazelignore new file mode 100644 index 0000000000..5930a06190 --- /dev/null +++ b/gazelle/.bazelignore @@ -0,0 +1,8 @@ +bazel-bin +bazel-gazelle +bazel-out +bazel-testlogs +examples/bzlmod_build_file_generation/bazel-bin +examples/bzlmod_build_file_generation/bazel-bzlmod_build_file_generation +examples/bzlmod_build_file_generation/bazel-out +examples/bzlmod_build_file_generation/bazel-testlog diff --git a/gazelle/.bazelrc b/gazelle/.bazelrc index 791b93912a..9a38133e9d 100644 --- a/gazelle/.bazelrc +++ b/gazelle/.bazelrc @@ -1,3 +1,6 @@ +common --deleted_packages=examples/bzlmod_build_file_generation +common --deleted_packages=examples/bzlmod_build_file_generation/runfiles + test --test_output=errors # Do NOT implicitly create empty __init__.py files in the runfiles tree. diff --git a/examples/bzlmod_build_file_generation/.bazelignore b/gazelle/examples/bzlmod_build_file_generation/.bazelignore similarity index 100% rename from examples/bzlmod_build_file_generation/.bazelignore rename to gazelle/examples/bzlmod_build_file_generation/.bazelignore diff --git a/examples/bzlmod_build_file_generation/.bazelrc b/gazelle/examples/bzlmod_build_file_generation/.bazelrc similarity index 100% rename from examples/bzlmod_build_file_generation/.bazelrc rename to gazelle/examples/bzlmod_build_file_generation/.bazelrc diff --git a/examples/bzlmod_build_file_generation/.gitignore b/gazelle/examples/bzlmod_build_file_generation/.gitignore similarity index 100% rename from examples/bzlmod_build_file_generation/.gitignore rename to gazelle/examples/bzlmod_build_file_generation/.gitignore diff --git a/examples/bzlmod_build_file_generation/BUILD.bazel b/gazelle/examples/bzlmod_build_file_generation/BUILD.bazel similarity index 100% rename from examples/bzlmod_build_file_generation/BUILD.bazel rename to gazelle/examples/bzlmod_build_file_generation/BUILD.bazel diff --git a/examples/bzlmod_build_file_generation/MODULE.bazel b/gazelle/examples/bzlmod_build_file_generation/MODULE.bazel similarity index 91% rename from examples/bzlmod_build_file_generation/MODULE.bazel rename to gazelle/examples/bzlmod_build_file_generation/MODULE.bazel index 3436fbf0af..5ace7f3d3a 100644 --- a/examples/bzlmod_build_file_generation/MODULE.bazel +++ b/gazelle/examples/bzlmod_build_file_generation/MODULE.bazel @@ -13,26 +13,28 @@ module( # For typical setups you set the version. # See the releases page for available versions. # https://github.com/bazel-contrib/rules_python/releases -bazel_dep(name = "rules_python", version = "0.0.0") +bazel_dep(name = "rules_python", version = "1.0.0") +# NOTE: This override is removed for BCR presubmits and the version +# specified by bazel_dep() is used instead. # The following loads rules_python from the file system. # For usual setups you should remove this local_path_override block. local_path_override( module_name = "rules_python", - path = "../..", + path = "../../..", ) # The following stanza defines the dependency rules_python_gazelle_plugin. # For typical setups you set the version. # See the releases page for available versions. # https://github.com/bazel-contrib/rules_python/releases -bazel_dep(name = "rules_python_gazelle_plugin", version = "0.0.0") +bazel_dep(name = "rules_python_gazelle_plugin", version = "1.5.0") # The following starlark loads the gazelle plugin from the file system. # For usual setups you should remove this local_path_override block. local_path_override( module_name = "rules_python_gazelle_plugin", - path = "../../gazelle", + path = "../..", ) # The following stanza defines the dependency for gazelle @@ -84,7 +86,7 @@ use_repo(pip, "pip") # This project includes a different module that is on the local file system. # Add the module to this parent project. -bazel_dep(name = "other_module", version = "", repo_name = "our_other_module") +bazel_dep(name = "other_module", version = "0.0.0", repo_name = "our_other_module") local_path_override( module_name = "other_module", path = "other_module", diff --git a/examples/bzlmod_build_file_generation/README.md b/gazelle/examples/bzlmod_build_file_generation/README.md similarity index 100% rename from examples/bzlmod_build_file_generation/README.md rename to gazelle/examples/bzlmod_build_file_generation/README.md diff --git a/examples/bzlmod_build_file_generation/WORKSPACE b/gazelle/examples/bzlmod_build_file_generation/WORKSPACE similarity index 100% rename from examples/bzlmod_build_file_generation/WORKSPACE rename to gazelle/examples/bzlmod_build_file_generation/WORKSPACE diff --git a/examples/bzlmod_build_file_generation/__main__.py b/gazelle/examples/bzlmod_build_file_generation/__main__.py similarity index 100% rename from examples/bzlmod_build_file_generation/__main__.py rename to gazelle/examples/bzlmod_build_file_generation/__main__.py diff --git a/examples/bzlmod_build_file_generation/__test__.py b/gazelle/examples/bzlmod_build_file_generation/__test__.py similarity index 100% rename from examples/bzlmod_build_file_generation/__test__.py rename to gazelle/examples/bzlmod_build_file_generation/__test__.py diff --git a/examples/bzlmod_build_file_generation/gazelle_python.yaml b/gazelle/examples/bzlmod_build_file_generation/gazelle_python.yaml similarity index 100% rename from examples/bzlmod_build_file_generation/gazelle_python.yaml rename to gazelle/examples/bzlmod_build_file_generation/gazelle_python.yaml diff --git a/examples/bzlmod_build_file_generation/gazelle_python_with_types.yaml b/gazelle/examples/bzlmod_build_file_generation/gazelle_python_with_types.yaml similarity index 100% rename from examples/bzlmod_build_file_generation/gazelle_python_with_types.yaml rename to gazelle/examples/bzlmod_build_file_generation/gazelle_python_with_types.yaml diff --git a/examples/bzlmod_build_file_generation/lib.py b/gazelle/examples/bzlmod_build_file_generation/lib.py similarity index 100% rename from examples/bzlmod_build_file_generation/lib.py rename to gazelle/examples/bzlmod_build_file_generation/lib.py diff --git a/gazelle/examples/bzlmod_build_file_generation/other_module/MODULE.bazel b/gazelle/examples/bzlmod_build_file_generation/other_module/MODULE.bazel new file mode 100644 index 0000000000..3deeeb6ccc --- /dev/null +++ b/gazelle/examples/bzlmod_build_file_generation/other_module/MODULE.bazel @@ -0,0 +1,7 @@ +module( + name = "other_module", +) + +# Version doesn't matter because the root module overrides it, +# but Bazel requires it exist in the registry. +bazel_dep(name = "rules_python", version = "1.0.0") diff --git a/examples/bzlmod_build_file_generation/other_module/WORKSPACE b/gazelle/examples/bzlmod_build_file_generation/other_module/WORKSPACE similarity index 100% rename from examples/bzlmod_build_file_generation/other_module/WORKSPACE rename to gazelle/examples/bzlmod_build_file_generation/other_module/WORKSPACE diff --git a/examples/bzlmod_build_file_generation/other_module/other_module/pkg/BUILD.bazel b/gazelle/examples/bzlmod_build_file_generation/other_module/other_module/pkg/BUILD.bazel similarity index 100% rename from examples/bzlmod_build_file_generation/other_module/other_module/pkg/BUILD.bazel rename to gazelle/examples/bzlmod_build_file_generation/other_module/other_module/pkg/BUILD.bazel diff --git a/examples/bzlmod_build_file_generation/other_module/other_module/pkg/data/data.txt b/gazelle/examples/bzlmod_build_file_generation/other_module/other_module/pkg/data/data.txt similarity index 100% rename from examples/bzlmod_build_file_generation/other_module/other_module/pkg/data/data.txt rename to gazelle/examples/bzlmod_build_file_generation/other_module/other_module/pkg/data/data.txt diff --git a/examples/bzlmod_build_file_generation/other_module/other_module/pkg/lib.py b/gazelle/examples/bzlmod_build_file_generation/other_module/other_module/pkg/lib.py similarity index 100% rename from examples/bzlmod_build_file_generation/other_module/other_module/pkg/lib.py rename to gazelle/examples/bzlmod_build_file_generation/other_module/other_module/pkg/lib.py diff --git a/examples/bzlmod_build_file_generation/requirements.in b/gazelle/examples/bzlmod_build_file_generation/requirements.in similarity index 100% rename from examples/bzlmod_build_file_generation/requirements.in rename to gazelle/examples/bzlmod_build_file_generation/requirements.in diff --git a/examples/bzlmod_build_file_generation/requirements_lock.txt b/gazelle/examples/bzlmod_build_file_generation/requirements_lock.txt similarity index 100% rename from examples/bzlmod_build_file_generation/requirements_lock.txt rename to gazelle/examples/bzlmod_build_file_generation/requirements_lock.txt diff --git a/examples/bzlmod_build_file_generation/requirements_windows.txt b/gazelle/examples/bzlmod_build_file_generation/requirements_windows.txt similarity index 100% rename from examples/bzlmod_build_file_generation/requirements_windows.txt rename to gazelle/examples/bzlmod_build_file_generation/requirements_windows.txt diff --git a/examples/bzlmod_build_file_generation/runfiles/BUILD.bazel b/gazelle/examples/bzlmod_build_file_generation/runfiles/BUILD.bazel similarity index 100% rename from examples/bzlmod_build_file_generation/runfiles/BUILD.bazel rename to gazelle/examples/bzlmod_build_file_generation/runfiles/BUILD.bazel diff --git a/examples/bzlmod_build_file_generation/runfiles/data/data.txt b/gazelle/examples/bzlmod_build_file_generation/runfiles/data/data.txt similarity index 100% rename from examples/bzlmod_build_file_generation/runfiles/data/data.txt rename to gazelle/examples/bzlmod_build_file_generation/runfiles/data/data.txt diff --git a/examples/bzlmod_build_file_generation/runfiles/runfiles_test.py b/gazelle/examples/bzlmod_build_file_generation/runfiles/runfiles_test.py similarity index 100% rename from examples/bzlmod_build_file_generation/runfiles/runfiles_test.py rename to gazelle/examples/bzlmod_build_file_generation/runfiles/runfiles_test.py