Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(bazel): test gazelle with rules_py #505

Draft
wants to merge 1 commit into
base: beta
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@
pyrovelocity BUILD
"""

load("@aspect_rules_py//py:defs.bzl", "py_test")
load("@bazel_gazelle//:def.bzl", "gazelle")
load("@pip//:requirements.bzl", "all_whl_requirements")
load("@rules_python//python:pip.bzl", "compile_pip_requirements")
load("@rules_python_gazelle_plugin//manifest:defs.bzl", "gazelle_python_manifest")
load("@rules_python_gazelle_plugin//modules_mapping:def.bzl", "modules_mapping")

# gazelle:exclude reproducibility/**
# gazelle:exclude src/pyrovelocity/flytezen/**

compile_pip_requirements(
name = "requirements",
Expand All @@ -11,3 +19,27 @@ compile_pip_requirements(
requirements_txt = "requirements-bazel.txt",
timeout = "moderate",
)

modules_mapping(
name = "modules_map",
exclude_patterns = [
"^_|(\\._)+", # This is the default.
"(\\.tests)+", # Add a custom one to get rid of the psutil tests.
],
wheels = all_whl_requirements,
)

gazelle_python_manifest(
name = "gazelle_python_manifest",
modules_mapping = ":modules_map",
pip_repository_name = "pip",
requirements = [
"//:requirements-bazel.txt",
],
tags = ["exclusive"],
)

gazelle(
name = "gazelle",
gazelle = "@rules_python_gazelle_plugin//python:gazelle_binary",
)
12 changes: 11 additions & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,23 @@ module(
compatibility_level = 1,
)

bazel_dep(name = "rules_python", version = "0.28.0")
bazel_dep(name = "aspect_rules_py", version = "0.5.0")
bazel_dep(name = "rules_python", dev_dependency = True, version = "0.28.0")
bazel_dep(name = "rules_python_gazelle_plugin", version = "0.27.1")
bazel_dep(name = "gazelle", version = "0.35.0", repo_name = "bazel_gazelle")

python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(
configure_coverage_tool = True,
python_version = "3.10",
)
# use_repo(python, "python3_10")
# use_repo(python, "python3_10_toolchains")

# # Register an already-defined toolchain so that Bazel can use it during toolchain resolution.
# register_toolchains(
# "@python3_10_toolchains//:all",
# )

pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")

Expand Down
Loading