Skip to content

Commit 35391d9

Browse files
authored
chore: support bzlmod (#744)
1 parent ab6940a commit 35391d9

File tree

13 files changed

+94
-2
lines changed

13 files changed

+94
-2
lines changed

.bazelrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
# This lets us glob() up all the files inside the examples to make them inputs to tests
44
# (Note, we cannot use `common --deleted_packages` because the bazel version command doesn't support it)
55
# To update these lines, run tools/bazel_integration_test/update_deleted_packages.sh
6-
build --deleted_packages=examples/build_file_generation,examples/pip_install,examples/pip_parse,examples/pip_parse_vendored,examples/pip_repository_annotations,examples/py_import,examples/relative_requirements,tests/pip_repository_entry_points,tests/pip_deps
7-
query --deleted_packages=examples/build_file_generation,examples/pip_install,examples/pip_parse,examples/pip_parse_vendored,examples/pip_repository_annotations,examples/py_import,examples/relative_requirements,tests/pip_repository_entry_points,tests/pip_deps
6+
build --deleted_packages=examples/build_file_generation,examples/bzlmod,examples/pip_install,examples/pip_parse,examples/pip_parse_vendored,examples/pip_repository_annotations,examples/py_import,examples/relative_requirements,tests/pip_repository_entry_points,tests/pip_deps
7+
query --deleted_packages=examples/build_file_generation,examples/bzlmod,examples/pip_install,examples/pip_parse,examples/pip_parse_vendored,examples/pip_repository_annotations,examples/py_import,examples/relative_requirements,tests/pip_repository_entry_points,tests/pip_deps
88

99
test --test_output=errors
1010

BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ filegroup(
2626
name = "distribution",
2727
srcs = [
2828
"BUILD",
29+
"MODULE.bazel",
2930
"WORKSPACE",
3031
"internal_deps.bzl",
3132
"internal_setup.bzl",

MODULE.bazel

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module(
2+
name = "rules_python",
3+
compatibility_level = 1,
4+
version = "0.0.0",
5+
)
6+
7+
pip_install = use_extension("@rules_python//python:extensions.bzl", "pip_install")
8+
9+
use_repo(
10+
pip_install,
11+
"pypi__click",
12+
"pypi__pip",
13+
"pypi__pip_tools",
14+
"pypi__pkginfo",
15+
"pypi__setuptools",
16+
"pypi__wheel",
17+
)

examples/BUILD

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,7 @@ bazel_integration_test(
4242
name = "relative_requirements_example",
4343
timeout = "long",
4444
)
45+
46+
bazel_integration_test(
47+
name = "bzlmod_example",
48+
)

examples/bzlmod/.bazelrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
common --experimental_enable_bzlmod

examples/bzlmod/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
bazel-*

examples/bzlmod/BUILD.bazel

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test")
2+
3+
py_library(
4+
name = "lib",
5+
srcs = ["__init__.py"],
6+
)
7+
8+
py_binary(
9+
name = "bzlmod",
10+
srcs = ["__main__.py"],
11+
main = "__main__.py",
12+
visibility = ["//:__subpackages__"],
13+
deps = [":lib"],
14+
)
15+
16+
py_test(
17+
name = "test",
18+
srcs = ["test.py"],
19+
deps = [":lib"],
20+
)

examples/bzlmod/MODULE.bazel

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module(
2+
name = "example_bzlmod",
3+
compatibility_level = 1,
4+
version = "0.0.0",
5+
)
6+
7+
bazel_dep(name = "rules_python", version = "0.0.0")
8+
9+
local_path_override(
10+
module_name = "rules_python",
11+
path = "../..",
12+
)

examples/bzlmod/WORKSPACE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Empty file indicating the root of a Bazel workspace.
2+
# Dependencies and setup are in MODULE.bazel.

examples/bzlmod/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# TODO: bzlmod should grant access to pip_install dependencies as well
2+
# import requests
3+
4+
5+
def main(url):
6+
# r = requests.get(url)
7+
# return r.text
8+
return url

0 commit comments

Comments
 (0)