forked from lalten/rules_cpan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBUILD.bazel
97 lines (88 loc) · 3.44 KB
/
BUILD.bazel
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
load("@buildifier_prebuilt//:rules.bzl", "buildifier")
load("@gazelle//:def.bzl", "gazelle")
load("@pip//:requirements.bzl", "all_whl_requirements")
load("@rules_multirun//:defs.bzl", "multirun")
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:map_kind py_library py_library @aspect_rules_py//py:defs.bzl
# gazelle:map_kind py_binary py_binary @aspect_rules_py//py:defs.bzl
# gazelle:map_kind py_test py_test @aspect_rules_py//py:defs.bzl
# gazelle:python_library_naming_convention $package_name$_library
# gazelle:resolve py yaml @pip//pyyaml
# we only need python support
gazelle(
name = "gazelle",
gazelle = "@rules_python_gazelle_plugin//python:gazelle_binary",
)
# generates targets for managing pip dependencies with pip-compile.
compile_pip_requirements(
name = "requirements",
src = "requirements.in",
requirements_txt = "requirements_lock.txt",
requirements_windows = "requirements_windows.txt",
)
# This repository rule fetches the metadata for python packages we
# depend on. That data is required for the gazelle_python_manifest
# rule to update our manifest file.
modules_mapping(
name = "modules_map",
exclude_patterns = [
"^_|(\\._)+", # This is the default.
"(\\.tests)+", # Add a custom one to get rid of the psutil tests.
"^colorama", # Get rid of colorama on Windows.
"^tzdata", # Get rid of tzdata on Windows.
"^lazy_object_proxy\\.cext$", # Get rid of this on Linux because it isn't included on Windows.
],
wheels = all_whl_requirements,
)
modules_mapping(
name = "modules_map_with_types",
exclude_patterns = [
"^_|(\\._)+", # This is the default.
"(\\.tests)+", # Add a custom one to get rid of the psutil tests.
"^colorama", # Get rid of colorama on Windows.
"^tzdata", # Get rid of tzdata on Windows.
"^lazy_object_proxy\\.cext$", # Get rid of this on Linux because it isn't included on Windows.
],
include_stub_packages = True,
modules_mapping_name = "modules_mapping_with_types.json",
wheels = all_whl_requirements,
)
# Gazelle python extension needs a manifest file mapping from
# an import to the installed package that provides it.
# This macro produces two targets:
# - //:gazelle_python_manifest.update can be used with `bazel run`
# to recalculate the manifest
# - //:gazelle_python_manifest.test is a test target ensuring that
# the manifest doesn't need to be updated
# This target updates a file called gazelle_python.yaml, and
# requires that file exist before the target is run.
# When you are using gazelle you need to run this target first.
gazelle_python_manifest(
name = "gazelle_python_manifest",
modules_mapping = ":modules_map",
pip_repository_name = "pip",
tags = ["exclusive"],
)
gazelle_python_manifest(
name = "gazelle_python_manifest_with_types",
manifest = "gazelle_python_with_types.yaml",
modules_mapping = ":modules_map_with_types",
pip_repository_name = "pip",
tags = ["exclusive"],
)
multirun(
name = "update_gazelle_python_manifests",
commands = [
":gazelle_python_manifest.update",
":gazelle_python_manifest_with_types.update",
],
)
buildifier(
name = "buildifier",
exclude_patterns = [
"./.git/*",
"external/*",
],
)