@@ -30,7 +30,28 @@ _PackageSpecificationInfo = getattr(py_internal, "PackageSpecificationInfo", Non
30
30
_STAMP_VALUES = [- 1 , 0 , 1 ]
31
31
32
32
def create_stamp_attr (** kwargs ):
33
- return {"stamp" : attr .int (values = _STAMP_VALUES , ** kwargs )}
33
+ return {
34
+ "stamp" : attr .int (
35
+ values = _STAMP_VALUES ,
36
+ doc = """
37
+ Whether to encode build information into the binary. Possible values:
38
+
39
+ * `stamp = 1`: Always stamp the build information into the binary, even in
40
+ `--nostamp` builds. **This setting should be avoided**, since it potentially kills
41
+ remote caching for the binary and any downstream actions that depend on it.
42
+ * `stamp = 0`: Always replace build information by constant values. This gives
43
+ good build result caching.
44
+ * `stamp = -1`: Embedding of build information is controlled by the
45
+ `--[no]stamp` flag.
46
+
47
+ Stamped binaries are not rebuilt unless their dependencies change.
48
+
49
+ WARNING: Stamping can harm build performance by reducing cache hits and should
50
+ be avoided if possible.
51
+ """ ,
52
+ ** kwargs
53
+ ),
54
+ }
34
55
35
56
def create_srcs_attr (* , mandatory ):
36
57
return {
@@ -40,6 +61,12 @@ def create_srcs_attr(*, mandatory):
40
61
mandatory = mandatory ,
41
62
# Necessary for --compile_one_dependency to work.
42
63
flags = ["DIRECT_COMPILE_TIME_INPUT" ],
64
+ doc = """
65
+ The list of Python source files that are processed to create the target. This
66
+ includes all your checked-in code and may include generated source files. The
67
+ `.py` files belong in `srcs` and library targets belong in `deps`. Other binary
68
+ files that may be needed at run time belong in `data`.
69
+ """ ,
43
70
),
44
71
}
45
72
@@ -51,6 +78,7 @@ def create_srcs_version_attr(values):
51
78
"srcs_version" : attr .string (
52
79
default = "PY2AND3" ,
53
80
values = values ,
81
+ doc = "Defunct, unused, does nothing." ,
54
82
),
55
83
}
56
84
@@ -81,6 +109,13 @@ DATA_ATTRS = {
81
109
"data" : attr .label_list (
82
110
allow_files = True ,
83
111
flags = ["SKIP_CONSTRAINTS_OVERRIDE" ],
112
+ doc = """
113
+ The list of files need by this library at runtime. See comments about
114
+ the [`data` attribute typically defined by rules](https://bazel.build/reference/be/common-definitions#typical-attributes).
115
+
116
+ There is no `py_embed_data` like there is `cc_embed_data` and `go_embed_data`.
117
+ This is because Python has a concept of runtime resources.
118
+ """ ,
84
119
),
85
120
}
86
121
@@ -136,6 +171,16 @@ PY_SRCS_ATTRS = union_attrs(
136
171
# TODO(b/228692666): Google-specific; remove these allowances once
137
172
# the depot is cleaned up.
138
173
allow_rules = DEPS_ATTR_ALLOW_RULES ,
174
+ doc = """
175
+ List of additional libraries to be linked in to the target.
176
+ See comments about
177
+ the [`deps` attribute typically defined by
178
+ rules](https://bazel.build/reference/be/common-definitions#typical-attributes).
179
+ These are typically `py_library` rules.
180
+
181
+ Targets that only provide data files used at runtime belong in the `data`
182
+ attribute.
183
+ """ ,
139
184
),
140
185
# Required attribute, but details vary by rule.
141
186
# Use create_srcs_attr to create one.
0 commit comments