diff --git a/docs/BUILD.bazel b/docs/BUILD.bazel index 66b6496fc5..33d93fd8ae 100644 --- a/docs/BUILD.bazel +++ b/docs/BUILD.bazel @@ -97,12 +97,12 @@ sphinx_stardocs( "//python/cc:py_cc_toolchain_bzl", "//python/cc:py_cc_toolchain_info_bzl", "//python/entry_points:py_console_script_binary_bzl", + "//python/private:py_binary_rule_bazel_bzl", "//python/private:py_cc_toolchain_rule_bzl", + "//python/private:py_library_rule_bazel_bzl", + "//python/private:py_runtime_rule_bzl", + "//python/private:py_test_rule_bazel_bzl", "//python/private/api:py_common_api_bzl", - "//python/private/common:py_binary_rule_bazel_bzl", - "//python/private/common:py_library_rule_bazel_bzl", - "//python/private/common:py_runtime_rule_bzl", - "//python/private/common:py_test_rule_bazel_bzl", ] + ([ # Bazel 6 + Stardoc isn't able to parse something about the python bzlmod extension "//python/extensions:python_bzl", diff --git a/docs/conf.py b/docs/conf.py index d65d5b51f0..9d3378241e 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -59,7 +59,7 @@ autodoc2_docstring_parser_regexes = [ (".*", "myst"), ] - + # NOTE: The redirects generation will clobber existing files. redirects = { "api/tools/precompiler/index": "/api/rules_python/tools/precompiler/index.html", @@ -69,10 +69,10 @@ "api/python/defs": "/api/rules_python/python/defs.html", "api/python/index": "/api/rules_python/python/index.html", "api/python/py_runtime_info": "/api/rules_python/python/py_runtime_info.html", - "api/python/private/common/py_library_rule_bazel": "/api/rules_python/python/private/common/py_library_rule_bazel.html", - "api/python/private/common/py_test_rule_bazel": "/api/rules_python/python/private/common/py_test_rule_bazel.html", - "api/python/private/common/py_binary_rule_bazel": "/api/rules_python/python/private/common/py_binary_rule_bazel.html", - "api/python/private/common/py_runtime_rule": "/api/rules_python/python/private/common/py_runtime_rule.html", + "api/python/private/common/py_library_rule_bazel": "/api/rules_python/python/private/py_library_rule_bazel.html", + "api/python/private/common/py_test_rule_bazel": "/api/rules_python/python/private/py_test_rule_bazel.html", + "api/python/private/common/py_binary_rule_bazel": "/api/rules_python/python/private/py_binary_rule_bazel.html", + "api/python/private/common/py_runtime_rule": "/api/rules_python/python/private/py_runtime_rule.html", "api/python/extensions/pip": "/api/rules_python/python/extensions/pip.html", "api/python/extensions/python": "/api/rules_python/python/extensions/python.html", "api/python/entry_points/py_console_script_binary": "/api/rules_python/python/entry_points/py_console_script_binary.html", diff --git a/examples/bzlmod/MODULE.bazel.lock b/examples/bzlmod/MODULE.bazel.lock index e292528dc0..56854cc847 100644 --- a/examples/bzlmod/MODULE.bazel.lock +++ b/examples/bzlmod/MODULE.bazel.lock @@ -17,6 +17,7 @@ "https://bcr.bazel.build/modules/bazel_skylib/1.2.1/MODULE.bazel": "f35baf9da0efe45fa3da1696ae906eea3d615ad41e2e3def4aeb4e8bc0ef9a7a", "https://bcr.bazel.build/modules/bazel_skylib/1.3.0/MODULE.bazel": "20228b92868bf5cfc41bda7afc8a8ba2a543201851de39d990ec957b513579c5", "https://bcr.bazel.build/modules/bazel_skylib/1.4.1/MODULE.bazel": "a0dcb779424be33100dcae821e9e27e4f2901d9dfd5333efe5ac6a8d7ab75e1d", + "https://bcr.bazel.build/modules/bazel_skylib/1.4.2/MODULE.bazel": "3bd40978e7a1fac911d5989e6b09d8f64921865a45822d8b09e815eaa726a651", "https://bcr.bazel.build/modules/bazel_skylib/1.5.0/MODULE.bazel": "32880f5e2945ce6a03d1fbd588e9198c0a959bb42297b2cfaf1685b7bc32e138", "https://bcr.bazel.build/modules/bazel_skylib/1.6.1/MODULE.bazel": "8fdee2dbaace6c252131c00e1de4b165dc65af02ea278476187765e1a617b917", "https://bcr.bazel.build/modules/bazel_skylib/1.6.1/source.json": "082ed5f9837901fada8c68c2f3ddc958bb22b6d654f71dd73f3df30d45d4b749", @@ -45,12 +46,14 @@ "https://bcr.bazel.build/modules/rules_cc/0.0.9/MODULE.bazel": "836e76439f354b89afe6a911a7adf59a6b2518fafb174483ad78a2a2fde7b1c5", "https://bcr.bazel.build/modules/rules_cc/0.0.9/source.json": "1f1ba6fea244b616de4a554a0f4983c91a9301640c8fe0dd1d410254115c8430", "https://bcr.bazel.build/modules/rules_java/4.0.0/MODULE.bazel": "5a78a7ae82cd1a33cef56dc578c7d2a46ed0dca12643ee45edbb8417899e6f74", + "https://bcr.bazel.build/modules/rules_java/6.3.0/MODULE.bazel": "a97c7678c19f236a956ad260d59c86e10a463badb7eb2eda787490f4c969b963", "https://bcr.bazel.build/modules/rules_java/7.1.0/MODULE.bazel": "30d9135a2b6561c761bd67bd4990da591e6bdc128790ce3e7afd6a3558b2fb64", "https://bcr.bazel.build/modules/rules_java/7.6.5/MODULE.bazel": "481164be5e02e4cab6e77a36927683263be56b7e36fef918b458d7a8a1ebadb1", "https://bcr.bazel.build/modules/rules_java/7.6.5/source.json": "a805b889531d1690e3c72a7a7e47a870d00323186a9904b36af83aa3d053ee8d", "https://bcr.bazel.build/modules/rules_jvm_external/4.4.2/MODULE.bazel": "a56b85e418c83eb1839819f0b515c431010160383306d13ec21959ac412d2fe7", "https://bcr.bazel.build/modules/rules_jvm_external/5.1/MODULE.bazel": "33f6f999e03183f7d088c9be518a63467dfd0be94a11d0055fe2d210f89aa909", - "https://bcr.bazel.build/modules/rules_jvm_external/5.1/source.json": "5abb45cc9beb27b77aec6a65a11855ef2b55d95dfdc358e9f312b78ae0ba32d5", + "https://bcr.bazel.build/modules/rules_jvm_external/5.2/MODULE.bazel": "d9351ba35217ad0de03816ef3ed63f89d411349353077348a45348b096615036", + "https://bcr.bazel.build/modules/rules_jvm_external/5.2/source.json": "10572111995bc349ce31c78f74b3c147f6b3233975c7fa5eff9211f6db0d34d9", "https://bcr.bazel.build/modules/rules_license/0.0.3/MODULE.bazel": "627e9ab0247f7d1e05736b59dbb1b6871373de5ad31c3011880b4133cafd4bd0", "https://bcr.bazel.build/modules/rules_license/0.0.7/MODULE.bazel": "088fbeb0b6a419005b89cf93fe62d9517c0a2b8bb56af3244af65ecfe37e7d5d", "https://bcr.bazel.build/modules/rules_license/0.0.7/source.json": "355cc5737a0f294e560d52b1b7a6492d4fff2caf0bef1a315df5a298fca2d34a", @@ -62,7 +65,8 @@ "https://bcr.bazel.build/modules/rules_proto/6.0.0-rc1/source.json": "8d8448e71706df7450ced227ca6b3812407ff5e2ccad74a43a9fbe79c84e34e0", "https://bcr.bazel.build/modules/stardoc/0.5.1/MODULE.bazel": "1a05d92974d0c122f5ccf09291442580317cdd859f07a8655f1db9a60374f9f8", "https://bcr.bazel.build/modules/stardoc/0.5.3/MODULE.bazel": "c7f6948dae6999bf0db32c1858ae345f112cacf98f174c7a8bb707e41b974f1c", - "https://bcr.bazel.build/modules/stardoc/0.5.3/source.json": "cd53fe968dc8cd98197c052db3db6d82562960c87b61e7a90ee96f8e4e0dda97", + "https://bcr.bazel.build/modules/stardoc/0.6.2/MODULE.bazel": "7060193196395f5dd668eda046ccbeacebfd98efc77fed418dbe2b82ffaa39fd", + "https://bcr.bazel.build/modules/stardoc/0.6.2/source.json": "d2ff8063b63b4a85e65fe595c4290f99717434fa9f95b4748a79a7d04dfed349", "https://bcr.bazel.build/modules/upb/0.0.0-20220923-a547704/MODULE.bazel": "7298990c00040a0e2f121f6c32544bab27d4452f80d9ce51349b1a28f3005c43", "https://bcr.bazel.build/modules/upb/0.0.0-20230516-61a97ef/MODULE.bazel": "c0df5e35ad55e264160417fd0875932ee3c9dda63d9fccace35ac62f45e1b6f9", "https://bcr.bazel.build/modules/upb/0.0.0-20230516-61a97ef/source.json": "b2150404947339e8b947c6b16baa39fa75657f4ddec5e37272c7b11c7ab533bc", @@ -149,9 +153,10 @@ }, "@@rules_jvm_external~//:extensions.bzl%maven": { "general": { - "bzlTransitiveDigest": "4ijz6uc3T4E+d+U8LQv4EAt+8OqZNVY/lzvhLx3y1yg=", - "usagesDigest": "WfVTcbopbu3jyxPgDWx1iqIv1QV6L/T7utvDxAj5k84=", + "bzlTransitiveDigest": "U98JuBYMWVrcyiXT1L6KAYSAA0chnjRZZloIUmNmZ7M=", + "usagesDigest": "1L6xElvJScwRWKMMza2Jyew+Iuz6EPOkfBMQmHYuNIk=", "recordedFileInputs": { + "@@stardoc~//maven_install.json": "de0bfa778b4ed6aebb77509362dd87ab8d20fc7c7c18d2a7429cdfee03949a21", "@@rules_jvm_external~//rules_jvm_external_deps_install.json": "3ab1f67b0de4815df110bc72ccd6c77882b3b21d3d1e0a84445847b6ce3235a3" }, "recordedDirentsInputs": {}, @@ -199,8 +204,7 @@ "attributes": { "sha256": "a171ee4c734dd2da837e4b16be9df4661afab72a41adaf31eb84dfdaf936ca26", "urls": [ - "https://repo1.maven.org/maven2/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1.jar", - "https://maven.google.com/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1.jar" + "https://repo1.maven.org/maven2/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1.jar" ], "downloaded_file_path": "com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1.jar" } @@ -241,6 +245,42 @@ "downloaded_file_path": "com/google/cloud/google-cloud-storage/1.113.4/google-cloud-storage-1.113.4.jar" } }, + "unpinned_stardoc_maven": { + "bzlFile": "@@rules_jvm_external~//:coursier.bzl", + "ruleClassName": "coursier_fetch", + "attributes": { + "repositories": [ + "{ \"repo_url\": \"https://repo1.maven.org/maven2\" }" + ], + "artifacts": [ + "{ \"group\": \"com.beust\", \"artifact\": \"jcommander\", \"version\": \"1.82\" }", + "{ \"group\": \"com.google.escapevelocity\", \"artifact\": \"escapevelocity\", \"version\": \"1.1\" }", + "{ \"group\": \"com.google.guava\", \"artifact\": \"guava\", \"version\": \"31.1-jre\" }", + "{ \"group\": \"com.google.truth\", \"artifact\": \"truth\", \"version\": \"1.1.3\" }", + "{ \"group\": \"junit\", \"artifact\": \"junit\", \"version\": \"4.13.2\" }" + ], + "fail_on_missing_checksum": true, + "fetch_sources": true, + "fetch_javadoc": false, + "excluded_artifacts": [], + "generate_compat_repositories": false, + "version_conflict_policy": "default", + "override_targets": {}, + "strict_visibility": true, + "strict_visibility_value": [ + "@@//visibility:private" + ], + "maven_install_json": "@@stardoc~//:maven_install.json", + "resolve_timeout": 600, + "jetify": false, + "jetify_include_list": [ + "*" + ], + "use_starlark_android_rules": false, + "aar_import_bzl_label": "@build_bazel_rules_android//android:rules.bzl", + "duplicate_version_warning": "warn" + } + }, "io_grpc_grpc_context_1_33_1": { "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_file", @@ -331,8 +371,7 @@ "attributes": { "sha256": "21af30c92267bd6122c0e0b4d20cccb6641a37eaf956c6540ec471d584e64a7b", "urls": [ - "https://repo1.maven.org/maven2/com/google/j2objc/j2objc-annotations/1.3/j2objc-annotations-1.3.jar", - "https://maven.google.com/com/google/j2objc/j2objc-annotations/1.3/j2objc-annotations-1.3.jar" + "https://repo1.maven.org/maven2/com/google/j2objc/j2objc-annotations/1.3/j2objc-annotations-1.3.jar" ], "downloaded_file_path": "com/google/j2objc/j2objc-annotations/1.3/j2objc-annotations-1.3.jar" } @@ -349,6 +388,17 @@ "downloaded_file_path": "software/amazon/awssdk/metrics-spi/2.17.183/metrics-spi-2.17.183.jar" } }, + "com_google_escapevelocity_escapevelocity_1_1": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_file", + "attributes": { + "sha256": "37e76e4466836dedb864fb82355cd01c3bd21325ab642d89a0f759291b171231", + "urls": [ + "https://repo1.maven.org/maven2/com/google/escapevelocity/escapevelocity/1.1/escapevelocity-1.1.jar" + ], + "downloaded_file_path": "com/google/escapevelocity/escapevelocity/1.1/escapevelocity-1.1.jar" + } + }, "org_reactivestreams_reactive_streams_1_0_3": { "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_file", @@ -385,6 +435,17 @@ "downloaded_file_path": "io/netty/netty-transport/4.1.72.Final/netty-transport-4.1.72.Final.jar" } }, + "com_beust_jcommander_1_82": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_file", + "attributes": { + "sha256": "deeac157c8de6822878d85d0c7bc8467a19cc8484d37788f7804f039dde280b1", + "urls": [ + "https://repo1.maven.org/maven2/com/beust/jcommander/1.82/jcommander-1.82.jar" + ], + "downloaded_file_path": "com/beust/jcommander/1.82/jcommander-1.82.jar" + } + }, "io_netty_netty_codec_http2_4_1_72_Final": { "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_file", @@ -588,8 +649,7 @@ "attributes": { "sha256": "a42edc9cab792e39fe39bb94f3fca655ed157ff87a8af78e1d6ba5b07c4a00ab", "urls": [ - "https://repo1.maven.org/maven2/com/google/guava/guava/31.1-jre/guava-31.1-jre.jar", - "https://maven.google.com/com/google/guava/guava/31.1-jre/guava-31.1-jre.jar" + "https://repo1.maven.org/maven2/com/google/guava/guava/31.1-jre/guava-31.1-jre.jar" ], "downloaded_file_path": "com/google/guava/guava/31.1-jre/guava-31.1-jre.jar" } @@ -618,6 +678,17 @@ "downloaded_file_path": "io/netty/netty-transport-native-unix-common/4.1.72.Final/netty-transport-native-unix-common-4.1.72.Final.jar" } }, + "junit_junit_4_13_2": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_file", + "attributes": { + "sha256": "8e495b634469d64fb8acfa3495a065cbacc8a0fff55ce1e31007be4c16dc57d3", + "urls": [ + "https://repo1.maven.org/maven2/junit/junit/4.13.2/junit-4.13.2.jar" + ], + "downloaded_file_path": "junit/junit/4.13.2/junit-4.13.2.jar" + } + }, "io_opencensus_opencensus_contrib_http_util_0_24_0": { "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_file", @@ -726,6 +797,17 @@ "downloaded_file_path": "org/checkerframework/checker-qual/3.12.0/checker-qual-3.12.0.jar" } }, + "org_hamcrest_hamcrest_core_1_3": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_file", + "attributes": { + "sha256": "66fdef91e9739348df7a096aa384a5685f4e875584cce89386a7a47251c4d8e9", + "urls": [ + "https://repo1.maven.org/maven2/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar" + ], + "downloaded_file_path": "org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar" + } + }, "com_google_cloud_google_cloud_core_http_1_93_10": { "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_file", @@ -832,8 +914,7 @@ "attributes": { "sha256": "721cb91842b46fa056847d104d5225c8b8e1e8b62263b993051e1e5a0137b7ec", "urls": [ - "https://repo1.maven.org/maven2/com/google/errorprone/error_prone_annotations/2.11.0/error_prone_annotations-2.11.0.jar", - "https://maven.google.com/com/google/errorprone/error_prone_annotations/2.11.0/error_prone_annotations-2.11.0.jar" + "https://repo1.maven.org/maven2/com/google/errorprone/error_prone_annotations/2.11.0/error_prone_annotations-2.11.0.jar" ], "downloaded_file_path": "com/google/errorprone/error_prone_annotations/2.11.0/error_prone_annotations-2.11.0.jar" } @@ -910,6 +991,51 @@ "downloaded_file_path": "software/amazon/awssdk/protocol-core/2.17.183/protocol-core-2.17.183.jar" } }, + "stardoc_maven": { + "bzlFile": "@@rules_jvm_external~//:coursier.bzl", + "ruleClassName": "pinned_coursier_fetch", + "attributes": { + "repositories": [ + "{ \"repo_url\": \"https://repo1.maven.org/maven2\" }" + ], + "artifacts": [ + "{ \"group\": \"com.beust\", \"artifact\": \"jcommander\", \"version\": \"1.82\" }", + "{ \"group\": \"com.google.escapevelocity\", \"artifact\": \"escapevelocity\", \"version\": \"1.1\" }", + "{ \"group\": \"com.google.guava\", \"artifact\": \"guava\", \"version\": \"31.1-jre\" }", + "{ \"group\": \"com.google.truth\", \"artifact\": \"truth\", \"version\": \"1.1.3\" }", + "{ \"group\": \"junit\", \"artifact\": \"junit\", \"version\": \"4.13.2\" }" + ], + "fetch_sources": true, + "fetch_javadoc": false, + "generate_compat_repositories": false, + "maven_install_json": "@@stardoc~//:maven_install.json", + "override_targets": {}, + "strict_visibility": true, + "strict_visibility_value": [ + "@@//visibility:private" + ], + "jetify": false, + "jetify_include_list": [ + "*" + ], + "additional_netrc_lines": [], + "fail_if_repin_required": true, + "use_starlark_android_rules": false, + "aar_import_bzl_label": "@build_bazel_rules_android//android:rules.bzl", + "duplicate_version_warning": "warn" + } + }, + "com_google_truth_truth_1_1_3": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_file", + "attributes": { + "sha256": "fc0b67782289a2aabfddfdf99eff1dcd5edc890d49143fcd489214b107b8f4f3", + "urls": [ + "https://repo1.maven.org/maven2/com/google/truth/truth/1.1.3/truth-1.1.3.jar" + ], + "downloaded_file_path": "com/google/truth/truth/1.1.3/truth-1.1.3.jar" + } + }, "org_checkerframework_checker_compat_qual_2_5_5": { "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_file", @@ -934,6 +1060,17 @@ "downloaded_file_path": "com/google/apis/google-api-services-storage/v1-rev20200927-1.30.10/google-api-services-storage-v1-rev20200927-1.30.10.jar" } }, + "org_ow2_asm_asm_9_1": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_file", + "attributes": { + "sha256": "cda4de455fab48ff0bcb7c48b4639447d4de859a7afc30a094a986f0936beba2", + "urls": [ + "https://repo1.maven.org/maven2/org/ow2/asm/asm/9.1/asm-9.1.jar" + ], + "downloaded_file_path": "org/ow2/asm/asm/9.1/asm-9.1.jar" + } + }, "com_google_api_client_google_api_client_1_30_11": { "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_file", @@ -1000,8 +1137,7 @@ "attributes": { "sha256": "b372a037d4230aa57fbeffdef30fd6123f9c0c2db85d0aced00c91b974f33f99", "urls": [ - "https://repo1.maven.org/maven2/com/google/guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar", - "https://maven.google.com/com/google/guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar" + "https://repo1.maven.org/maven2/com/google/guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar" ], "downloaded_file_path": "com/google/guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar" } @@ -1042,6 +1178,17 @@ "downloaded_file_path": "software/amazon/awssdk/arns/2.17.183/arns-2.17.183.jar" } }, + "com_google_auto_value_auto_value_annotations_1_8_1": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_file", + "attributes": { + "sha256": "37ec09b47d7ed35a99d13927db5c86fc9071f620f943ead5d757144698310852", + "urls": [ + "https://repo1.maven.org/maven2/com/google/auto/value/auto-value-annotations/1.8.1/auto-value-annotations-1.8.1.jar" + ], + "downloaded_file_path": "com/google/auto/value/auto-value-annotations/1.8.1/auto-value-annotations-1.8.1.jar" + } + }, "com_google_code_gson_gson_2_9_0": { "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_file", @@ -1072,8 +1219,7 @@ "attributes": { "sha256": "766ad2a0783f2687962c8ad74ceecc38a28b9f72a2d085ee438b7813e928d0c7", "urls": [ - "https://repo1.maven.org/maven2/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar", - "https://maven.google.com/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar" + "https://repo1.maven.org/maven2/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar" ], "downloaded_file_path": "com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar" } @@ -1126,6 +1272,17 @@ "downloaded_file_path": "org/codehaus/plexus/plexus-utils/3.3.1/plexus-utils-3.3.1.jar" } }, + "org_checkerframework_checker_qual_3_13_0": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_file", + "attributes": { + "sha256": "3ea0dcd73b4d6cb2fb34bd7ed4dad6db327a01ebad7db05eb7894076b3d64491", + "urls": [ + "https://repo1.maven.org/maven2/org/checkerframework/checker-qual/3.13.0/checker-qual-3.13.0.jar" + ], + "downloaded_file_path": "org/checkerframework/checker-qual/3.13.0/checker-qual-3.13.0.jar" + } + }, "com_google_protobuf_protobuf_java_util_3_13_0": { "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_file", @@ -1204,7 +1361,7 @@ "@@rules_jvm_external~//:non-module-deps.bzl%non_module_deps": { "general": { "bzlTransitiveDigest": "l6SlNloqPvd60dcuPdWiJNi3g3jfK76fcZc0i/Yr0dQ=", - "usagesDigest": "pX61d12AFioOtqChQDmxvlNGDYT69e5MrKT2E/S6TeQ=", + "usagesDigest": "hiuzyio8ny4T3UoEFpHaxXzNFc6OGUFvx5DDVLBBUmU=", "recordedFileInputs": {}, "recordedDirentsInputs": {}, "envVariables": {}, diff --git a/python/BUILD.bazel b/python/BUILD.bazel index e64ad8cdb7..f2f3374db3 100644 --- a/python/BUILD.bazel +++ b/python/BUILD.bazel @@ -124,9 +124,9 @@ bzl_library( name = "py_binary_bzl", srcs = ["py_binary.bzl"], deps = [ + "//python/private:py_binary_macro_bazel_bzl", "//python/private:register_extension_info_bzl", "//python/private:util_bzl", - "//python/private/common:py_binary_macro_bazel_bzl", "@rules_python_internal//:rules_python_config_bzl", ], ) @@ -135,7 +135,7 @@ bzl_library( name = "py_cc_link_params_info_bzl", srcs = ["py_cc_link_params_info.bzl"], deps = [ - "//python/private/common:providers_bzl", + "//python/private:py_cc_link_params_info_bzl", "@rules_python_internal//:rules_python_config_bzl", ], ) @@ -178,9 +178,9 @@ bzl_library( name = "py_library_bzl", srcs = ["py_library.bzl"], deps = [ + "//python/private:py_library_macro_bazel_bzl", "//python/private:register_extension_info_bzl", "//python/private:util_bzl", - "//python/private/common:py_library_macro_bazel_bzl", "@rules_python_internal//:rules_python_config_bzl", ], ) @@ -189,8 +189,8 @@ bzl_library( name = "py_runtime_bzl", srcs = ["py_runtime.bzl"], deps = [ + "//python/private:py_runtime_macro_bzl", "//python/private:util_bzl", - "//python/private/common:py_runtime_macro_bzl", ], ) @@ -208,9 +208,9 @@ bzl_library( name = "py_runtime_info_bzl", srcs = ["py_runtime_info.bzl"], deps = [ + "//python/private:py_runtime_info_bzl", "//python/private:reexports_bzl", "//python/private:util_bzl", - "//python/private/common:providers_bzl", "@rules_python_internal//:rules_python_config_bzl", ], ) @@ -219,9 +219,9 @@ bzl_library( name = "py_test_bzl", srcs = ["py_test.bzl"], deps = [ + "//python/private:py_test_macro_bazel_bzl", "//python/private:register_extension_info_bzl", "//python/private:util_bzl", - "//python/private/common:py_test_macro_bazel_bzl", "@rules_python_internal//:rules_python_config_bzl", ], ) diff --git a/python/private/BUILD.bazel b/python/private/BUILD.bazel index cee77c5836..d3b9bf4aad 100644 --- a/python/private/BUILD.bazel +++ b/python/private/BUILD.bazel @@ -30,7 +30,6 @@ licenses(["notice"]) filegroup( name = "distribution", srcs = glob(["**"]) + [ - "//python/private/common:distribution", "//python/private/proto:distribution", "//python/private/pypi:distribution", "//python/private/whl_filegroup:distribution", @@ -52,6 +51,28 @@ filegroup( visibility = ["//python:__pkg__"], ) +bzl_library( + name = "attributes_bazel_bzl", + srcs = ["attributes_bazel.bzl"], + deps = ["//python/private:rules_cc_srcs_bzl"], +) + +bzl_library( + name = "attributes_bzl", + srcs = ["attributes.bzl"], + deps = [ + ":common_bzl", + ":py_internal_bzl", + ":semantics_bzl", + "//python/private:enum_bzl", + "//python/private:flags_bzl", + "//python/private:py_info_bzl", + "//python/private:reexports_bzl", + "//python/private:rules_cc_srcs_bzl", + "@bazel_skylib//rules:common_settings", + ], +) + bzl_library( name = "auth_bzl", srcs = ["auth.bzl"], @@ -82,6 +103,39 @@ bzl_library( srcs = ["bzlmod_enabled.bzl"], ) +bzl_library( + name = "cc_helper_bzl", + srcs = ["cc_helper.bzl"], + deps = [":py_internal_bzl"], +) + +bzl_library( + name = "common_bazel_bzl", + srcs = ["common_bazel.bzl"], + deps = [ + ":attributes_bzl", + ":common_bzl", + ":py_internal_bzl", + "//python/private:py_cc_link_params_info_bzl", + "//python/private:py_interpreter_program_bzl", + "//python/private:toolchain_types_bzl", + "@bazel_skylib//lib:paths", + ], +) + +bzl_library( + name = "common_bzl", + srcs = ["common.bzl"], + deps = [ + ":cc_helper_bzl", + ":py_internal_bzl", + ":semantics_bzl", + "//python/private:py_info_bzl", + "//python/private:reexports_bzl", + "//python/private:rules_cc_srcs_bzl", + ], +) + bzl_library( name = "config_settings_bzl", srcs = ["config_settings.bzl"], @@ -159,18 +213,6 @@ bzl_library( ], ) -bzl_library( - name = "py_repositories_bzl", - srcs = ["py_repositories.bzl"], - deps = [ - ":bazel_tools_bzl", - ":internal_config_repo_bzl", - ":pythons_hub_bzl", - "//python:versions_bzl", - "//python/private/pypi:deps_bzl", - ], -) - bzl_library( name = "python_register_toolchains_bzl", srcs = ["python_register_toolchains.bzl"], @@ -217,6 +259,35 @@ bzl_library( ], ) +bzl_library( + name = "py_binary_macro_bazel_bzl", + srcs = ["py_binary_macro_bazel.bzl"], + deps = [ + ":common_bzl", + ":py_binary_rule_bazel_bzl", + ], +) + +bzl_library( + name = "py_binary_rule_bazel_bzl", + srcs = ["py_binary_rule_bazel.bzl"], + deps = [ + ":attributes_bzl", + ":py_executable_bazel_bzl", + ":semantics_bzl", + "@bazel_skylib//lib:dicts", + ], +) + +bzl_library( + name = "py_cc_link_params_info_bzl", + srcs = ["py_cc_link_params_info.bzl"], + deps = [ + ":rules_cc_srcs_bzl", + ":util_bzl", + ], +) + bzl_library( name = "py_cc_toolchain_macro_bzl", srcs = ["py_cc_toolchain_macro.bzl"], @@ -265,12 +336,46 @@ bzl_library( ":py_exec_tools_info_bzl", ":sentinel_bzl", ":toolchain_types_bzl", - "//python/private/common:providers_bzl", "@bazel_skylib//lib:paths", "@bazel_skylib//rules:common_settings", ], ) +bzl_library( + name = "py_executable_bazel_bzl", + srcs = ["py_executable_bazel.bzl"], + deps = [ + ":attributes_bazel_bzl", + ":common_bazel_bzl", + ":common_bzl", + ":py_executable_bzl", + ":py_internal_bzl", + ":semantics_bzl", + "//python/private:py_runtime_info_bzl", + ], +) + +bzl_library( + name = "py_executable_bzl", + srcs = ["py_executable.bzl"], + deps = [ + ":attributes_bzl", + ":cc_helper_bzl", + ":common_bzl", + ":py_internal_bzl", + "//python/private:flags_bzl", + "//python/private:py_cc_link_params_info_bzl", + "//python/private:py_executable_info_bzl", + "//python/private:py_info_bzl", + "//python/private:py_runtime_info_bzl", + "//python/private:rules_cc_srcs_bzl", + "//python/private:toolchain_types_bzl", + "@bazel_skylib//lib:dicts", + "@bazel_skylib//lib:structs", + "@bazel_skylib//rules:common_settings", + ], +) + bzl_library( name = "py_executable_info_bzl", srcs = ["py_executable_info.bzl"], @@ -287,12 +392,50 @@ bzl_library( ], ) +bzl_library( + name = "py_internal_bzl", + srcs = ["py_internal.bzl"], + deps = ["@rules_python_internal//:py_internal_bzl"], +) + bzl_library( name = "py_interpreter_program_bzl", srcs = ["py_interpreter_program.bzl"], deps = ["@bazel_skylib//rules:common_settings"], ) +bzl_library( + name = "py_library_bzl", + srcs = ["py_library.bzl"], + deps = [ + ":attributes_bzl", + ":common_bzl", + ":py_internal_bzl", + "//python/private:flags_bzl", + "//python/private:py_cc_link_params_info_bzl", + "//python/private:toolchain_types_bzl", + "@bazel_skylib//lib:dicts", + "@bazel_skylib//rules:common_settings", + ], +) + +bzl_library( + name = "py_library_macro_bazel_bzl", + srcs = ["py_library_macro_bazel.bzl"], + deps = [":py_library_rule_bazel_bzl"], +) + +bzl_library( + name = "py_library_rule_bazel_bzl", + srcs = ["py_library_rule_bazel.bzl"], + deps = [ + ":attributes_bazel_bzl", + ":common_bazel_bzl", + ":common_bzl", + ":py_library_bzl", + ], +) + bzl_library( name = "py_package_bzl", srcs = ["py_package.bzl"], @@ -303,6 +446,44 @@ bzl_library( ], ) +bzl_library( + name = "py_runtime_info_bzl", + srcs = ["py_runtime_info.bzl"], + deps = [":util_bzl"], +) + +bzl_library( + name = "py_repositories_bzl", + srcs = ["py_repositories.bzl"], + deps = [ + ":bazel_tools_bzl", + ":internal_config_repo_bzl", + ":pythons_hub_bzl", + "//python:versions_bzl", + "//python/private/pypi:deps_bzl", + ], +) + +bzl_library( + name = "py_runtime_macro_bzl", + srcs = ["py_runtime_macro.bzl"], + deps = [":py_runtime_rule_bzl"], +) + +bzl_library( + name = "py_runtime_rule_bzl", + srcs = ["py_runtime_rule.bzl"], + deps = [ + ":py_runtime_info_bzl", + ":reexports_bzl", + ":util_bzl", + "//python/private:attributes_bzl", + "//python/private:py_internal_bzl", + "@bazel_skylib//lib:dicts", + "@bazel_skylib//lib:paths", + ], +) + bzl_library( name = "py_runtime_pair_macro_bzl", srcs = ["py_runtime_pair_macro.bzl"], @@ -320,6 +501,27 @@ bzl_library( ], ) +bzl_library( + name = "py_test_macro_bazel_bzl", + srcs = ["py_test_macro_bazel.bzl"], + deps = [ + ":common_bazel_bzl", + ":py_test_rule_bazel_bzl", + ], +) + +bzl_library( + name = "py_test_rule_bazel_bzl", + srcs = ["py_test_rule_bazel.bzl"], + deps = [ + ":attributes_bzl", + ":common_bzl", + ":py_executable_bazel_bzl", + ":semantics_bzl", + "@bazel_skylib//lib:dicts", + ], +) + bzl_library( name = "py_toolchain_suite_bzl", srcs = ["py_toolchain_suite.bzl"], @@ -434,6 +636,11 @@ bzl_library( deps = [":bazel_tools_bzl"], ) +bzl_library( + name = "semantics_bzl", + srcs = ["semantics.bzl"], +) + # Needed to define bzl_library targets for docgen. (We don't define the # bzl_library target here because it'd give our users a transitive dependency # on Skylib.) diff --git a/python/private/common/attributes.bzl b/python/private/attributes.bzl similarity index 98% rename from python/private/common/attributes.bzl rename to python/private/attributes.bzl index 56e8a66e19..424a2c5ad6 100644 --- a/python/private/common/attributes.bzl +++ b/python/private/attributes.bzl @@ -15,12 +15,12 @@ load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo") load("@rules_cc//cc:defs.bzl", "CcInfo") -load("//python/private:enum.bzl", "enum") -load("//python/private:flags.bzl", "PrecompileFlag", "PrecompileSourceRetentionFlag") -load("//python/private:py_info.bzl", "PyInfo") -load("//python/private:reexports.bzl", "BuiltinPyInfo") load(":common.bzl", "union_attrs") +load(":enum.bzl", "enum") +load(":flags.bzl", "PrecompileFlag", "PrecompileSourceRetentionFlag") +load(":py_info.bzl", "PyInfo") load(":py_internal.bzl", "py_internal") +load(":reexports.bzl", "BuiltinPyInfo") load( ":semantics.bzl", "DEPS_ATTR_ALLOW_RULES", diff --git a/python/private/common/attributes_bazel.bzl b/python/private/attributes_bazel.bzl similarity index 100% rename from python/private/common/attributes_bazel.bzl rename to python/private/attributes_bazel.bzl diff --git a/python/private/common/cc_helper.bzl b/python/private/cc_helper.bzl similarity index 100% rename from python/private/common/cc_helper.bzl rename to python/private/cc_helper.bzl diff --git a/python/private/common/common.bzl b/python/private/common.bzl similarity index 99% rename from python/private/common/common.bzl rename to python/private/common.bzl index ec46ea8965..2dcc9482ca 100644 --- a/python/private/common/common.bzl +++ b/python/private/common.bzl @@ -13,10 +13,10 @@ # limitations under the License. """Various things common to Bazel and Google rule implementations.""" -load("//python/private:py_info.bzl", "PyInfo", "PyInfoBuilder") -load("//python/private:reexports.bzl", "BuiltinPyInfo") load(":cc_helper.bzl", "cc_helper") +load(":py_info.bzl", "PyInfo", "PyInfoBuilder") load(":py_internal.bzl", "py_internal") +load(":reexports.bzl", "BuiltinPyInfo") load( ":semantics.bzl", "NATIVE_RULES_MIGRATION_FIX_CMD", @@ -173,7 +173,7 @@ def create_cc_details_struct( runfiles. cc_toolchain: CcToolchain that should be used when building. feature_config: struct from cc_configure_features(); see - //python/private/common:py_executable.bzl%cc_configure_features. + //python/private:py_executable.bzl%cc_configure_features. **kwargs: Additional keys/values to set in the returned struct. This is to facilitate extensions with less patching. Any added fields should pick names that are unlikely to collide if the CcDetails API has diff --git a/python/private/common/BUILD.bazel b/python/private/common/BUILD.bazel deleted file mode 100644 index 6fef8e87af..0000000000 --- a/python/private/common/BUILD.bazel +++ /dev/null @@ -1,228 +0,0 @@ -# Copyright 2023 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. - -load("@bazel_skylib//:bzl_library.bzl", "bzl_library") - -package( - default_visibility = ["//:__subpackages__"], -) - -bzl_library( - name = "attributes_bazel_bzl", - srcs = ["attributes_bazel.bzl"], - deps = ["//python/private:rules_cc_srcs_bzl"], -) - -bzl_library( - name = "attributes_bzl", - srcs = ["attributes.bzl"], - deps = [ - ":common_bzl", - ":py_internal_bzl", - ":semantics_bzl", - "//python/private:enum_bzl", - "//python/private:flags_bzl", - "//python/private:py_info_bzl", - "//python/private:reexports_bzl", - "//python/private:rules_cc_srcs_bzl", - "@bazel_skylib//rules:common_settings", - ], -) - -bzl_library( - name = "cc_helper_bzl", - srcs = ["cc_helper.bzl"], - deps = [":py_internal_bzl"], -) - -bzl_library( - name = "common_bazel_bzl", - srcs = ["common_bazel.bzl"], - deps = [ - ":attributes_bzl", - ":common_bzl", - ":providers_bzl", - ":py_internal_bzl", - "//python/private:py_interpreter_program_bzl", - "//python/private:toolchain_types_bzl", - "@bazel_skylib//lib:paths", - ], -) - -bzl_library( - name = "common_bzl", - srcs = ["common.bzl"], - deps = [ - ":cc_helper_bzl", - ":providers_bzl", - ":py_internal_bzl", - ":semantics_bzl", - "//python/private:py_info_bzl", - "//python/private:reexports_bzl", - "//python/private:rules_cc_srcs_bzl", - ], -) - -filegroup( - name = "distribution", - srcs = glob(["**"]), -) - -bzl_library( - name = "providers_bzl", - srcs = ["providers.bzl"], - deps = [ - ":semantics_bzl", - "//python/private:rules_cc_srcs_bzl", - "//python/private:util_bzl", - ], -) - -bzl_library( - name = "py_binary_macro_bazel_bzl", - srcs = ["py_binary_macro_bazel.bzl"], - deps = [ - ":common_bzl", - ":py_binary_rule_bazel_bzl", - ], -) - -bzl_library( - name = "py_binary_rule_bazel_bzl", - srcs = ["py_binary_rule_bazel.bzl"], - deps = [ - ":attributes_bzl", - ":py_executable_bazel_bzl", - ":semantics_bzl", - "@bazel_skylib//lib:dicts", - ], -) - -bzl_library( - name = "py_executable_bazel_bzl", - srcs = ["py_executable_bazel.bzl"], - deps = [ - ":attributes_bazel_bzl", - ":common_bazel_bzl", - ":common_bzl", - ":providers_bzl", - ":py_executable_bzl", - ":py_internal_bzl", - ":semantics_bzl", - ], -) - -bzl_library( - name = "py_executable_bzl", - srcs = ["py_executable.bzl"], - deps = [ - ":attributes_bzl", - ":cc_helper_bzl", - ":common_bzl", - ":providers_bzl", - ":py_internal_bzl", - "//python/private:flags_bzl", - "//python/private:py_executable_info_bzl", - "//python/private:py_info_bzl", - "//python/private:rules_cc_srcs_bzl", - "//python/private:toolchain_types_bzl", - "@bazel_skylib//lib:dicts", - "@bazel_skylib//lib:structs", - "@bazel_skylib//rules:common_settings", - ], -) - -bzl_library( - name = "py_internal_bzl", - srcs = ["py_internal.bzl"], - deps = ["@rules_python_internal//:py_internal_bzl"], -) - -bzl_library( - name = "py_library_bzl", - srcs = ["py_library.bzl"], - deps = [ - ":attributes_bzl", - ":common_bzl", - ":providers_bzl", - ":py_internal_bzl", - "//python/private:flags_bzl", - "//python/private:toolchain_types_bzl", - "@bazel_skylib//lib:dicts", - "@bazel_skylib//rules:common_settings", - ], -) - -bzl_library( - name = "py_library_macro_bazel_bzl", - srcs = ["py_library_macro_bazel.bzl"], - deps = [":py_library_rule_bazel_bzl"], -) - -bzl_library( - name = "py_library_rule_bazel_bzl", - srcs = ["py_library_rule_bazel.bzl"], - deps = [ - ":attributes_bazel_bzl", - ":common_bazel_bzl", - ":common_bzl", - ":py_library_bzl", - ], -) - -bzl_library( - name = "py_runtime_macro_bzl", - srcs = ["py_runtime_macro.bzl"], - deps = [":py_runtime_rule_bzl"], -) - -bzl_library( - name = "py_runtime_rule_bzl", - srcs = ["py_runtime_rule.bzl"], - deps = [ - ":attributes_bzl", - ":providers_bzl", - ":py_internal_bzl", - "//python/private:reexports_bzl", - "//python/private:util_bzl", - "@bazel_skylib//lib:dicts", - "@bazel_skylib//lib:paths", - ], -) - -bzl_library( - name = "py_test_macro_bazel_bzl", - srcs = ["py_test_macro_bazel.bzl"], - deps = [ - ":common_bazel_bzl", - ":py_test_rule_bazel_bzl", - ], -) - -bzl_library( - name = "py_test_rule_bazel_bzl", - srcs = ["py_test_rule_bazel.bzl"], - deps = [ - ":attributes_bzl", - ":common_bzl", - ":py_executable_bazel_bzl", - ":semantics_bzl", - "@bazel_skylib//lib:dicts", - ], -) - -bzl_library( - name = "semantics_bzl", - srcs = ["semantics.bzl"], -) diff --git a/python/private/common/common_bazel.bzl b/python/private/common_bazel.bzl similarity index 96% rename from python/private/common/common_bazel.bzl rename to python/private/common_bazel.bzl index 6148fc2daa..642cfd86cc 100644 --- a/python/private/common/common_bazel.bzl +++ b/python/private/common_bazel.bzl @@ -16,13 +16,13 @@ load("@bazel_skylib//lib:paths.bzl", "paths") load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo") load("@rules_cc//cc:defs.bzl", "CcInfo", "cc_common") -load("//python/private:flags.bzl", "PrecompileFlag") -load("//python/private:py_interpreter_program.bzl", "PyInterpreterProgramInfo") -load("//python/private:toolchain_types.bzl", "EXEC_TOOLS_TOOLCHAIN_TYPE", "TARGET_TOOLCHAIN_TYPE") load(":attributes.bzl", "PrecompileAttr", "PrecompileInvalidationModeAttr", "PrecompileSourceRetentionAttr") load(":common.bzl", "is_bool") -load(":providers.bzl", "PyCcLinkParamsProvider") +load(":flags.bzl", "PrecompileFlag") +load(":py_cc_link_params_info.bzl", "PyCcLinkParamsInfo") load(":py_internal.bzl", "py_internal") +load(":py_interpreter_program.bzl", "PyInterpreterProgramInfo") +load(":toolchain_types.bzl", "EXEC_TOOLS_TOOLCHAIN_TYPE", "TARGET_TOOLCHAIN_TYPE") _py_builtins = py_internal @@ -45,8 +45,8 @@ def collect_cc_info(ctx, extra_deps = []): if CcInfo in dep: cc_infos.append(dep[CcInfo]) - if PyCcLinkParamsProvider in dep: - cc_infos.append(dep[PyCcLinkParamsProvider].cc_info) + if PyCcLinkParamsInfo in dep: + cc_infos.append(dep[PyCcLinkParamsInfo].cc_info) return cc_common.merge_cc_infos(cc_infos = cc_infos) diff --git a/python/private/flags.bzl b/python/private/flags.bzl index e7643fc1ae..c190cf682b 100644 --- a/python/private/flags.bzl +++ b/python/private/flags.bzl @@ -19,7 +19,7 @@ unnecessary files when all that are needed are flag definitions. """ load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo") -load("//python/private:enum.bzl", "enum") +load(":enum.bzl", "enum") def _FlagEnum_flag_values(self): return sorted(self.__members__.values()) diff --git a/python/private/local_runtime_repo.bzl b/python/private/local_runtime_repo.bzl index 4e7edde9d8..fb1a8e29ac 100644 --- a/python/private/local_runtime_repo.bzl +++ b/python/private/local_runtime_repo.bzl @@ -14,7 +14,7 @@ """Create a repository for a locally installed Python runtime.""" -load("//python/private:enum.bzl", "enum") +load(":enum.bzl", "enum") load(":repo_utils.bzl", "REPO_DEBUG_ENV_VAR", "repo_utils") # buildifier: disable=name-conventions diff --git a/python/private/local_runtime_toolchains_repo.bzl b/python/private/local_runtime_toolchains_repo.bzl index 880fbfe224..adb3bb560d 100644 --- a/python/private/local_runtime_toolchains_repo.bzl +++ b/python/private/local_runtime_toolchains_repo.bzl @@ -14,8 +14,8 @@ """Create a repository to hold a local Python toolchain definitions.""" -load("//python/private:text_util.bzl", "render") load(":repo_utils.bzl", "REPO_DEBUG_ENV_VAR", "repo_utils") +load(":text_util.bzl", "render") _TOOLCHAIN_TEMPLATE = """ # Generated by local_runtime_toolchains_repo.bzl diff --git a/python/private/common/py_binary_macro_bazel.bzl b/python/private/py_binary_macro_bazel.bzl similarity index 100% rename from python/private/common/py_binary_macro_bazel.bzl rename to python/private/py_binary_macro_bazel.bzl diff --git a/python/private/common/py_binary_rule_bazel.bzl b/python/private/py_binary_rule_bazel.bzl similarity index 100% rename from python/private/common/py_binary_rule_bazel.bzl rename to python/private/py_binary_rule_bazel.bzl diff --git a/python/private/common/providers.bzl b/python/private/py_cc_link_params_info.bzl similarity index 98% rename from python/private/common/providers.bzl rename to python/private/py_cc_link_params_info.bzl index b704ce0298..e5f4534c70 100644 --- a/python/private/common/providers.bzl +++ b/python/private/py_cc_link_params_info.bzl @@ -14,7 +14,7 @@ """Providers for Python rules.""" load("@rules_cc//cc:defs.bzl", "CcInfo") -load("//python/private:util.bzl", "define_bazel_6_provider") +load(":util.bzl", "define_bazel_6_provider") DEFAULT_STUB_SHEBANG = "#!/usr/bin/env python3" @@ -300,17 +300,17 @@ The following substitutions are made during template expansion: }, ) -def _PyCcLinkParamsProvider_init(cc_info): +def _PyCcLinkParamsInfo_init(cc_info): return { "cc_info": CcInfo(linking_context = cc_info.linking_context), } # buildifier: disable=name-conventions -PyCcLinkParamsProvider, _unused_raw_py_cc_link_params_provider_ctor = define_bazel_6_provider( +PyCcLinkParamsInfo, _unused_raw_py_cc_link_params_provider_ctor = define_bazel_6_provider( doc = ("Python-wrapper to forward {obj}`CcInfo.linking_context`. This is to " + "allow Python targets to propagate C++ linking information, but " + "without the Python target appearing to be a valid C++ rule dependency"), - init = _PyCcLinkParamsProvider_init, + init = _PyCcLinkParamsInfo_init, fields = { "cc_info": """ :type: CcInfo diff --git a/python/private/py_exec_tools_toolchain.bzl b/python/private/py_exec_tools_toolchain.bzl index 957448f421..edf9159759 100644 --- a/python/private/py_exec_tools_toolchain.bzl +++ b/python/private/py_exec_tools_toolchain.bzl @@ -16,9 +16,9 @@ load("@bazel_skylib//lib:paths.bzl", "paths") load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo") -load("//python/private:sentinel.bzl", "SentinelInfo") -load("//python/private:toolchain_types.bzl", "TARGET_TOOLCHAIN_TYPE") load(":py_exec_tools_info.bzl", "PyExecToolsInfo") +load(":sentinel.bzl", "SentinelInfo") +load(":toolchain_types.bzl", "TARGET_TOOLCHAIN_TYPE") def _py_exec_tools_toolchain_impl(ctx): extra_kwargs = {} @@ -43,7 +43,7 @@ py_exec_tools_toolchain = rule( Provides a toolchain for build time tools. This provides `ToolchainInfo` with the following attributes: -* `exec_tools`: {type}`PyExecToolsInfo` +* `exec_tools`: {type}`PyExecToolsInfo` * `toolchain_label`: {type}`Label` _only present when `--visibile_for_testing=True` for internal testing_. The rule's label; this allows identifying what toolchain implmentation was selected for testing purposes. diff --git a/python/private/common/py_executable.bzl b/python/private/py_executable.bzl similarity index 98% rename from python/private/common/py_executable.bzl rename to python/private/py_executable.bzl index 6c238a2a5d..00d8d36272 100644 --- a/python/private/common/py_executable.bzl +++ b/python/private/py_executable.bzl @@ -17,15 +17,6 @@ load("@bazel_skylib//lib:dicts.bzl", "dicts") load("@bazel_skylib//lib:structs.bzl", "structs") load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo") load("@rules_cc//cc:defs.bzl", "cc_common") -load("//python/private:builders.bzl", "builders") -load("//python/private:py_executable_info.bzl", "PyExecutableInfo") -load("//python/private:py_info.bzl", "PyInfo") -load("//python/private:reexports.bzl", "BuiltinPyInfo", "BuiltinPyRuntimeInfo") -load( - "//python/private:toolchain_types.bzl", - "EXEC_TOOLS_TOOLCHAIN_TYPE", - TOOLCHAIN_TYPE = "TARGET_TOOLCHAIN_TYPE", -) load( ":attributes.bzl", "AGNOSTIC_EXECUTABLE_ATTRS", @@ -38,6 +29,7 @@ load( "create_srcs_attr", "create_srcs_version_attr", ) +load(":builders.bzl", "builders") load(":cc_helper.bzl", "cc_helper") load( ":common.bzl", @@ -52,12 +44,12 @@ load( "target_platform_has_any_constraint", "union_attrs", ) -load( - ":providers.bzl", - "PyCcLinkParamsProvider", - "PyRuntimeInfo", -) +load(":py_cc_link_params_info.bzl", "PyCcLinkParamsInfo") +load(":py_executable_info.bzl", "PyExecutableInfo") +load(":py_info.bzl", "PyInfo") load(":py_internal.bzl", "py_internal") +load(":py_runtime_info.bzl", "PyRuntimeInfo") +load(":reexports.bzl", "BuiltinPyInfo", "BuiltinPyRuntimeInfo") load( ":semantics.bzl", "ALLOWED_MAIN_EXTENSIONS", @@ -65,6 +57,11 @@ load( "IS_BAZEL", "PY_RUNTIME_ATTR_NAME", ) +load( + ":toolchain_types.bzl", + "EXEC_TOOLS_TOOLCHAIN_TYPE", + TOOLCHAIN_TYPE = "TARGET_TOOLCHAIN_TYPE", +) _py_builtins = py_internal @@ -842,7 +839,7 @@ def _create_providers( runfiles_details: runfiles that will become the default and data runfiles. imports: depset of strings; the import paths to propagate cc_info: optional CcInfo; Linking information to propagate as - PyCcLinkParamsProvider. Note that only the linking information + PyCcLinkParamsInfo. Note that only the linking information is propagated, not the whole CcInfo. inherited_environment: list of strings; Environment variable names that should be inherited from the environment the executuble @@ -903,11 +900,11 @@ def _create_providers( bootstrap_template = py_runtime_info.bootstrap_template, )) - # TODO(b/163083591): Remove the PyCcLinkParamsProvider once binaries-in-deps + # TODO(b/163083591): Remove the PyCcLinkParamsInfo once binaries-in-deps # are cleaned up. if cc_info: providers.append( - PyCcLinkParamsProvider(cc_info = cc_info), + PyCcLinkParamsInfo(cc_info = cc_info), ) py_info, deps_transitive_sources, builtin_py_info = create_py_info( diff --git a/python/private/common/py_executable_bazel.bzl b/python/private/py_executable_bazel.bzl similarity index 99% rename from python/private/common/py_executable_bazel.bzl rename to python/private/py_executable_bazel.bzl index dae1c4a0b1..53206bdbfd 100644 --- a/python/private/common/py_executable_bazel.bzl +++ b/python/private/py_executable_bazel.bzl @@ -15,8 +15,6 @@ load("@bazel_skylib//lib:dicts.bzl", "dicts") load("@bazel_skylib//lib:paths.bzl", "paths") -load("//python/private:flags.bzl", "BootstrapImplFlag") -load("//python/private:toolchain_types.bzl", "TARGET_TOOLCHAIN_TYPE") load(":attributes_bazel.bzl", "IMPORTS_ATTRS") load( ":common.bzl", @@ -27,13 +25,15 @@ load( "union_attrs", ) load(":common_bazel.bzl", "collect_cc_info", "get_imports", "maybe_precompile") -load(":providers.bzl", "DEFAULT_STUB_SHEBANG") +load(":flags.bzl", "BootstrapImplFlag") load( ":py_executable.bzl", "create_base_executable_rule", "py_executable_base_impl", ) load(":py_internal.bzl", "py_internal") +load(":py_runtime_info.bzl", "DEFAULT_STUB_SHEBANG") +load(":toolchain_types.bzl", "TARGET_TOOLCHAIN_TYPE") _py_builtins = py_internal _EXTERNAL_PATH_PREFIX = "external" diff --git a/python/private/py_info.bzl b/python/private/py_info.bzl index 6c2c3c6499..7a0bdeaef8 100644 --- a/python/private/py_info.bzl +++ b/python/private/py_info.bzl @@ -14,8 +14,8 @@ """Implementation of PyInfo provider and PyInfo-specific utilities.""" load("@rules_python_internal//:rules_python_config.bzl", "config") -load("//python/private:reexports.bzl", "BuiltinPyInfo") load(":builders.bzl", "builders") +load(":reexports.bzl", "BuiltinPyInfo") load(":util.bzl", "define_bazel_6_provider") def _check_arg_type(name, required_type, value): diff --git a/python/private/common/py_internal.bzl b/python/private/py_internal.bzl similarity index 100% rename from python/private/common/py_internal.bzl rename to python/private/py_internal.bzl diff --git a/python/private/common/py_library.bzl b/python/private/py_library.bzl similarity index 95% rename from python/private/common/py_library.bzl rename to python/private/py_library.bzl index bce18c3132..4f43116947 100644 --- a/python/private/common/py_library.bzl +++ b/python/private/py_library.bzl @@ -15,13 +15,6 @@ load("@bazel_skylib//lib:dicts.bzl", "dicts") load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo") -load("//python/private:builders.bzl", "builders") -load("//python/private:flags.bzl", "AddSrcsToRunfilesFlag", "PrecompileFlag") -load( - "//python/private:toolchain_types.bzl", - "EXEC_TOOLS_TOOLCHAIN_TYPE", - TOOLCHAIN_TYPE = "TARGET_TOOLCHAIN_TYPE", -) load( ":attributes.bzl", "COMMON_ATTRS", @@ -32,6 +25,7 @@ load( "create_srcs_attr", "create_srcs_version_attr", ) +load(":builders.bzl", "builders") load( ":common.bzl", "check_native_allowed", @@ -43,8 +37,14 @@ load( "filter_to_py_srcs", "union_attrs", ) -load(":providers.bzl", "PyCcLinkParamsProvider") +load(":flags.bzl", "AddSrcsToRunfilesFlag", "PrecompileFlag") +load(":py_cc_link_params_info.bzl", "PyCcLinkParamsInfo") load(":py_internal.bzl", "py_internal") +load( + ":toolchain_types.bzl", + "EXEC_TOOLS_TOOLCHAIN_TYPE", + TOOLCHAIN_TYPE = "TARGET_TOOLCHAIN_TYPE", +) _py_builtins = py_internal @@ -121,7 +121,7 @@ def py_library_impl(ctx, *, semantics): DefaultInfo(files = default_outputs, runfiles = runfiles), py_info, create_instrumented_files_info(ctx), - PyCcLinkParamsProvider(cc_info = cc_info), + PyCcLinkParamsInfo(cc_info = cc_info), create_output_group_info(py_info.transitive_sources, extra_groups = {}), ] if builtins_py_info: diff --git a/python/private/common/py_library_macro_bazel.bzl b/python/private/py_library_macro_bazel.bzl similarity index 100% rename from python/private/common/py_library_macro_bazel.bzl rename to python/private/py_library_macro_bazel.bzl diff --git a/python/private/common/py_library_rule_bazel.bzl b/python/private/py_library_rule_bazel.bzl similarity index 100% rename from python/private/common/py_library_rule_bazel.bzl rename to python/private/py_library_rule_bazel.bzl diff --git a/python/private/py_runtime_info.bzl b/python/private/py_runtime_info.bzl new file mode 100644 index 0000000000..359a9e78cf --- /dev/null +++ b/python/private/py_runtime_info.bzl @@ -0,0 +1,300 @@ +# Copyright 2022 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. +"""Providers for Python rules.""" + +load(":util.bzl", "define_bazel_6_provider") + +DEFAULT_STUB_SHEBANG = "#!/usr/bin/env python3" + +DEFAULT_BOOTSTRAP_TEMPLATE = Label("//python/private:bootstrap_template") + +_PYTHON_VERSION_VALUES = ["PY2", "PY3"] + +def _optional_int(value): + return int(value) if value != None else None + +def interpreter_version_info_struct_from_dict(info_dict): + """Create a struct of interpreter version info from a dict from an attribute. + + Args: + info_dict: (dict | None) of version info fields. See interpreter_version_info + provider field docs. + + Returns: + struct of version info; see interpreter_version_info provider field docs. + """ + info_dict = dict(info_dict or {}) # Copy in case the original is frozen + if info_dict: + if not ("major" in info_dict and "minor" in info_dict): + fail("interpreter_version_info must have at least two keys, 'major' and 'minor'") + version_info_struct = struct( + major = _optional_int(info_dict.pop("major", None)), + minor = _optional_int(info_dict.pop("minor", None)), + micro = _optional_int(info_dict.pop("micro", None)), + releaselevel = str(info_dict.pop("releaselevel")) if "releaselevel" in info_dict else None, + serial = _optional_int(info_dict.pop("serial", None)), + ) + + if len(info_dict.keys()) > 0: + fail("unexpected keys {} in interpreter_version_info".format( + str(info_dict.keys()), + )) + + return version_info_struct + +def _PyRuntimeInfo_init( + *, + implementation_name = None, + interpreter_path = None, + interpreter = None, + files = None, + coverage_tool = None, + coverage_files = None, + pyc_tag = None, + python_version, + stub_shebang = None, + bootstrap_template = None, + interpreter_version_info = None, + stage2_bootstrap_template = None, + zip_main_template = None): + if (interpreter_path and interpreter) or (not interpreter_path and not interpreter): + fail("exactly one of interpreter or interpreter_path must be specified") + + if interpreter_path and files != None: + fail("cannot specify 'files' if 'interpreter_path' is given") + + if (coverage_tool and not coverage_files) or (not coverage_tool and coverage_files): + fail( + "coverage_tool and coverage_files must both be set or neither must be set, " + + "got coverage_tool={}, coverage_files={}".format( + coverage_tool, + coverage_files, + ), + ) + + if python_version not in _PYTHON_VERSION_VALUES: + fail("invalid python_version: '{}'; must be one of {}".format( + python_version, + _PYTHON_VERSION_VALUES, + )) + + if files != None and type(files) != type(depset()): + fail("invalid files: got value of type {}, want depset".format(type(files))) + + if interpreter: + if files == None: + files = depset() + else: + files = None + + if coverage_files == None: + coverage_files = depset() + + if not stub_shebang: + stub_shebang = DEFAULT_STUB_SHEBANG + + return { + "bootstrap_template": bootstrap_template, + "coverage_files": coverage_files, + "coverage_tool": coverage_tool, + "files": files, + "implementation_name": implementation_name, + "interpreter": interpreter, + "interpreter_path": interpreter_path, + "interpreter_version_info": interpreter_version_info_struct_from_dict(interpreter_version_info), + "pyc_tag": pyc_tag, + "python_version": python_version, + "stage2_bootstrap_template": stage2_bootstrap_template, + "stub_shebang": stub_shebang, + "zip_main_template": zip_main_template, + } + +PyRuntimeInfo, _unused_raw_py_runtime_info_ctor = define_bazel_6_provider( + doc = """Contains information about a Python runtime, as returned by the `py_runtime` +rule. + +A Python runtime describes either a *platform runtime* or an *in-build runtime*. +A platform runtime accesses a system-installed interpreter at a known path, +whereas an in-build runtime points to a `File` that acts as the interpreter. In +both cases, an "interpreter" is really any executable binary or wrapper script +that is capable of running a Python script passed on the command line, following +the same conventions as the standard CPython interpreter. +""", + init = _PyRuntimeInfo_init, + fields = { + "bootstrap_template": """ +:type: File + +A template of code responsible for the initial startup of a program. + +This code is responsible for: + +* Locating the target interpreter. Typically it is in runfiles, but not always. +* Setting necessary environment variables, command line flags, or other + configuration that can't be modified after the interpreter starts. +* Invoking the appropriate entry point. This is usually a second-stage bootstrap + that performs additional setup prior to running a program's actual entry point. + +The {obj}`--bootstrap_impl` flag affects how this stage 1 bootstrap +is expected to behave and the substutitions performed. + +* `--bootstrap_impl=system_python` substitutions: `%is_zipfile%`, `%python_binary%`, + `%target%`, `%workspace_name`, `%coverage_tool%`, `%import_all%`, `%imports%`, + `%main%`, `%shebang%` +* `--bootstrap_impl=script` substititions: `%is_zipfile%`, `%python_binary%`, + `%target%`, `%workspace_name`, `%shebang%, `%stage2_bootstrap%` + +Substitution definitions: + +* `%shebang%`: The shebang to use with the bootstrap; the bootstrap template + may choose to ignore this. +* `%stage2_bootstrap%`: A runfiles-relative path to the stage 2 bootstrap. +* `%python_binary%`: The path to the target Python interpreter. There are three + types of paths: + * An absolute path to a system interpreter (e.g. begins with `/`). + * A runfiles-relative path to an interpreter (e.g. `somerepo/bin/python3`) + * A program to search for on PATH, i.e. a word without spaces, e.g. `python3`. +* `%workspace_name%`: The name of the workspace the target belongs to. +* `%is_zipfile%`: The string `1` if this template is prepended to a zipfile to + create a self-executable zip file. The string `0` otherwise. + +For the other substitution definitions, see the {obj}`stage2_bootstrap_template` +docs. + +:::{versionchanged} 0.33.0 +The set of substitutions depends on {obj}`--bootstrap_impl` +::: +""", + "coverage_files": """ +:type: depset[File] | None + +The files required at runtime for using `coverage_tool`. Will be `None` if no +`coverage_tool` was provided. +""", + "coverage_tool": """ +:type: File | None + +If set, this field is a `File` representing tool used for collecting code +coverage information from python tests. Otherwise, this is `None`. +""", + "files": """ +:type: depset[File] | None + +If this is an in-build runtime, this field is a `depset` of `File`s that need to +be added to the runfiles of an executable target that uses this runtime (in +particular, files needed by `interpreter`). The value of `interpreter` need not +be included in this field. If this is a platform runtime then this field is +`None`. +""", + "implementation_name": """ +:type: str | None + +The Python implementation name (`sys.implementation.name`) +""", + "interpreter": """ +:type: File | None + +If this is an in-build runtime, this field is a `File` representing the +interpreter. Otherwise, this is `None`. Note that an in-build runtime can use +either a prebuilt, checked-in interpreter or an interpreter built from source. +""", + "interpreter_path": """ +:type: str | None + +If this is a platform runtime, this field is the absolute filesystem path to the +interpreter on the target platform. Otherwise, this is `None`. +""", + "interpreter_version_info": """ +:type: struct + +Version information about the interpreter this runtime provides. +It should match the format given by `sys.version_info`, however +for simplicity, the micro, releaselevel, and serial values are +optional. +A struct with the following fields: +* `major`: {type}`int`, the major version number +* `minor`: {type}`int`, the minor version number +* `micro`: {type}`int | None`, the micro version number +* `releaselevel`: {type}`str | None`, the release level +* `serial`: {type}`int | None`, the serial number of the release +""", + "pyc_tag": """ +:type: str | None + +The tag portion of a pyc filename, e.g. the `cpython-39` infix +of `foo.cpython-39.pyc`. See PEP 3147. If not specified, it will be computed +from {obj}`implementation_name` and {obj}`interpreter_version_info`. If no +pyc_tag is available, then only source-less pyc generation will function +correctly. +""", + "python_version": """ +:type: str + +Indicates whether this runtime uses Python major version 2 or 3. Valid values +are (only) `"PY2"` and `"PY3"`. +""", + "stage2_bootstrap_template": """ +:type: File + +A template of Python code that runs under the desired interpreter and is +responsible for orchestrating calling the program's actual main code. This +bootstrap is responsible for affecting the current runtime's state, such as +import paths or enabling coverage, so that, when it runs the program's actual +main code, it works properly under Bazel. + +The following substitutions are made during template expansion: +* `%main%`: A runfiles-relative path to the program's actual main file. This + can be a `.py` or `.pyc` file, depending on precompile settings. +* `%coverage_tool%`: Runfiles-relative path to the coverage library's entry point. + If coverage is not enabled or available, an empty string. +* `%import_all%`: The string `True` if all repositories in the runfiles should + be added to sys.path. The string `False` otherwise. +* `%imports%`: A colon-delimited string of runfiles-relative paths to add to + sys.path. +* `%target%`: The name of the target this is for. +* `%workspace_name%`: The name of the workspace the target belongs to. + +:::{versionadded} 0.33.0 +::: +""", + "stub_shebang": """ +:type: str + +"Shebang" expression prepended to the bootstrapping Python stub +script used when executing {obj}`py_binary` targets. Does not +apply to Windows. +""", + "zip_main_template": """ +:type: File + +A template of Python code that becomes a zip file's top-level `__main__.py` +file. The top-level `__main__.py` file is used when the zip file is explicitly +passed to a Python interpreter. See PEP 441 for more information about zipapp +support. Note that py_binary-generated zip files are self-executing and +skip calling `__main__.py`. + +The following substitutions are made during template expansion: +* `%stage2_bootstrap%`: A runfiles-relative string to the stage 2 bootstrap file. +* `%python_binary%`: The path to the target Python interpreter. There are three + types of paths: + * An absolute path to a system interpreter (e.g. begins with `/`). + * A runfiles-relative path to an interpreter (e.g. `somerepo/bin/python3`) + * A program to search for on PATH, i.e. a word without spaces, e.g. `python3`. +* `%workspace_name%`: The name of the workspace for the built target. + +:::{versionadded} 0.33.0 +::: +""", + }, +) diff --git a/python/private/common/py_runtime_macro.bzl b/python/private/py_runtime_macro.bzl similarity index 100% rename from python/private/common/py_runtime_macro.bzl rename to python/private/py_runtime_macro.bzl diff --git a/python/private/py_runtime_pair_rule.bzl b/python/private/py_runtime_pair_rule.bzl index 39f15bffb4..b3b7a4e5f8 100644 --- a/python/private/py_runtime_pair_rule.bzl +++ b/python/private/py_runtime_pair_rule.bzl @@ -16,8 +16,8 @@ load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo") load("//python:py_runtime_info.bzl", "PyRuntimeInfo") -load("//python/private:reexports.bzl", "BuiltinPyRuntimeInfo") -load("//python/private:util.bzl", "IS_BAZEL_7_OR_HIGHER") +load(":reexports.bzl", "BuiltinPyRuntimeInfo") +load(":util.bzl", "IS_BAZEL_7_OR_HIGHER") def _py_runtime_pair_impl(ctx): if ctx.attr.py2_runtime != None: diff --git a/python/private/common/py_runtime_rule.bzl b/python/private/py_runtime_rule.bzl similarity index 98% rename from python/private/common/py_runtime_rule.bzl rename to python/private/py_runtime_rule.bzl index 088b6ead16..ba9b36d13a 100644 --- a/python/private/common/py_runtime_rule.bzl +++ b/python/private/py_runtime_rule.bzl @@ -16,11 +16,11 @@ load("@bazel_skylib//lib:dicts.bzl", "dicts") load("@bazel_skylib//lib:paths.bzl", "paths") load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo") -load("//python/private:reexports.bzl", "BuiltinPyRuntimeInfo") -load("//python/private:util.bzl", "IS_BAZEL_7_OR_HIGHER") load(":attributes.bzl", "NATIVE_RULES_ALLOWLIST_ATTRS") -load(":providers.bzl", "DEFAULT_BOOTSTRAP_TEMPLATE", "DEFAULT_STUB_SHEBANG", "PyRuntimeInfo") load(":py_internal.bzl", "py_internal") +load(":py_runtime_info.bzl", "DEFAULT_BOOTSTRAP_TEMPLATE", "DEFAULT_STUB_SHEBANG", "PyRuntimeInfo") +load(":reexports.bzl", "BuiltinPyRuntimeInfo") +load(":util.bzl", "IS_BAZEL_7_OR_HIGHER") _py_builtins = py_internal diff --git a/python/private/common/py_test_macro_bazel.bzl b/python/private/py_test_macro_bazel.bzl similarity index 100% rename from python/private/common/py_test_macro_bazel.bzl rename to python/private/py_test_macro_bazel.bzl diff --git a/python/private/common/py_test_rule_bazel.bzl b/python/private/py_test_rule_bazel.bzl similarity index 100% rename from python/private/common/py_test_rule_bazel.bzl rename to python/private/py_test_rule_bazel.bzl diff --git a/python/private/py_toolchain_suite.bzl b/python/private/py_toolchain_suite.bzl index 3fead95069..a69be376b4 100644 --- a/python/private/py_toolchain_suite.bzl +++ b/python/private/py_toolchain_suite.bzl @@ -15,7 +15,7 @@ """Create the toolchain defs in a BUILD.bazel file.""" load("@bazel_skylib//lib:selects.bzl", "selects") -load("//python/private:text_util.bzl", "render") +load(":text_util.bzl", "render") load( ":toolchain_types.bzl", "EXEC_TOOLS_TOOLCHAIN_TYPE", diff --git a/python/private/py_wheel.bzl b/python/private/py_wheel.bzl index 26eb5652a6..6d047ad680 100644 --- a/python/private/py_wheel.bzl +++ b/python/private/py_wheel.bzl @@ -14,9 +14,9 @@ "Implementation of py_wheel rule" -load("//python/private:stamp.bzl", "is_stamping_enabled") load(":py_package.bzl", "py_package_lib") load(":py_wheel_normalize_pep440.bzl", "normalize_pep440") +load(":stamp.bzl", "is_stamping_enabled") PyWheelInfo = provider( doc = "Information about a wheel produced by `py_wheel`", diff --git a/python/private/common/semantics.bzl b/python/private/semantics.bzl similarity index 100% rename from python/private/common/semantics.bzl rename to python/private/semantics.bzl diff --git a/python/private/toolchains_repo.bzl b/python/private/toolchains_repo.bzl index 4fae987c74..d21e46ac48 100644 --- a/python/private/toolchains_repo.bzl +++ b/python/private/toolchains_repo.bzl @@ -30,8 +30,8 @@ load( "PLATFORMS", "WINDOWS_NAME", ) -load("//python/private:repo_utils.bzl", "REPO_DEBUG_ENV_VAR", "repo_utils") -load("//python/private:text_util.bzl", "render") +load(":repo_utils.bzl", "REPO_DEBUG_ENV_VAR", "repo_utils") +load(":text_util.bzl", "render") def get_repository_name(repository_workspace): dummy_label = "//:_" diff --git a/python/py_binary.bzl b/python/py_binary.bzl index f7f68e6045..349610865f 100644 --- a/python/py_binary.bzl +++ b/python/py_binary.bzl @@ -15,9 +15,9 @@ """Public entry point for py_binary.""" load("@rules_python_internal//:rules_python_config.bzl", "config") +load("//python/private:py_binary_macro_bazel.bzl", _starlark_py_binary = "py_binary") load("//python/private:register_extension_info.bzl", "register_extension_info") load("//python/private:util.bzl", "add_migration_tag") -load("//python/private/common:py_binary_macro_bazel.bzl", _starlark_py_binary = "py_binary") # buildifier: disable=native-python _py_binary_impl = _starlark_py_binary if config.enable_pystar else native.py_binary @@ -26,9 +26,8 @@ def py_binary(**attrs): """Creates an executable Python program. This is the public macro wrapping the underlying rule. Args are forwarded - on as-is unless otherwise specified. See - the underlying {bzl:obj}`py_binary rule` - for detailed attribute documentation. + on as-is unless otherwise specified. See the underlying {rule}`py_binary` + rule for detailed attribute documentation. This macro affects the following args: * `python_version`: cannot be `PY2` @@ -36,8 +35,7 @@ def py_binary(**attrs): * `tags`: May have special marker values added, if not already present. Args: - **attrs: Rule attributes forwarded onto the underlying - {bzl:obj}`py_binary rule` + **attrs: Rule attributes forwarded onto the underlying {rule}`py_binary`. """ if attrs.get("python_version") == "PY2": fail("Python 2 is no longer supported: https://github.com/bazelbuild/rules_python/issues/886") diff --git a/python/py_cc_link_params_info.bzl b/python/py_cc_link_params_info.bzl index b0ad0a79d2..02eff71c4d 100644 --- a/python/py_cc_link_params_info.bzl +++ b/python/py_cc_link_params_info.bzl @@ -1,10 +1,10 @@ """Public entry point for PyCcLinkParamsInfo.""" load("@rules_python_internal//:rules_python_config.bzl", "config") -load("//python/private/common:providers.bzl", _starlark_PyCcLinkParamsProvider = "PyCcLinkParamsProvider") +load("//python/private:py_cc_link_params_info.bzl", _starlark_PyCcLinkParamsInfo = "PyCcLinkParamsInfo") PyCcLinkParamsInfo = ( - _starlark_PyCcLinkParamsProvider if ( + _starlark_PyCcLinkParamsInfo if ( config.enable_pystar or config.BuiltinPyCcLinkParamsProvider == None ) else config.BuiltinPyCcLinkParamsProvider ) diff --git a/python/py_library.bzl b/python/py_library.bzl index 3b9ddd1aa4..4ec1da4b27 100644 --- a/python/py_library.bzl +++ b/python/py_library.bzl @@ -15,9 +15,9 @@ """Public entry point for py_library.""" load("@rules_python_internal//:rules_python_config.bzl", "config") +load("//python/private:py_library_macro_bazel.bzl", _starlark_py_library = "py_library") load("//python/private:register_extension_info.bzl", "register_extension_info") load("//python/private:util.bzl", "add_migration_tag") -load("//python/private/common:py_library_macro_bazel.bzl", _starlark_py_library = "py_library") # buildifier: disable=native-python _py_library_impl = _starlark_py_library if config.enable_pystar else native.py_library @@ -27,16 +27,14 @@ def py_library(**attrs): This is the public macro wrapping the underlying rule. Args are forwarded on as-is unless otherwise specified. See - {bzl:obj}`py_library ` - for detailed attribute documentation. + {rule}`py_library` for detailed attribute documentation. This macro affects the following args: * `srcs_version`: cannot be `PY2` or `PY2ONLY` * `tags`: May have special marker values added, if not already present. Args: - **attrs: Rule attributes forwarded onto - {bzl:obj}`py_library ` + **attrs: Rule attributes forwarded onto {rule}`py_library`. """ if attrs.get("srcs_version") in ("PY2", "PY2ONLY"): fail("Python 2 is no longer supported: https://github.com/bazelbuild/rules_python/issues/886") diff --git a/python/py_runtime.bzl b/python/py_runtime.bzl index 9c8cd00dd9..2c44523505 100644 --- a/python/py_runtime.bzl +++ b/python/py_runtime.bzl @@ -14,8 +14,8 @@ """Public entry point for py_runtime.""" +load("//python/private:py_runtime_macro.bzl", _starlark_py_runtime = "py_runtime") load("//python/private:util.bzl", "IS_BAZEL_6_OR_HIGHER", "add_migration_tag") -load("//python/private/common:py_runtime_macro.bzl", _starlark_py_runtime = "py_runtime") # buildifier: disable=native-python _py_runtime_impl = _starlark_py_runtime if IS_BAZEL_6_OR_HIGHER else native.py_runtime @@ -25,7 +25,7 @@ def py_runtime(**attrs): This is the public macro wrapping the underlying rule. Args are forwarded on as-is unless otherwise specified. See - {bzl:obj}`py_runtime ` + {rule}`py_runtime` for detailed attribute documentation. This macro affects the following args: @@ -34,8 +34,7 @@ def py_runtime(**attrs): * `tags`: May have special marker values added, if not already present. Args: - **attrs: Rule attributes forwarded onto - {bzl:obj}`py_runtime ` + **attrs: Rule attributes forwarded onto {rule}`py_runtime`. """ if attrs.get("python_version") == "PY2": fail("Python 2 is no longer supported: see https://github.com/bazelbuild/rules_python/issues/886") diff --git a/python/py_runtime_info.bzl b/python/py_runtime_info.bzl index e88e0c0235..3a31c0f2f4 100644 --- a/python/py_runtime_info.bzl +++ b/python/py_runtime_info.bzl @@ -15,7 +15,7 @@ """Public entry point for PyRuntimeInfo.""" load("@rules_python_internal//:rules_python_config.bzl", "config") +load("//python/private:py_runtime_info.bzl", _starlark_PyRuntimeInfo = "PyRuntimeInfo") load("//python/private:reexports.bzl", "BuiltinPyRuntimeInfo") -load("//python/private/common:providers.bzl", _starlark_PyRuntimeInfo = "PyRuntimeInfo") PyRuntimeInfo = _starlark_PyRuntimeInfo if config.enable_pystar else BuiltinPyRuntimeInfo diff --git a/python/py_test.bzl b/python/py_test.bzl index 8f93b270ff..2aa93ff54b 100644 --- a/python/py_test.bzl +++ b/python/py_test.bzl @@ -15,9 +15,9 @@ """Public entry point for py_test.""" load("@rules_python_internal//:rules_python_config.bzl", "config") +load("//python/private:py_test_macro_bazel.bzl", _starlark_py_test = "py_test") load("//python/private:register_extension_info.bzl", "register_extension_info") load("//python/private:util.bzl", "add_migration_tag") -load("//python/private/common:py_test_macro_bazel.bzl", _starlark_py_test = "py_test") # buildifier: disable=native-python _py_test_impl = _starlark_py_test if config.enable_pystar else native.py_test @@ -27,8 +27,7 @@ def py_test(**attrs): This is the public macro wrapping the underlying rule. Args are forwarded on as-is unless otherwise specified. See - {bzl:obj}`py_test ` - for detailed attribute documentation. + {rule}`py_test` for detailed attribute documentation. This macro affects the following args: * `python_version`: cannot be `PY2` @@ -36,8 +35,7 @@ def py_test(**attrs): * `tags`: May have special marker values added, if not already present. Args: - **attrs: Rule attributes forwarded onto - {bzl:obj}`py_test ` + **attrs: Rule attributes forwarded onto {rule}`py_test`. """ if attrs.get("python_version") == "PY2": fail("Python 2 is no longer supported: https://github.com/bazelbuild/rules_python/issues/886")