forked from bazel-contrib/rules_python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfeatures.bzl
More file actions
149 lines (121 loc) · 4.03 KB
/
Copy pathfeatures.bzl
File metadata and controls
149 lines (121 loc) · 4.03 KB
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# Copyright 2024 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Allows detecting of rules_python features that aren't easily detected."""
# This is a magic string expanded by `git archive`, as set by `.gitattributes`
# See https://git-scm.com/docs/git-archive/2.29.0#Documentation/git-archive.txt-export-subst
_VERSION_PRIVATE = "$Format:%(describe:tags=true)$"
def _features_typedef():
"""Information about features rules_python has implemented.
::::{field} targets
:type: dict[str, bool]
A map of public API targets available in rules_python for feature detection
purposes.
:::{versionadded} 1.9.0
:::
::::
::::{field} headers_abi3
:type: bool
True if the {obj}`@rules_python//python/cc:current_py_cc_headers_abi3`
target is available.
:::{versionadded} 1.7.0
:::
::::
::::{field} precompile
:type: bool
True if the precompile attributes are available.
:::{versionadded} 0.33.0
:::
::::
::::{field} loadable_symbols
:type: dict[str, list[str]]
A map of bzl paths to the list of public symbols they export.
:::{versionadded} 2.2.0
:::
::::
::::{field} py_info_venv_symlinks
True if the `PyInfo.venv_symlinks` field is available.
:::{versionadded} 1.5.0
:::
::::
::::{field} uses_builtin_rules
:type: bool
True if the rules are using the Bazel-builtin implementation.
:::{versionadded} 1.1.0
:::
::::
::::{field} version
:type: str
The rules_python version. This is a semver format, e.g. `X.Y.Z` with
optional trailing `-rcN`. For unreleased versions, it is an empty string.
:::{versionadded} 0.38.0
::::
::::{field} zipapp_rules
:type: bool
Whether the rules_python version has the `py_zipapp_*` rules
:::{versionadded} 1.9.0
::::
"""
_TARGETS = {
"//command_line_option:build_runfile_links": True,
"//command_line_option:enable_runfiles": True,
"//command_line_option:extra_toolchains": True,
"//python/api:api": True,
"//python/api:executables": True,
"//python/api:libraries": True,
"//python/cc:current_py_cc_headers_abi3": True,
"//python/cc:py_cc_toolchain": True,
"//python/cc:py_cc_toolchain_info": True,
"//python/config_settings:venv": True,
"//python/entry_points:py_console_script_binary": True,
"//python/local_toolchains:repos": True,
"//python:defs": True,
"//python:features": True,
"//python:packaging": True,
"//python:pip": True,
"//python:proto": True,
"//python:py_binary": True,
"//python:py_cc_link_params_info": True,
"//python:py_exec_tools_info": True,
"//python:py_exec_tools_toolchain": True,
"//python:py_executable_info": True,
"//python:py_import": True,
"//python:py_info": True,
"//python:py_library": True,
"//python:py_runtime": True,
"//python:py_runtime_info": True,
"//python:py_runtime_pair": True,
"//python:py_test": True,
"//python:repositories": True,
"//python:versions": True,
}
_LOADABLE_SYMBOLS = {
"//python:py_info.bzl": [
# keep sorted
"PyInfo",
"VenvSymlinkEntry",
"VenvSymlinkKind",
],
}
features = struct(
TYPEDEF = _features_typedef,
# keep sorted
headers_abi3 = True,
loadable_symbols = _LOADABLE_SYMBOLS,
precompile = True,
py_info_venv_symlinks = True,
targets = _TARGETS,
uses_builtin_rules = False,
version = _VERSION_PRIVATE if "$Format" not in _VERSION_PRIVATE else "",
zipapp_rules = True,
)