forked from bazel-contrib/rules_python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfeatures.bzl
67 lines (52 loc) · 2.01 KB
/
features.bzl
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
# 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."""
load("@rules_python_internal//:rules_python_config.bzl", "config")
# 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} precompile
:type: bool
True if the precompile attributes are available.
:::{versionadded} 0.33.0
:::
::::
::::{field} py_info_site_packages_symlinks
True if the `PyInfo.site_packages_symlinks` field is available.
:::{versionadded} VERSION_NEXT_FEATURE
:::
::::
::::{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
::::
"""
features = struct(
TYPEDEF = _features_typedef,
# keep sorted
precompile = True,
py_info_site_packages_symlinks = True,
uses_builtin_rules = not config.enable_pystar,
version = _VERSION_PRIVATE if "$Format" not in _VERSION_PRIVATE else "",
)