...
1load("@pip//:requirements.bzl", "all_whl_requirements")
2load("@rules_python//python:pip.bzl", "compile_pip_requirements")
3load("@rules_python_gazelle_plugin//manifest:defs.bzl", "gazelle_python_manifest")
4load("@rules_python_gazelle_plugin//modules_mapping:def.bzl", "modules_mapping")
5load("//hack/build/rules/container:index.bzl", "push_third_party_images")
6load(":images.bzl", "IMAGES")
7
8package(default_visibility = ["//visibility:public"])
9
10exports_files([
11 "go.bzl",
12])
13
14push_third_party_images(imgs = IMAGES)
15
16# This rule adds a convenient way to update the requirements file.
17compile_pip_requirements(
18 name = "pip_requirements",
19 src = "requirements.in",
20 requirements_txt = "requirements_lock.txt",
21)
22
23# This repository rule fetches the metadata for python packages we
24# depend on. That data is required for the gazelle_python_manifest
25# rule to update our manifest file.
26# To see what this rule does, try `bazel run @modules_map//:print`
27modules_mapping(
28 name = "modules_map",
29 exclude_patterns = [
30 "^_|(\\._)+", # This is the default.
31 "(\\.tests)+", # Add a custom one to get rid of the psutil tests.
32 ],
33 wheels = all_whl_requirements,
34)
35
36# Gazelle python extension needs a manifest file mapping from
37# an import to the installed package that provides it.
38# This macro produces two targets:
39# - //:gazelle_python_manifest.update can be used with `bazel run`
40# to recalculate the manifest
41# - //:gazelle_python_manifest.test is a test target ensuring that
42# the manifest doesn't need to be updated
43gazelle_python_manifest(
44 name = "gazelle_python_manifest",
45 modules_mapping = ":modules_map",
46 pip_repository_name = "pip",
47 requirements = "requirements_lock.txt",
48)
View as plain text