1# This file replaces the WORKSPACE file when using bzlmod. 2 3# module declares certain properties of the Bazel module represented by the current Bazel repo. 4# These properties are either essential metadata of the module (such as the name and version), 5# or affect behavior of the current module and its dependents. 6module( 7 name = "example_bzlmod_build_file_generation", 8 version = "0.0.0", 9 compatibility_level = 1, 10) 11 12# The following stanza defines the dependency rules_python. 13# For typical setups you set the version. 14# See the releases page for available versions. 15# https://github.com/bazelbuild/rules_python/releases 16bazel_dep(name = "rules_python", version = "0.0.0") 17 18# The following loads rules_python from the file system. 19# For usual setups you should remove this local_path_override block. 20local_path_override( 21 module_name = "rules_python", 22 path = "../..", 23) 24 25# The following stanza defines the dependency rules_python_gazelle_plugin. 26# For typical setups you set the version. 27# See the releases page for available versions. 28# https://github.com/bazelbuild/rules_python/releases 29bazel_dep(name = "rules_python_gazelle_plugin", version = "0.0.0") 30 31# The following starlark loads the gazelle plugin from the file system. 32# For usual setups you should remove this local_path_override block. 33local_path_override( 34 module_name = "rules_python_gazelle_plugin", 35 path = "../../gazelle", 36) 37 38# The following stanza defines the dependency for gazelle 39# See here https://github.com/bazelbuild/bazel-gazelle/releases/ for the 40# latest version. 41bazel_dep(name = "gazelle", version = "0.30.0", repo_name = "bazel_gazelle") 42 43# The following stanze returns a proxy object representing a module extension; 44# its methods can be invoked to create module extension tags. 45python = use_extension("@rules_python//python/extensions:python.bzl", "python") 46 47# We next initialize the python toolchain using the extension. 48# You can set different Python versions in this block. 49python.toolchain( 50 configure_coverage_tool = True, 51 is_default = True, 52 python_version = "3.9", 53) 54 55# Use the extension, pip.parse, to call the `pip_repository` rule that invokes 56# `pip`, with `incremental` set. The pip call accepts a locked/compiled 57# requirements file and installs the dependencies listed within. 58# Those dependencies become available in a generated `requirements.bzl` file. 59# You can instead check this `requirements.bzl` file into your repo. 60# Because this project has different requirements for windows vs other 61# operating systems, we have requirements for each. 62pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip") 63pip.parse( 64 hub_name = "pip", 65 # The interpreter_target attribute points to the interpreter to 66 # use for running pip commands to download the packages in the 67 # requirements file. 68 # As a best practice, we use the same interpreter as the toolchain 69 # that was configured above; this ensures the same Python version 70 # is used for both resolving dependencies and running tests/binaries. 71 # If this isn't specified, then you'll get whatever is locally installed 72 # on your system. 73 python_version = "3.9", 74 requirements_lock = "//:requirements_lock.txt", 75 requirements_windows = "//:requirements_windows.txt", 76) 77 78# Imports the pip toolchain generated by the given module extension into the scope of the current module. 79use_repo(pip, "pip") 80 81# This project includes a different module that is on the local file system. 82# Add the module to this parent project. 83bazel_dep(name = "other_module", version = "", repo_name = "our_other_module") 84local_path_override( 85 module_name = "other_module", 86 path = "other_module", 87) 88