blob: 40dfb6aed11922ccbd384f281699a5fe864e691b [file] [log] [blame]
module(
name = "example_bzlmod",
version = "0.0.0",
compatibility_level = 1,
)
bazel_dep(name = "bazel_skylib", version = "1.4.1")
bazel_dep(name = "rules_python", version = "0.0.0")
local_path_override(
module_name = "rules_python",
path = "../..",
)
# This name is generated by python.toolchain(), and is later passed
# to use_repo() and interpreter.install().
PYTHON_NAME_39 = "python_3_9"
INTERPRETER_NAME_39 = "interpreter_39"
PYTHON_NAME_310 = "python_3_10"
INTERPRETER_NAME_310 = "interpreter_310"
# We next initialize the python toolchain using the extension.
# You can set different Python versions in this block.
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(
configure_coverage_tool = True,
# Only set when you have mulitple toolchain versions.
is_default = True,
python_version = "3.9",
)
# We are also using a second version of Python in this project.
# Typically you will only need a single version of Python, but
# If you need a different vesion we support more than one.
# Note: we do not supporting using multiple pip extensions, this is
# work in progress.
python.toolchain(
configure_coverage_tool = True,
python_version = "3.10",
)
# You only need to load this repositories if you are using muiltple Python versions.
# See the tests folder for various examples.
use_repo(python, PYTHON_NAME_39, "python_aliases")
# The interpreter extension discovers the platform specific Python binary.
# It creates a symlink to the binary, and we pass the label to the following
# pip.parse call.
interpreter = use_extension("@rules_python//python/extensions:interpreter.bzl", "interpreter")
interpreter.install(
name = INTERPRETER_NAME_39,
python_name = PYTHON_NAME_39,
)
# This second call is only needed if you are using mulitple different
# Python versions/interpreters.
interpreter.install(
name = INTERPRETER_NAME_310,
python_name = PYTHON_NAME_310,
)
use_repo(interpreter, INTERPRETER_NAME_39, INTERPRETER_NAME_310)
pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
pip.parse(
name = "pip",
# Intentionally set it false because the "true" case is already
# covered by examples/bzlmod_build_file_generation
incompatible_generate_aliases = False,
python_interpreter_target = "@{}//:python".format(INTERPRETER_NAME_39),
requirements_lock = "//:requirements_lock.txt",
requirements_windows = "//:requirements_windows.txt",
)
use_repo(pip, "pip")
bazel_dep(name = "other_module", version = "", repo_name = "our_other_module")
local_path_override(
module_name = "other_module",
path = "other_module",
)