1# Copyright 2024 The Bazel Authors. All rights reserved. 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15"""Common attributes between bzlmod pip.parse and workspace pip_parse. 16 17A common attributes shared between bzlmod and workspace implementations 18stored in a separate file to avoid unnecessary refetching of the 19repositories.""" 20 21load(":attrs.bzl", COMMON_ATTRS = "ATTRS") 22 23ATTRS = { 24 "requirements_by_platform": attr.label_keyed_string_dict( 25 doc = """\ 26The requirements files and the comma delimited list of target platforms as values. 27 28The keys are the requirement files and the values are comma-separated platform 29identifiers. For now we only support `<os>_<cpu>` values that are present in 30`@platforms//os` and `@platforms//cpu` packages respectively. 31""", 32 ), 33 "requirements_darwin": attr.label( 34 allow_single_file = True, 35 doc = "Override the requirements_lock attribute when the host platform is Mac OS", 36 ), 37 "requirements_linux": attr.label( 38 allow_single_file = True, 39 doc = "Override the requirements_lock attribute when the host platform is Linux", 40 ), 41 "requirements_lock": attr.label( 42 allow_single_file = True, 43 doc = """\ 44A fully resolved 'requirements.txt' pip requirement file containing the 45transitive set of your dependencies. If this file is passed instead of 46'requirements' no resolve will take place and pip_repository will create 47individual repositories for each of your dependencies so that wheels are 48fetched/built only for the targets specified by 'build/run/test'. Note that if 49your lockfile is platform-dependent, you can use the `requirements_[platform]` 50attributes. 51 52Note, that in general requirements files are compiled for a specific platform, 53but sometimes they can work for multiple platforms. `rules_python` right now 54supports requirements files that are created for a particular platform without 55platform markers. 56""", 57 ), 58 "requirements_windows": attr.label( 59 allow_single_file = True, 60 doc = "Override the requirements_lock attribute when the host platform is Windows", 61 ), 62 "use_hub_alias_dependencies": attr.bool( 63 default = False, 64 doc = """\ 65Controls if the hub alias dependencies are used. If set to true, then the 66group_library will be included in the hub repo. 67 68True will become default in a subsequent release. 69""", 70 ), 71} 72 73ATTRS.update(**COMMON_ATTRS) 74