• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2021 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
15load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
16load("@bazel_skylib//rules:common_settings.bzl", "bool_setting")
17load("//python:py_binary.bzl", "py_binary")
18load("//python:py_library.bzl", "py_library")
19load("//python:versions.bzl", "print_toolchains_checksums")
20load(":py_exec_tools_toolchain.bzl", "current_interpreter_executable")
21load(":sentinel.bzl", "sentinel")
22load(":stamp.bzl", "stamp_build_setting")
23
24package(
25    default_visibility = ["//:__subpackages__"],
26)
27
28licenses(["notice"])
29
30filegroup(
31    name = "distribution",
32    srcs = glob(["**"]) + [
33        "//python/private/api:distribution",
34        "//python/private/proto:distribution",
35        "//python/private/pypi:distribution",
36        "//python/private/whl_filegroup:distribution",
37        "//tools/build_defs/python/private:distribution",
38    ],
39    visibility = ["//python:__pkg__"],
40)
41
42filegroup(
43    name = "coverage_deps",
44    srcs = ["coverage_deps.bzl"],
45    visibility = ["//tools/private/update_deps:__pkg__"],
46)
47
48# Filegroup of bzl files that can be used by downstream rules for documentation generation
49filegroup(
50    name = "bzl",
51    srcs = glob(["**/*.bzl"]),
52    visibility = ["//python:__pkg__"],
53)
54
55bzl_library(
56    name = "attributes_bzl",
57    srcs = ["attributes.bzl"],
58    deps = [
59        ":common_bzl",
60        ":enum_bzl",
61        ":flags_bzl",
62        ":py_info_bzl",
63        ":py_internal_bzl",
64        ":reexports_bzl",
65        ":rules_cc_srcs_bzl",
66        ":semantics_bzl",
67        "@bazel_skylib//rules:common_settings",
68    ],
69)
70
71bzl_library(
72    name = "auth_bzl",
73    srcs = ["auth.bzl"],
74    deps = [":bazel_tools_bzl"],
75)
76
77bzl_library(
78    name = "runtime_env_toolchain_bzl",
79    srcs = ["runtime_env_toolchain.bzl"],
80    deps = [
81        ":py_exec_tools_toolchain_bzl",
82        ":toolchain_types_bzl",
83        "//python:py_runtime_bzl",
84        "//python:py_runtime_pair_bzl",
85    ],
86)
87
88bzl_library(
89    name = "builders_bzl",
90    srcs = ["builders.bzl"],
91    deps = [
92        "@bazel_skylib//lib:types",
93    ],
94)
95
96bzl_library(
97    name = "bzlmod_enabled_bzl",
98    srcs = ["bzlmod_enabled.bzl"],
99)
100
101bzl_library(
102    name = "cc_helper_bzl",
103    srcs = ["cc_helper.bzl"],
104    deps = [":py_internal_bzl"],
105)
106
107bzl_library(
108    name = "common_bazel_bzl",
109    srcs = ["common_bazel.bzl"],
110    deps = [
111        ":attributes_bzl",
112        ":common_bzl",
113        ":py_cc_link_params_info_bzl",
114        ":py_internal_bzl",
115        ":py_interpreter_program_bzl",
116        ":toolchain_types_bzl",
117        "@bazel_skylib//lib:paths",
118    ],
119)
120
121bzl_library(
122    name = "common_bzl",
123    srcs = ["common.bzl"],
124    deps = [
125        ":cc_helper_bzl",
126        ":py_info_bzl",
127        ":py_internal_bzl",
128        ":reexports_bzl",
129        ":rules_cc_srcs_bzl",
130        ":semantics_bzl",
131    ],
132)
133
134bzl_library(
135    name = "config_settings_bzl",
136    srcs = ["config_settings.bzl"],
137    deps = [
138        ":semver_bzl",
139        "@bazel_skylib//lib:selects",
140        "@bazel_skylib//rules:common_settings",
141    ],
142)
143
144bzl_library(
145    name = "coverage_deps_bzl",
146    srcs = ["coverage_deps.bzl"],
147    deps = [
148        ":bazel_tools_bzl",
149        ":version_label_bzl",
150    ],
151)
152
153bzl_library(
154    name = "enum_bzl",
155    srcs = ["enum.bzl"],
156)
157
158bzl_library(
159    name = "envsubst_bzl",
160    srcs = ["envsubst.bzl"],
161)
162
163bzl_library(
164    name = "flags_bzl",
165    srcs = ["flags.bzl"],
166    deps = [
167        ":enum_bzl",
168        "@bazel_skylib//rules:common_settings",
169    ],
170)
171
172bzl_library(
173    name = "full_version_bzl",
174    srcs = ["full_version.bzl"],
175)
176
177bzl_library(
178    name = "glob_excludes_bzl",
179    srcs = ["glob_excludes.bzl"],
180    deps = [":util_bzl"],
181)
182
183bzl_library(
184    name = "internal_config_repo_bzl",
185    srcs = ["internal_config_repo.bzl"],
186    deps = [":bzlmod_enabled_bzl"],
187)
188
189bzl_library(
190    name = "is_standalone_interpreter_bzl",
191    srcs = ["is_standalone_interpreter.bzl"],
192    deps = [
193        ":repo_utils_bzl",
194    ],
195)
196
197bzl_library(
198    name = "normalize_name_bzl",
199    srcs = ["normalize_name.bzl"],
200)
201
202bzl_library(
203    name = "python_bzl",
204    srcs = ["python.bzl"],
205    deps = [
206        ":full_version_bzl",
207        ":python_register_toolchains_bzl",
208        ":pythons_hub_bzl",
209        ":repo_utils_bzl",
210        ":semver_bzl",
211        ":toolchains_repo_bzl",
212        ":util_bzl",
213        "@bazel_features//:features",
214    ],
215)
216
217bzl_library(
218    name = "python_register_toolchains_bzl",
219    srcs = ["python_register_toolchains.bzl"],
220    deps = [
221        ":auth_bzl",
222        ":bazel_tools_bzl",
223        ":coverage_deps_bzl",
224        ":full_version_bzl",
225        ":internal_config_repo_bzl",
226        ":python_repository_bzl",
227        ":toolchains_repo_bzl",
228        "//python:versions_bzl",
229        "//python/private/pypi:deps_bzl",
230    ],
231)
232
233bzl_library(
234    name = "python_repository_bzl",
235    srcs = ["python_repository.bzl"],
236    deps = [
237        ":auth_bzl",
238        ":repo_utils_bzl",
239        ":text_util_bzl",
240        "//python:versions_bzl",
241    ],
242)
243
244bzl_library(
245    name = "python_register_multi_toolchains_bzl",
246    srcs = ["python_register_multi_toolchains.bzl"],
247    deps = [
248        ":python_register_toolchains_bzl",
249        ":toolchains_repo_bzl",
250        "//python:versions_bzl",
251    ],
252)
253
254bzl_library(
255    name = "pythons_hub_bzl",
256    srcs = ["pythons_hub.bzl"],
257    deps = [
258        ":py_toolchain_suite_bzl",
259        ":text_util_bzl",
260        "//python:versions_bzl",
261    ],
262)
263
264bzl_library(
265    name = "py_binary_macro_bzl",
266    srcs = ["py_binary_macro.bzl"],
267    deps = [
268        ":common_bzl",
269        ":py_binary_rule_bzl",
270    ],
271)
272
273bzl_library(
274    name = "py_binary_rule_bzl",
275    srcs = ["py_binary_rule.bzl"],
276    deps = [
277        ":attributes_bzl",
278        ":py_executable_bazel_bzl",
279        ":semantics_bzl",
280        "@bazel_skylib//lib:dicts",
281    ],
282)
283
284bzl_library(
285    name = "py_cc_link_params_info_bzl",
286    srcs = ["py_cc_link_params_info.bzl"],
287    deps = [
288        ":rules_cc_srcs_bzl",
289        ":util_bzl",
290    ],
291)
292
293bzl_library(
294    name = "py_cc_toolchain_macro_bzl",
295    srcs = ["py_cc_toolchain_macro.bzl"],
296    deps = [
297        ":py_cc_toolchain_rule_bzl",
298    ],
299)
300
301bzl_library(
302    name = "py_cc_toolchain_rule_bzl",
303    srcs = ["py_cc_toolchain_rule.bzl"],
304    deps = [
305        ":py_cc_toolchain_info_bzl",
306        ":rules_cc_srcs_bzl",
307        ":util_bzl",
308        "@bazel_skylib//rules:common_settings",
309    ],
310)
311
312bzl_library(
313    name = "py_cc_toolchain_info_bzl",
314    srcs = ["py_cc_toolchain_info.bzl"],
315)
316
317bzl_library(
318    name = "py_console_script_binary_bzl",
319    srcs = [
320        "py_console_script_binary.bzl",
321        "py_console_script_gen.bzl",
322    ],
323    visibility = ["//python/entry_points:__pkg__"],
324    deps = [
325        "//python:py_binary_bzl",
326    ],
327)
328
329bzl_library(
330    name = "py_exec_tools_info_bzl",
331    srcs = ["py_exec_tools_info.bzl"],
332)
333
334bzl_library(
335    name = "py_exec_tools_toolchain_bzl",
336    srcs = ["py_exec_tools_toolchain.bzl"],
337    deps = [
338        ":py_exec_tools_info_bzl",
339        ":sentinel_bzl",
340        ":toolchain_types_bzl",
341        "@bazel_skylib//lib:paths",
342        "@bazel_skylib//rules:common_settings",
343    ],
344)
345
346bzl_library(
347    name = "py_executable_bazel_bzl",
348    srcs = ["py_executable_bazel.bzl"],
349    deps = [
350        ":attributes_bzl",
351        ":common_bazel_bzl",
352        ":common_bzl",
353        ":py_executable_bzl",
354        ":py_internal_bzl",
355        ":py_runtime_info_bzl",
356        ":semantics_bzl",
357    ],
358)
359
360bzl_library(
361    name = "py_executable_bzl",
362    srcs = ["py_executable.bzl"],
363    deps = [
364        ":attributes_bzl",
365        ":cc_helper_bzl",
366        ":common_bzl",
367        ":flags_bzl",
368        ":py_cc_link_params_info_bzl",
369        ":py_executable_info_bzl",
370        ":py_info_bzl",
371        ":py_internal_bzl",
372        ":py_runtime_info_bzl",
373        ":rules_cc_srcs_bzl",
374        ":toolchain_types_bzl",
375        "@bazel_skylib//lib:dicts",
376        "@bazel_skylib//lib:structs",
377        "@bazel_skylib//rules:common_settings",
378    ],
379)
380
381bzl_library(
382    name = "py_executable_info_bzl",
383    srcs = ["py_executable_info.bzl"],
384)
385
386bzl_library(
387    name = "py_info_bzl",
388    srcs = ["py_info.bzl"],
389    deps = [
390        ":builders_bzl",
391        ":reexports_bzl",
392        ":util_bzl",
393        "@rules_python_internal//:rules_python_config_bzl",
394    ],
395)
396
397bzl_library(
398    name = "py_internal_bzl",
399    srcs = ["py_internal.bzl"],
400    deps = ["@rules_python_internal//:py_internal_bzl"],
401)
402
403bzl_library(
404    name = "py_interpreter_program_bzl",
405    srcs = ["py_interpreter_program.bzl"],
406    deps = ["@bazel_skylib//rules:common_settings"],
407)
408
409bzl_library(
410    name = "py_library_bzl",
411    srcs = ["py_library.bzl"],
412    deps = [
413        ":attributes_bzl",
414        ":common_bzl",
415        ":flags_bzl",
416        ":py_cc_link_params_info_bzl",
417        ":py_internal_bzl",
418        ":toolchain_types_bzl",
419        "@bazel_skylib//lib:dicts",
420        "@bazel_skylib//rules:common_settings",
421    ],
422)
423
424bzl_library(
425    name = "py_library_macro_bzl",
426    srcs = ["py_library_macro.bzl"],
427    deps = [":py_library_rule_bzl"],
428)
429
430bzl_library(
431    name = "py_library_rule_bzl",
432    srcs = ["py_library_rule.bzl"],
433    deps = [
434        ":common_bazel_bzl",
435        ":common_bzl",
436        ":py_library_bzl",
437    ],
438)
439
440bzl_library(
441    name = "py_package_bzl",
442    srcs = ["py_package.bzl"],
443    visibility = ["//:__subpackages__"],
444    deps = [
445        ":builders_bzl",
446        ":py_info_bzl",
447    ],
448)
449
450bzl_library(
451    name = "py_runtime_info_bzl",
452    srcs = ["py_runtime_info.bzl"],
453    deps = [":util_bzl"],
454)
455
456bzl_library(
457    name = "py_repositories_bzl",
458    srcs = ["py_repositories.bzl"],
459    deps = [
460        ":bazel_tools_bzl",
461        ":internal_config_repo_bzl",
462        ":pythons_hub_bzl",
463        "//python:versions_bzl",
464        "//python/private/pypi:deps_bzl",
465    ],
466)
467
468bzl_library(
469    name = "py_runtime_macro_bzl",
470    srcs = ["py_runtime_macro.bzl"],
471    deps = [":py_runtime_rule_bzl"],
472)
473
474bzl_library(
475    name = "py_runtime_rule_bzl",
476    srcs = ["py_runtime_rule.bzl"],
477    deps = [
478        ":attributes_bzl",
479        ":flags_bzl",
480        ":py_internal_bzl",
481        ":py_runtime_info_bzl",
482        ":reexports_bzl",
483        ":util_bzl",
484        "@bazel_skylib//lib:dicts",
485        "@bazel_skylib//lib:paths",
486        "@bazel_skylib//rules:common_settings",
487    ],
488)
489
490bzl_library(
491    name = "py_runtime_pair_macro_bzl",
492    srcs = ["py_runtime_pair_macro.bzl"],
493    visibility = ["//:__subpackages__"],
494    deps = [":py_runtime_pair_rule_bzl"],
495)
496
497bzl_library(
498    name = "py_runtime_pair_rule_bzl",
499    srcs = ["py_runtime_pair_rule.bzl"],
500    deps = [
501        "//python:py_runtime_bzl",
502        "//python:py_runtime_info_bzl",
503        "@bazel_skylib//rules:common_settings",
504    ],
505)
506
507bzl_library(
508    name = "py_test_macro_bzl",
509    srcs = ["py_test_macro.bzl"],
510    deps = [
511        ":common_bazel_bzl",
512        ":py_test_rule_bzl",
513    ],
514)
515
516bzl_library(
517    name = "py_test_rule_bzl",
518    srcs = ["py_test_rule.bzl"],
519    deps = [
520        ":attributes_bzl",
521        ":common_bzl",
522        ":py_executable_bazel_bzl",
523        ":semantics_bzl",
524        "@bazel_skylib//lib:dicts",
525    ],
526)
527
528bzl_library(
529    name = "py_toolchain_suite_bzl",
530    srcs = ["py_toolchain_suite.bzl"],
531    deps = [
532        ":config_settings_bzl",
533        ":text_util_bzl",
534        ":toolchain_types_bzl",
535        "@bazel_skylib//lib:selects",
536    ],
537)
538
539bzl_library(
540    name = "py_wheel_bzl",
541    srcs = ["py_wheel.bzl"],
542    visibility = ["//:__subpackages__"],
543    deps = [
544        ":py_package_bzl",
545        ":stamp_bzl",
546    ],
547)
548
549bzl_library(
550    name = "reexports_bzl",
551    srcs = ["reexports.bzl"],
552    visibility = [
553        "//:__subpackages__",
554    ],
555    deps = [
556        ":bazel_tools_bzl",
557        "@rules_python_internal//:rules_python_config_bzl",
558    ],
559)
560
561bzl_library(
562    name = "register_extension_info_bzl",
563    srcs = ["register_extension_info.bzl"],
564)
565
566bzl_library(
567    name = "repo_utils_bzl",
568    srcs = ["repo_utils.bzl"],
569)
570
571bzl_library(
572    name = "semver_bzl",
573    srcs = ["semver.bzl"],
574)
575
576bzl_library(
577    name = "sentinel_bzl",
578    srcs = ["sentinel.bzl"],
579)
580
581bzl_library(
582    name = "stamp_bzl",
583    srcs = ["stamp.bzl"],
584    visibility = ["//:__subpackages__"],
585)
586
587bzl_library(
588    name = "text_util_bzl",
589    srcs = ["text_util.bzl"],
590)
591
592bzl_library(
593    name = "toolchains_repo_bzl",
594    srcs = ["toolchains_repo.bzl"],
595    deps = [
596        ":repo_utils_bzl",
597        ":text_util_bzl",
598        "//python:versions_bzl",
599    ],
600)
601
602bzl_library(
603    name = "toolchain_types_bzl",
604    srcs = ["toolchain_types.bzl"],
605)
606
607bzl_library(
608    name = "util_bzl",
609    srcs = ["util.bzl"],
610    visibility = [
611        "//:__subpackages__",
612    ],
613    deps = [
614        "@bazel_skylib//lib:types",
615        "@rules_python_internal//:rules_python_config_bzl",
616    ],
617)
618
619bzl_library(
620    name = "version_label_bzl",
621    srcs = ["version_label.bzl"],
622)
623
624# @bazel_tools can't define bzl_library itself, so we just put a wrapper around it.
625bzl_library(
626    name = "bazel_tools_bzl",
627    srcs = [
628        # This set of sources is overly broad, but it's the only public
629        # target available across Bazel versions that has all the necessary
630        # sources.
631        "@bazel_tools//tools:bzl_srcs",
632    ],
633)
634
635bzl_library(
636    name = "rules_cc_srcs_bzl",
637    srcs = [
638        # rules_cc 0.0.13 and earlier load cc_proto_libary (and thus protobuf@),
639        # but their bzl srcs targets don't transitively refer to protobuf.
640        "@com_google_protobuf//:bzl_srcs",
641        # NOTE: As of rules_cc 0.10, cc:bzl_srcs no longer contains
642        # everything and sub-targets must be used instead
643        "@rules_cc//cc:bzl_srcs",
644        "@rules_cc//cc/common",
645        "@rules_cc//cc/toolchains:toolchain_rules",
646    ],
647    deps = [
648        ":bazel_tools_bzl",
649        "@rules_cc//cc/common",
650    ],
651)
652
653bzl_library(
654    name = "semantics_bzl",
655    srcs = ["semantics.bzl"],
656)
657
658# Needed to define bzl_library targets for docgen. (We don't define the
659# bzl_library target here because it'd give our users a transitive dependency
660# on Skylib.)
661exports_files(
662    [
663        "coverage.patch",
664        "repack_whl.py",
665        "py_package.bzl",
666        "py_wheel.bzl",
667        "py_wheel_normalize_pep440.bzl",
668        "reexports.bzl",
669        "stamp.bzl",
670        "util.bzl",
671    ],
672    visibility = ["//:__subpackages__"],
673)
674
675exports_files(
676    ["python_bootstrap_template.txt"],
677    # Not actually public. Only public because it's an implicit dependency of
678    # py_runtime.
679    visibility = ["//visibility:public"],
680)
681
682filegroup(
683    name = "stage1_bootstrap_template",
684    srcs = ["stage1_bootstrap_template.sh"],
685    # Not actually public. Only public because it's an implicit dependency of
686    # py_runtime.
687    visibility = ["//visibility:public"],
688)
689
690filegroup(
691    name = "stage2_bootstrap_template",
692    srcs = ["stage2_bootstrap_template.py"],
693    # Not actually public. Only public because it's an implicit dependency of
694    # py_runtime.
695    visibility = ["//visibility:public"],
696)
697
698filegroup(
699    name = "zip_main_template",
700    srcs = ["zip_main_template.py"],
701    # Not actually public. Only public because it's an implicit dependency of
702    # py_runtime.
703    visibility = ["//visibility:public"],
704)
705
706filegroup(
707    name = "site_init_template",
708    srcs = ["site_init_template.py"],
709    # Not actually public. Only public because it's an implicit dependency of
710    # py_runtime.
711    visibility = ["//visibility:public"],
712)
713
714# NOTE: Windows builds don't use this bootstrap. Instead, a native Windows
715# program locates some Python exe and runs `python.exe foo.zip` which
716# runs the __main__.py in the zip file.
717alias(
718    name = "bootstrap_template",
719    actual = select({
720        ":is_script_bootstrap_enabled": "stage1_bootstrap_template.sh",
721        "//conditions:default": "python_bootstrap_template.txt",
722    }),
723    # Not actually public. Only public because it's an implicit dependency of
724    # py_runtime.
725    visibility = ["//visibility:public"],
726)
727
728# Used to determine the use of `--stamp` in Starlark rules
729stamp_build_setting(name = "stamp")
730
731config_setting(
732    name = "is_script_bootstrap_enabled",
733    flag_values = {
734        "//python/config_settings:bootstrap_impl": "script",
735    },
736)
737
738# This should only be set by analysis tests to expose additional metadata to
739# aid testing, so a setting instead of a flag.
740bool_setting(
741    name = "visible_for_testing",
742    build_setting_default = False,
743    # This is only because it is an implicit dependency by the toolchains.
744    visibility = ["//visibility:public"],
745)
746
747print_toolchains_checksums(name = "print_toolchains_checksums")
748
749# Used for py_console_script_gen rule
750py_binary(
751    name = "py_console_script_gen_py",
752    srcs = ["py_console_script_gen.py"],
753    main = "py_console_script_gen.py",
754    visibility = [
755        "//visibility:public",
756    ],
757)
758
759py_binary(
760    name = "py_wheel_dist",
761    srcs = ["py_wheel_dist.py"],
762    visibility = ["//visibility:public"],
763)
764
765py_library(
766    name = "py_console_script_gen_lib",
767    srcs = ["py_console_script_gen.py"],
768    imports = ["../.."],
769    visibility = [
770        "//tests/entry_points:__pkg__",
771    ],
772)
773
774# The current toolchain's interpreter as an excutable, usable with
775# executable=True attributes.
776current_interpreter_executable(
777    name = "current_interpreter_executable",
778    # Not actually public. Only public because it's an implicit dependency of
779    # py_exec_tools_toolchain.
780    visibility = ["//visibility:public"],
781)
782
783sentinel(
784    name = "sentinel",
785)
786