fix(rules): remove rules_python --incompatible_python_disallow_native_rules checking (#2327)
When --incompatible_python_disallow_native_rules is enabled, all the
core rules fail with
an error that rules_python should be used. This is incorrect, since the
rules_python rules
are being used. What's happening is
https://github.com/bazelbuild/rules_python/pull/2257
removed the magic migration tag when pystar is enabled, but the code to
check the tag
was present wasn't removed. This went unnoticed because our CI doesn't
set the migration
flag.
To fix, remove the validation logic entirely. If we're in the
rules_python implementation,
then there is not need to perform this validation. It was just something
copy/pasted from
the original code from Bazel itself.
Also update the bazelrc to always set
--incompatible_python_disallow_native_rules.
Fixes https://github.com/bazelbuild/rules_python/issues/2326
Fixes https://github.com/bazelbuild/rules_python/issues/1645
diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml
index d7f2f7a..5d51b10 100644
--- a/.bazelci/presubmit.yml
+++ b/.bazelci/presubmit.yml
@@ -94,6 +94,8 @@
bazel: "7.x"
environment:
RULES_PYTHON_ENABLE_PYSTAR: "1"
+ build_flags:
+ - "--config=bazel7.x"
test_flags:
# The doc check tests fail because the Starlark implementation makes the
# PyInfo and PyRuntimeInfo symbols become documented.
diff --git a/.bazelrc b/.bazelrc
index 1ca469c..c44124d 100644
--- a/.bazelrc
+++ b/.bazelrc
@@ -33,4 +33,6 @@
# Some bzl files contain repos only available under bzlmod
build:rtd --enable_bzlmod
+common:bazel7.x --incompatible_python_disallow_native_rules
+
build --lockfile_mode=update
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1994af2..4774174 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -31,7 +31,9 @@
{#v0-0-0-fixed}
### Fixed
-- Nothing yet
+* (rules) Setting `--incompatible_python_disallow_native_rules` no longer
+ causes rules_python rules to fail.
+ ([#2326](https://github.com/bazelbuild/rules_python/issues/2326).
{#v0-0-0-added}
### Added
diff --git a/examples/build_file_generation/.bazelrc b/examples/build_file_generation/.bazelrc
index e0b1984..fd0f731 100644
--- a/examples/build_file_generation/.bazelrc
+++ b/examples/build_file_generation/.bazelrc
@@ -6,3 +6,5 @@
# The bzlmod version of this example is in examples/bzlmod_build_file_generation
# Once WORKSPACE support is dropped, this example can be entirely deleted.
build --experimental_enable_bzlmod=false
+
+common:bazel7.x --incompatible_python_disallow_native_rules
diff --git a/examples/bzlmod/.bazelrc b/examples/bzlmod/.bazelrc
index fd16095..ca83047 100644
--- a/examples/bzlmod/.bazelrc
+++ b/examples/bzlmod/.bazelrc
@@ -7,3 +7,4 @@
# Windows requires these for multi-python support:
build --enable_runfiles
+common:bazel7.x --incompatible_python_disallow_native_rules
diff --git a/examples/bzlmod/MODULE.bazel.lock b/examples/bzlmod/MODULE.bazel.lock
index 681a701..25930d1 100644
--- a/examples/bzlmod/MODULE.bazel.lock
+++ b/examples/bzlmod/MODULE.bazel.lock
@@ -6303,8 +6303,8 @@
"usagesDigest": "Y8ihY+R57BAFhalrVLVdJFrpwlbsiKz9JPJ99ljF7HA=",
"recordedFileInputs": {
"@@rules_python~//tools/publish/requirements.txt": "031e35d03dde03ae6305fe4b3d1f58ad7bdad857379752deede0f93649991b8a",
- "@@rules_python~//tools/publish/requirements_windows.txt": "27831a1477549ad865043f17a9c1dd9a19566d460ba1f68cd8dfded642accbca",
- "@@rules_python~//tools/publish/requirements_darwin.txt": "91df49ab0079887f6b7ee4035f9e2a686036c749e7ce82837a4a74b471e4a9aa"
+ "@@rules_python~//tools/publish/requirements_windows.txt": "a24d2aeea74a744a0aad1ac262cb9fb9e2f6f14f8d08d4f11a84f3f54da81231",
+ "@@rules_python~//tools/publish/requirements_darwin.txt": "186c9e45c372e30cae42e31696420a9065580147f71bd834e3e3ba477842bb5a"
},
"recordedDirentsInputs": {},
"envVariables": {
@@ -6334,6 +6334,26 @@
]
}
},
+ "rules_python_publish_deps_311_charset_normalizer_cp311_cp311_macosx_10_9_x86_64_c57516e5": {
+ "bzlFile": "@@rules_python~//python/private/pypi:whl_library.bzl",
+ "ruleClassName": "whl_library",
+ "attributes": {
+ "dep_template": "@rules_python_publish_deps//{name}:{target}",
+ "experimental_target_platforms": [
+ "cp311_osx_aarch64",
+ "cp311_osx_x86_64",
+ "cp311_windows_x86_64"
+ ],
+ "filename": "charset_normalizer-3.4.0-cp311-cp311-macosx_10_9_x86_64.whl",
+ "python_interpreter_target": "@@rules_python~~python~python_3_11_host//:python",
+ "repo": "rules_python_publish_deps_311",
+ "requirement": "charset-normalizer==3.4.0",
+ "sha256": "c57516e58fd17d03ebe67e181a4e4e2ccab1168f8c2976c6a334d4f819fe5944",
+ "urls": [
+ "https://files.pythonhosted.org/packages/77/d5/8c982d58144de49f59571f940e329ad6e8615e1e82ef84584c5eeb5e1d72/charset_normalizer-3.4.0-cp311-cp311-macosx_10_9_x86_64.whl"
+ ]
+ }
+ },
"rules_python_publish_deps_311_urllib3_sdist_076907bf": {
"bzlFile": "@@rules_python~//python/private/pypi:whl_library.bzl",
"ruleClassName": "whl_library",
@@ -6447,6 +6467,26 @@
]
}
},
+ "rules_python_publish_deps_311_charset_normalizer_cp311_cp311_macosx_11_0_arm64_6dba5d19": {
+ "bzlFile": "@@rules_python~//python/private/pypi:whl_library.bzl",
+ "ruleClassName": "whl_library",
+ "attributes": {
+ "dep_template": "@rules_python_publish_deps//{name}:{target}",
+ "experimental_target_platforms": [
+ "cp311_osx_aarch64",
+ "cp311_osx_x86_64",
+ "cp311_windows_x86_64"
+ ],
+ "filename": "charset_normalizer-3.4.0-cp311-cp311-macosx_11_0_arm64.whl",
+ "python_interpreter_target": "@@rules_python~~python~python_3_11_host//:python",
+ "repo": "rules_python_publish_deps_311",
+ "requirement": "charset-normalizer==3.4.0",
+ "sha256": "6dba5d19c4dfab08e58d5b36304b3f92f3bd5d42c1a3fa37b5ba5cdf6dfcbcee",
+ "urls": [
+ "https://files.pythonhosted.org/packages/bf/19/411a64f01ee971bed3231111b69eb56f9331a769072de479eae7de52296d/charset_normalizer-3.4.0-cp311-cp311-macosx_11_0_arm64.whl"
+ ]
+ }
+ },
"rules_python_publish_deps_311_readme_renderer_py3_none_any_f67a16ca": {
"bzlFile": "@@rules_python~//python/private/pypi:whl_library.bzl",
"ruleClassName": "whl_library",
@@ -6519,26 +6559,6 @@
]
}
},
- "rules_python_publish_deps_311_charset_normalizer_cp311_cp311_macosx_10_9_universal2_802fe99c": {
- "bzlFile": "@@rules_python~//python/private/pypi:whl_library.bzl",
- "ruleClassName": "whl_library",
- "attributes": {
- "dep_template": "@rules_python_publish_deps//{name}:{target}",
- "experimental_target_platforms": [
- "cp311_osx_aarch64",
- "cp311_osx_x86_64",
- "cp311_windows_x86_64"
- ],
- "filename": "charset_normalizer-3.3.2-cp311-cp311-macosx_10_9_universal2.whl",
- "python_interpreter_target": "@@rules_python~~python~python_3_11_host//:python",
- "repo": "rules_python_publish_deps_311",
- "requirement": "charset-normalizer==3.3.2",
- "sha256": "802fe99cca7457642125a8a88a084cef28ff0cf9407060f7b93dca5aa25480db",
- "urls": [
- "https://files.pythonhosted.org/packages/68/77/02839016f6fbbf808e8b38601df6e0e66c17bbab76dff4613f7511413597/charset_normalizer-3.3.2-cp311-cp311-macosx_10_9_universal2.whl"
- ]
- }
- },
"rules_python_publish_deps_311_cffi_cp311_cp311_manylinux_2_17_x86_64_94411f22": {
"bzlFile": "@@rules_python~//python/private/pypi:whl_library.bzl",
"ruleClassName": "whl_library",
@@ -6583,6 +6603,26 @@
]
}
},
+ "rules_python_publish_deps_311_charset_normalizer_sdist_223217c3": {
+ "bzlFile": "@@rules_python~//python/private/pypi:whl_library.bzl",
+ "ruleClassName": "whl_library",
+ "attributes": {
+ "dep_template": "@rules_python_publish_deps//{name}:{target}",
+ "experimental_target_platforms": [
+ "cp311_osx_aarch64",
+ "cp311_osx_x86_64",
+ "cp311_windows_x86_64"
+ ],
+ "filename": "charset_normalizer-3.4.0.tar.gz",
+ "python_interpreter_target": "@@rules_python~~python~python_3_11_host//:python",
+ "repo": "rules_python_publish_deps_311",
+ "requirement": "charset-normalizer==3.4.0",
+ "sha256": "223217c3d4f82c3ac5e29032b3f1c2eb0fb591b72161f86d93f5719079dae93e",
+ "urls": [
+ "https://files.pythonhosted.org/packages/f2/4f/e1808dc01273379acc506d18f1504eb2d299bd4131743b9fc54d7be4df1e/charset_normalizer-3.4.0.tar.gz"
+ ]
+ }
+ },
"rules_python_publish_deps_311_pygments_py3_none_any_fa7bd7bd": {
"bzlFile": "@@rules_python~//python/private/pypi:whl_library.bzl",
"ruleClassName": "whl_library",
@@ -7153,6 +7193,26 @@
]
}
},
+ "rules_python_publish_deps_311_charset_normalizer_cp311_cp311_win_amd64_cee4373f": {
+ "bzlFile": "@@rules_python~//python/private/pypi:whl_library.bzl",
+ "ruleClassName": "whl_library",
+ "attributes": {
+ "dep_template": "@rules_python_publish_deps//{name}:{target}",
+ "experimental_target_platforms": [
+ "cp311_osx_aarch64",
+ "cp311_osx_x86_64",
+ "cp311_windows_x86_64"
+ ],
+ "filename": "charset_normalizer-3.4.0-cp311-cp311-win_amd64.whl",
+ "python_interpreter_target": "@@rules_python~~python~python_3_11_host//:python",
+ "repo": "rules_python_publish_deps_311",
+ "requirement": "charset-normalizer==3.4.0",
+ "sha256": "cee4373f4d3ad28f1ab6290684d8e2ebdb9e7a1b74fdc39e4c211995f77bec27",
+ "urls": [
+ "https://files.pythonhosted.org/packages/0b/6e/b13bd47fa9023b3699e94abf565b5a2f0b0be6e9ddac9812182596ee62e4/charset_normalizer-3.4.0-cp311-cp311-win_amd64.whl"
+ ]
+ }
+ },
"rules_python_publish_deps_311_pywin32_ctypes_py2_none_any_9dc2d991": {
"bzlFile": "@@rules_python~//python/private/pypi:whl_library.bzl",
"ruleClassName": "whl_library",
@@ -7263,26 +7323,6 @@
]
}
},
- "rules_python_publish_deps_311_charset_normalizer_sdist_f30c3cb3": {
- "bzlFile": "@@rules_python~//python/private/pypi:whl_library.bzl",
- "ruleClassName": "whl_library",
- "attributes": {
- "dep_template": "@rules_python_publish_deps//{name}:{target}",
- "experimental_target_platforms": [
- "cp311_osx_aarch64",
- "cp311_osx_x86_64",
- "cp311_windows_x86_64"
- ],
- "filename": "charset-normalizer-3.3.2.tar.gz",
- "python_interpreter_target": "@@rules_python~~python~python_3_11_host//:python",
- "repo": "rules_python_publish_deps_311",
- "requirement": "charset-normalizer==3.3.2",
- "sha256": "f30c3cb33b24454a82faecaf01b19c18562b1e89558fb6c56de4d9118a032fd5",
- "urls": [
- "https://files.pythonhosted.org/packages/63/09/c1bc53dab74b1816a00d8d030de5bf98f724c52c1635e07681d312f20be8/charset-normalizer-3.3.2.tar.gz"
- ]
- }
- },
"rules_python_publish_deps_311_cryptography_sdist_831a4b37": {
"bzlFile": "@@rules_python~//python/private/pypi:whl_library.bzl",
"ruleClassName": "whl_library",
@@ -7345,6 +7385,26 @@
]
}
},
+ "rules_python_publish_deps_311_charset_normalizer_py3_none_any_fe9f97fe": {
+ "bzlFile": "@@rules_python~//python/private/pypi:whl_library.bzl",
+ "ruleClassName": "whl_library",
+ "attributes": {
+ "dep_template": "@rules_python_publish_deps//{name}:{target}",
+ "experimental_target_platforms": [
+ "cp311_osx_aarch64",
+ "cp311_osx_x86_64",
+ "cp311_windows_x86_64"
+ ],
+ "filename": "charset_normalizer-3.4.0-py3-none-any.whl",
+ "python_interpreter_target": "@@rules_python~~python~python_3_11_host//:python",
+ "repo": "rules_python_publish_deps_311",
+ "requirement": "charset-normalizer==3.4.0",
+ "sha256": "fe9f97feb71aa9896b81973a7bbada8c49501dc73e58a10fcef6663af95e5079",
+ "urls": [
+ "https://files.pythonhosted.org/packages/bf/9b/08c0432272d77b04803958a4598a51e2a4b51c06640af8b8f0f908c18bf2/charset_normalizer-3.4.0-py3-none-any.whl"
+ ]
+ }
+ },
"rules_python_publish_deps_311_cryptography_cp39_abi3_musllinux_1_2_x86_64_ce8613be": {
"bzlFile": "@@rules_python~//python/private/pypi:whl_library.bzl",
"ruleClassName": "whl_library",
@@ -7487,26 +7547,6 @@
]
}
},
- "rules_python_publish_deps_311_charset_normalizer_cp311_cp311_macosx_11_0_arm64_549a3a73": {
- "bzlFile": "@@rules_python~//python/private/pypi:whl_library.bzl",
- "ruleClassName": "whl_library",
- "attributes": {
- "dep_template": "@rules_python_publish_deps//{name}:{target}",
- "experimental_target_platforms": [
- "cp311_osx_aarch64",
- "cp311_osx_x86_64",
- "cp311_windows_x86_64"
- ],
- "filename": "charset_normalizer-3.3.2-cp311-cp311-macosx_11_0_arm64.whl",
- "python_interpreter_target": "@@rules_python~~python~python_3_11_host//:python",
- "repo": "rules_python_publish_deps_311",
- "requirement": "charset-normalizer==3.3.2",
- "sha256": "549a3a73da901d5bc3ce8d24e0600d1fa85524c10287f6004fbab87672bf3e1e",
- "urls": [
- "https://files.pythonhosted.org/packages/dd/51/68b61b90b24ca35495956b718f35a9756ef7d3dd4b3c1508056fa98d1a1b/charset_normalizer-3.3.2-cp311-cp311-macosx_11_0_arm64.whl"
- ]
- }
- },
"rules_python_publish_deps_311_rfc3986_sdist_97aacf9d": {
"bzlFile": "@@rules_python~//python/private/pypi:whl_library.bzl",
"ruleClassName": "whl_library",
@@ -7557,26 +7597,6 @@
]
}
},
- "rules_python_publish_deps_311_charset_normalizer_py3_none_any_3e4d1f65": {
- "bzlFile": "@@rules_python~//python/private/pypi:whl_library.bzl",
- "ruleClassName": "whl_library",
- "attributes": {
- "dep_template": "@rules_python_publish_deps//{name}:{target}",
- "experimental_target_platforms": [
- "cp311_osx_aarch64",
- "cp311_osx_x86_64",
- "cp311_windows_x86_64"
- ],
- "filename": "charset_normalizer-3.3.2-py3-none-any.whl",
- "python_interpreter_target": "@@rules_python~~python~python_3_11_host//:python",
- "repo": "rules_python_publish_deps_311",
- "requirement": "charset-normalizer==3.3.2",
- "sha256": "3e4d1f6587322d2788836a99c69062fbb091331ec940e02d12d179c1d53e25fc",
- "urls": [
- "https://files.pythonhosted.org/packages/28/76/e6222113b83e3622caa4bb41032d0b1bf785250607392e1b778aca0b8a7d/charset_normalizer-3.3.2-py3-none-any.whl"
- ]
- }
- },
"rules_python_publish_deps_311_cryptography_cp39_abi3_manylinux_2_28_aarch64_1df6fcbf": {
"bzlFile": "@@rules_python~//python/private/pypi:whl_library.bzl",
"ruleClassName": "whl_library",
@@ -8039,26 +8059,6 @@
]
}
},
- "rules_python_publish_deps_311_charset_normalizer_cp311_cp311_win_amd64_66394663": {
- "bzlFile": "@@rules_python~//python/private/pypi:whl_library.bzl",
- "ruleClassName": "whl_library",
- "attributes": {
- "dep_template": "@rules_python_publish_deps//{name}:{target}",
- "experimental_target_platforms": [
- "cp311_osx_aarch64",
- "cp311_osx_x86_64",
- "cp311_windows_x86_64"
- ],
- "filename": "charset_normalizer-3.3.2-cp311-cp311-win_amd64.whl",
- "python_interpreter_target": "@@rules_python~~python~python_3_11_host//:python",
- "repo": "rules_python_publish_deps_311",
- "requirement": "charset-normalizer==3.3.2",
- "sha256": "663946639d296df6a2bb2aa51b60a2454ca1cb29835324c640dafb5ff2131a77",
- "urls": [
- "https://files.pythonhosted.org/packages/57/ec/80c8d48ac8b1741d5b963797b7c0c869335619e13d4744ca2f67fc11c6fc/charset_normalizer-3.3.2-cp311-cp311-win_amd64.whl"
- ]
- }
- },
"rules_python_publish_deps_311_docutils_py3_none_any_5e1de4d8": {
"bzlFile": "@@rules_python~//python/private/pypi:whl_library.bzl",
"ruleClassName": "whl_library",
@@ -8271,7 +8271,7 @@
"bleach": "[{\"config_setting\":\"//_config:is_python_3.11\",\"filename\":\"bleach-6.0.0-py3-none-any.whl\",\"repo\":\"rules_python_publish_deps_311_bleach_py3_none_any_33c16e33\",\"target_platforms\":null,\"version\":\"3.11\"},{\"config_setting\":\"//_config:is_python_3.11\",\"filename\":\"bleach-6.0.0.tar.gz\",\"repo\":\"rules_python_publish_deps_311_bleach_sdist_1a1a85c1\",\"target_platforms\":null,\"version\":\"3.11\"}]",
"certifi": "[{\"config_setting\":\"//_config:is_python_3.11\",\"filename\":\"certifi-2022.12.7-py3-none-any.whl\",\"repo\":\"rules_python_publish_deps_311_certifi_py3_none_any_4ad3232f\",\"target_platforms\":[\"cp311_linux_aarch64\",\"cp311_linux_arm\",\"cp311_linux_ppc\",\"cp311_linux_s390x\",\"cp311_linux_x86_64\"],\"version\":\"3.11\"},{\"config_setting\":\"//_config:is_python_3.11\",\"filename\":\"certifi-2022.12.7.tar.gz\",\"repo\":\"rules_python_publish_deps_311_certifi_sdist_35824b4c\",\"target_platforms\":[\"cp311_linux_aarch64\",\"cp311_linux_arm\",\"cp311_linux_ppc\",\"cp311_linux_s390x\",\"cp311_linux_x86_64\"],\"version\":\"3.11\"},{\"config_setting\":\"//_config:is_python_3.11\",\"filename\":\"certifi-2024.8.30-py3-none-any.whl\",\"repo\":\"rules_python_publish_deps_311_certifi_py3_none_any_922820b5\",\"target_platforms\":[\"cp311_osx_aarch64\",\"cp311_osx_x86_64\",\"cp311_windows_x86_64\"],\"version\":\"3.11\"},{\"config_setting\":\"//_config:is_python_3.11\",\"filename\":\"certifi-2024.8.30.tar.gz\",\"repo\":\"rules_python_publish_deps_311_certifi_sdist_bec941d2\",\"target_platforms\":[\"cp311_osx_aarch64\",\"cp311_osx_x86_64\",\"cp311_windows_x86_64\"],\"version\":\"3.11\"}]",
"cffi": "[{\"config_setting\":\"//_config:is_python_3.11\",\"filename\":\"cffi-1.15.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl\",\"repo\":\"rules_python_publish_deps_311_cffi_cp311_cp311_manylinux_2_17_aarch64_3548db28\",\"target_platforms\":null,\"version\":\"3.11\"},{\"config_setting\":\"//_config:is_python_3.11\",\"filename\":\"cffi-1.15.1-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl\",\"repo\":\"rules_python_publish_deps_311_cffi_cp311_cp311_manylinux_2_17_ppc64le_91fc98ad\",\"target_platforms\":null,\"version\":\"3.11\"},{\"config_setting\":\"//_config:is_python_3.11\",\"filename\":\"cffi-1.15.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl\",\"repo\":\"rules_python_publish_deps_311_cffi_cp311_cp311_manylinux_2_17_x86_64_94411f22\",\"target_platforms\":null,\"version\":\"3.11\"},{\"config_setting\":\"//_config:is_python_3.11\",\"filename\":\"cffi-1.15.1-cp311-cp311-musllinux_1_1_x86_64.whl\",\"repo\":\"rules_python_publish_deps_311_cffi_cp311_cp311_musllinux_1_1_x86_64_cc4d65ae\",\"target_platforms\":null,\"version\":\"3.11\"},{\"config_setting\":\"//_config:is_python_3.11\",\"filename\":\"cffi-1.15.1.tar.gz\",\"repo\":\"rules_python_publish_deps_311_cffi_sdist_d400bfb9\",\"target_platforms\":null,\"version\":\"3.11\"}]",
- "charset_normalizer": "[{\"config_setting\":\"//_config:is_python_3.11\",\"filename\":\"charset-normalizer-3.0.1.tar.gz\",\"repo\":\"rules_python_publish_deps_311_charset_normalizer_sdist_ebea339a\",\"target_platforms\":[\"cp311_linux_aarch64\",\"cp311_linux_arm\",\"cp311_linux_ppc\",\"cp311_linux_s390x\",\"cp311_linux_x86_64\"],\"version\":\"3.11\"},{\"config_setting\":\"//_config:is_python_3.11\",\"filename\":\"charset-normalizer-3.3.2.tar.gz\",\"repo\":\"rules_python_publish_deps_311_charset_normalizer_sdist_f30c3cb3\",\"target_platforms\":[\"cp311_osx_aarch64\",\"cp311_osx_x86_64\",\"cp311_windows_x86_64\"],\"version\":\"3.11\"},{\"config_setting\":\"//_config:is_python_3.11\",\"filename\":\"charset_normalizer-3.0.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl\",\"repo\":\"rules_python_publish_deps_311_charset_normalizer_cp311_cp311_manylinux_2_17_aarch64_14e76c0f\",\"target_platforms\":null,\"version\":\"3.11\"},{\"config_setting\":\"//_config:is_python_3.11\",\"filename\":\"charset_normalizer-3.0.1-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl\",\"repo\":\"rules_python_publish_deps_311_charset_normalizer_cp311_cp311_manylinux_2_17_ppc64le_0c0a5902\",\"target_platforms\":null,\"version\":\"3.11\"},{\"config_setting\":\"//_config:is_python_3.11\",\"filename\":\"charset_normalizer-3.0.1-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl\",\"repo\":\"rules_python_publish_deps_311_charset_normalizer_cp311_cp311_manylinux_2_17_s390x_8c7fe7af\",\"target_platforms\":null,\"version\":\"3.11\"},{\"config_setting\":\"//_config:is_python_3.11\",\"filename\":\"charset_normalizer-3.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl\",\"repo\":\"rules_python_publish_deps_311_charset_normalizer_cp311_cp311_manylinux_2_17_x86_64_79909e27\",\"target_platforms\":null,\"version\":\"3.11\"},{\"config_setting\":\"//_config:is_python_3.11\",\"filename\":\"charset_normalizer-3.0.1-cp311-cp311-musllinux_1_1_aarch64.whl\",\"repo\":\"rules_python_publish_deps_311_charset_normalizer_cp311_cp311_musllinux_1_1_aarch64_72966d1b\",\"target_platforms\":null,\"version\":\"3.11\"},{\"config_setting\":\"//_config:is_python_3.11\",\"filename\":\"charset_normalizer-3.0.1-cp311-cp311-musllinux_1_1_ppc64le.whl\",\"repo\":\"rules_python_publish_deps_311_charset_normalizer_cp311_cp311_musllinux_1_1_ppc64le_5995f016\",\"target_platforms\":null,\"version\":\"3.11\"},{\"config_setting\":\"//_config:is_python_3.11\",\"filename\":\"charset_normalizer-3.0.1-cp311-cp311-musllinux_1_1_s390x.whl\",\"repo\":\"rules_python_publish_deps_311_charset_normalizer_cp311_cp311_musllinux_1_1_s390x_4a8fcf28\",\"target_platforms\":null,\"version\":\"3.11\"},{\"config_setting\":\"//_config:is_python_3.11\",\"filename\":\"charset_normalizer-3.0.1-cp311-cp311-musllinux_1_1_x86_64.whl\",\"repo\":\"rules_python_publish_deps_311_charset_normalizer_cp311_cp311_musllinux_1_1_x86_64_761e8904\",\"target_platforms\":null,\"version\":\"3.11\"},{\"config_setting\":\"//_config:is_python_3.11\",\"filename\":\"charset_normalizer-3.0.1-py3-none-any.whl\",\"repo\":\"rules_python_publish_deps_311_charset_normalizer_py3_none_any_7e189e2e\",\"target_platforms\":[\"cp311_linux_aarch64\",\"cp311_linux_arm\",\"cp311_linux_ppc\",\"cp311_linux_s390x\",\"cp311_linux_x86_64\"],\"version\":\"3.11\"},{\"config_setting\":\"//_config:is_python_3.11\",\"filename\":\"charset_normalizer-3.3.2-cp311-cp311-macosx_10_9_universal2.whl\",\"repo\":\"rules_python_publish_deps_311_charset_normalizer_cp311_cp311_macosx_10_9_universal2_802fe99c\",\"target_platforms\":null,\"version\":\"3.11\"},{\"config_setting\":\"//_config:is_python_3.11\",\"filename\":\"charset_normalizer-3.3.2-cp311-cp311-macosx_10_9_x86_64.whl\",\"repo\":\"rules_python_publish_deps_311_charset_normalizer_cp311_cp311_macosx_10_9_x86_64_573f6eac\",\"target_platforms\":null,\"version\":\"3.11\"},{\"config_setting\":\"//_config:is_python_3.11\",\"filename\":\"charset_normalizer-3.3.2-cp311-cp311-macosx_11_0_arm64.whl\",\"repo\":\"rules_python_publish_deps_311_charset_normalizer_cp311_cp311_macosx_11_0_arm64_549a3a73\",\"target_platforms\":null,\"version\":\"3.11\"},{\"config_setting\":\"//_config:is_python_3.11\",\"filename\":\"charset_normalizer-3.3.2-cp311-cp311-win_amd64.whl\",\"repo\":\"rules_python_publish_deps_311_charset_normalizer_cp311_cp311_win_amd64_66394663\",\"target_platforms\":null,\"version\":\"3.11\"},{\"config_setting\":\"//_config:is_python_3.11\",\"filename\":\"charset_normalizer-3.3.2-py3-none-any.whl\",\"repo\":\"rules_python_publish_deps_311_charset_normalizer_py3_none_any_3e4d1f65\",\"target_platforms\":[\"cp311_osx_aarch64\",\"cp311_osx_x86_64\",\"cp311_windows_x86_64\"],\"version\":\"3.11\"}]",
+ "charset_normalizer": "[{\"config_setting\":\"//_config:is_python_3.11\",\"filename\":\"charset-normalizer-3.0.1.tar.gz\",\"repo\":\"rules_python_publish_deps_311_charset_normalizer_sdist_ebea339a\",\"target_platforms\":[\"cp311_linux_aarch64\",\"cp311_linux_arm\",\"cp311_linux_ppc\",\"cp311_linux_s390x\",\"cp311_linux_x86_64\"],\"version\":\"3.11\"},{\"config_setting\":\"//_config:is_python_3.11\",\"filename\":\"charset_normalizer-3.0.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl\",\"repo\":\"rules_python_publish_deps_311_charset_normalizer_cp311_cp311_manylinux_2_17_aarch64_14e76c0f\",\"target_platforms\":null,\"version\":\"3.11\"},{\"config_setting\":\"//_config:is_python_3.11\",\"filename\":\"charset_normalizer-3.0.1-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl\",\"repo\":\"rules_python_publish_deps_311_charset_normalizer_cp311_cp311_manylinux_2_17_ppc64le_0c0a5902\",\"target_platforms\":null,\"version\":\"3.11\"},{\"config_setting\":\"//_config:is_python_3.11\",\"filename\":\"charset_normalizer-3.0.1-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl\",\"repo\":\"rules_python_publish_deps_311_charset_normalizer_cp311_cp311_manylinux_2_17_s390x_8c7fe7af\",\"target_platforms\":null,\"version\":\"3.11\"},{\"config_setting\":\"//_config:is_python_3.11\",\"filename\":\"charset_normalizer-3.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl\",\"repo\":\"rules_python_publish_deps_311_charset_normalizer_cp311_cp311_manylinux_2_17_x86_64_79909e27\",\"target_platforms\":null,\"version\":\"3.11\"},{\"config_setting\":\"//_config:is_python_3.11\",\"filename\":\"charset_normalizer-3.0.1-cp311-cp311-musllinux_1_1_aarch64.whl\",\"repo\":\"rules_python_publish_deps_311_charset_normalizer_cp311_cp311_musllinux_1_1_aarch64_72966d1b\",\"target_platforms\":null,\"version\":\"3.11\"},{\"config_setting\":\"//_config:is_python_3.11\",\"filename\":\"charset_normalizer-3.0.1-cp311-cp311-musllinux_1_1_ppc64le.whl\",\"repo\":\"rules_python_publish_deps_311_charset_normalizer_cp311_cp311_musllinux_1_1_ppc64le_5995f016\",\"target_platforms\":null,\"version\":\"3.11\"},{\"config_setting\":\"//_config:is_python_3.11\",\"filename\":\"charset_normalizer-3.0.1-cp311-cp311-musllinux_1_1_s390x.whl\",\"repo\":\"rules_python_publish_deps_311_charset_normalizer_cp311_cp311_musllinux_1_1_s390x_4a8fcf28\",\"target_platforms\":null,\"version\":\"3.11\"},{\"config_setting\":\"//_config:is_python_3.11\",\"filename\":\"charset_normalizer-3.0.1-cp311-cp311-musllinux_1_1_x86_64.whl\",\"repo\":\"rules_python_publish_deps_311_charset_normalizer_cp311_cp311_musllinux_1_1_x86_64_761e8904\",\"target_platforms\":null,\"version\":\"3.11\"},{\"config_setting\":\"//_config:is_python_3.11\",\"filename\":\"charset_normalizer-3.0.1-py3-none-any.whl\",\"repo\":\"rules_python_publish_deps_311_charset_normalizer_py3_none_any_7e189e2e\",\"target_platforms\":[\"cp311_linux_aarch64\",\"cp311_linux_arm\",\"cp311_linux_ppc\",\"cp311_linux_s390x\",\"cp311_linux_x86_64\"],\"version\":\"3.11\"},{\"config_setting\":\"//_config:is_python_3.11\",\"filename\":\"charset_normalizer-3.4.0-cp311-cp311-macosx_10_9_universal2.whl\",\"repo\":\"rules_python_publish_deps_311_charset_normalizer_cp311_cp311_macosx_10_9_universal2_0d99dd8f\",\"target_platforms\":null,\"version\":\"3.11\"},{\"config_setting\":\"//_config:is_python_3.11\",\"filename\":\"charset_normalizer-3.4.0-cp311-cp311-macosx_10_9_x86_64.whl\",\"repo\":\"rules_python_publish_deps_311_charset_normalizer_cp311_cp311_macosx_10_9_x86_64_c57516e5\",\"target_platforms\":null,\"version\":\"3.11\"},{\"config_setting\":\"//_config:is_python_3.11\",\"filename\":\"charset_normalizer-3.4.0-cp311-cp311-macosx_11_0_arm64.whl\",\"repo\":\"rules_python_publish_deps_311_charset_normalizer_cp311_cp311_macosx_11_0_arm64_6dba5d19\",\"target_platforms\":null,\"version\":\"3.11\"},{\"config_setting\":\"//_config:is_python_3.11\",\"filename\":\"charset_normalizer-3.4.0-cp311-cp311-win_amd64.whl\",\"repo\":\"rules_python_publish_deps_311_charset_normalizer_cp311_cp311_win_amd64_cee4373f\",\"target_platforms\":null,\"version\":\"3.11\"},{\"config_setting\":\"//_config:is_python_3.11\",\"filename\":\"charset_normalizer-3.4.0-py3-none-any.whl\",\"repo\":\"rules_python_publish_deps_311_charset_normalizer_py3_none_any_fe9f97fe\",\"target_platforms\":[\"cp311_osx_aarch64\",\"cp311_osx_x86_64\",\"cp311_windows_x86_64\"],\"version\":\"3.11\"},{\"config_setting\":\"//_config:is_python_3.11\",\"filename\":\"charset_normalizer-3.4.0.tar.gz\",\"repo\":\"rules_python_publish_deps_311_charset_normalizer_sdist_223217c3\",\"target_platforms\":[\"cp311_osx_aarch64\",\"cp311_osx_x86_64\",\"cp311_windows_x86_64\"],\"version\":\"3.11\"}]",
"cryptography": "[{\"config_setting\":\"//_config:is_python_3.11\",\"filename\":\"cryptography-42.0.4-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl\",\"repo\":\"rules_python_publish_deps_311_cryptography_cp39_abi3_manylinux_2_17_aarch64_a1327f28\",\"target_platforms\":null,\"version\":\"3.11\"},{\"config_setting\":\"//_config:is_python_3.11\",\"filename\":\"cryptography-42.0.4-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl\",\"repo\":\"rules_python_publish_deps_311_cryptography_cp39_abi3_manylinux_2_17_x86_64_6ffb03d4\",\"target_platforms\":null,\"version\":\"3.11\"},{\"config_setting\":\"//_config:is_python_3.11\",\"filename\":\"cryptography-42.0.4-cp39-abi3-manylinux_2_28_aarch64.whl\",\"repo\":\"rules_python_publish_deps_311_cryptography_cp39_abi3_manylinux_2_28_aarch64_1df6fcbf\",\"target_platforms\":null,\"version\":\"3.11\"},{\"config_setting\":\"//_config:is_python_3.11\",\"filename\":\"cryptography-42.0.4-cp39-abi3-manylinux_2_28_x86_64.whl\",\"repo\":\"rules_python_publish_deps_311_cryptography_cp39_abi3_manylinux_2_28_x86_64_44a64043\",\"target_platforms\":null,\"version\":\"3.11\"},{\"config_setting\":\"//_config:is_python_3.11\",\"filename\":\"cryptography-42.0.4-cp39-abi3-musllinux_1_1_aarch64.whl\",\"repo\":\"rules_python_publish_deps_311_cryptography_cp39_abi3_musllinux_1_1_aarch64_3c6048f2\",\"target_platforms\":null,\"version\":\"3.11\"},{\"config_setting\":\"//_config:is_python_3.11\",\"filename\":\"cryptography-42.0.4-cp39-abi3-musllinux_1_1_x86_64.whl\",\"repo\":\"rules_python_publish_deps_311_cryptography_cp39_abi3_musllinux_1_1_x86_64_6d0fbe73\",\"target_platforms\":null,\"version\":\"3.11\"},{\"config_setting\":\"//_config:is_python_3.11\",\"filename\":\"cryptography-42.0.4-cp39-abi3-musllinux_1_2_aarch64.whl\",\"repo\":\"rules_python_publish_deps_311_cryptography_cp39_abi3_musllinux_1_2_aarch64_887623fe\",\"target_platforms\":null,\"version\":\"3.11\"},{\"config_setting\":\"//_config:is_python_3.11\",\"filename\":\"cryptography-42.0.4-cp39-abi3-musllinux_1_2_x86_64.whl\",\"repo\":\"rules_python_publish_deps_311_cryptography_cp39_abi3_musllinux_1_2_x86_64_ce8613be\",\"target_platforms\":null,\"version\":\"3.11\"},{\"config_setting\":\"//_config:is_python_3.11\",\"filename\":\"cryptography-42.0.4.tar.gz\",\"repo\":\"rules_python_publish_deps_311_cryptography_sdist_831a4b37\",\"target_platforms\":null,\"version\":\"3.11\"}]",
"docutils": "[{\"config_setting\":\"//_config:is_python_3.11\",\"filename\":\"docutils-0.19-py3-none-any.whl\",\"repo\":\"rules_python_publish_deps_311_docutils_py3_none_any_5e1de4d8\",\"target_platforms\":[\"cp311_linux_aarch64\",\"cp311_linux_arm\",\"cp311_linux_ppc\",\"cp311_linux_s390x\",\"cp311_linux_x86_64\"],\"version\":\"3.11\"},{\"config_setting\":\"//_config:is_python_3.11\",\"filename\":\"docutils-0.19.tar.gz\",\"repo\":\"rules_python_publish_deps_311_docutils_sdist_33995a67\",\"target_platforms\":[\"cp311_linux_aarch64\",\"cp311_linux_arm\",\"cp311_linux_ppc\",\"cp311_linux_s390x\",\"cp311_linux_x86_64\"],\"version\":\"3.11\"},{\"config_setting\":\"//_config:is_python_3.11\",\"filename\":\"docutils-0.21.2-py3-none-any.whl\",\"repo\":\"rules_python_publish_deps_311_docutils_py3_none_any_dafca5b9\",\"target_platforms\":[\"cp311_osx_aarch64\",\"cp311_osx_x86_64\",\"cp311_windows_x86_64\"],\"version\":\"3.11\"},{\"config_setting\":\"//_config:is_python_3.11\",\"filename\":\"docutils-0.21.2.tar.gz\",\"repo\":\"rules_python_publish_deps_311_docutils_sdist_3a6b1873\",\"target_platforms\":[\"cp311_osx_aarch64\",\"cp311_osx_x86_64\",\"cp311_windows_x86_64\"],\"version\":\"3.11\"}]",
"idna": "[{\"config_setting\":\"//_config:is_python_3.11\",\"filename\":\"idna-3.10-py3-none-any.whl\",\"repo\":\"rules_python_publish_deps_311_idna_py3_none_any_946d195a\",\"target_platforms\":[\"cp311_osx_aarch64\",\"cp311_osx_x86_64\",\"cp311_windows_x86_64\"],\"version\":\"3.11\"},{\"config_setting\":\"//_config:is_python_3.11\",\"filename\":\"idna-3.10.tar.gz\",\"repo\":\"rules_python_publish_deps_311_idna_sdist_12f65c9b\",\"target_platforms\":[\"cp311_osx_aarch64\",\"cp311_osx_x86_64\",\"cp311_windows_x86_64\"],\"version\":\"3.11\"},{\"config_setting\":\"//_config:is_python_3.11\",\"filename\":\"idna-3.4-py3-none-any.whl\",\"repo\":\"rules_python_publish_deps_311_idna_py3_none_any_90b77e79\",\"target_platforms\":[\"cp311_linux_aarch64\",\"cp311_linux_arm\",\"cp311_linux_ppc\",\"cp311_linux_s390x\",\"cp311_linux_x86_64\"],\"version\":\"3.11\"},{\"config_setting\":\"//_config:is_python_3.11\",\"filename\":\"idna-3.4.tar.gz\",\"repo\":\"rules_python_publish_deps_311_idna_sdist_814f528e\",\"target_platforms\":[\"cp311_linux_aarch64\",\"cp311_linux_arm\",\"cp311_linux_ppc\",\"cp311_linux_s390x\",\"cp311_linux_x86_64\"],\"version\":\"3.11\"}]",
@@ -8326,6 +8326,26 @@
"groups": {}
}
},
+ "rules_python_publish_deps_311_charset_normalizer_cp311_cp311_macosx_10_9_universal2_0d99dd8f": {
+ "bzlFile": "@@rules_python~//python/private/pypi:whl_library.bzl",
+ "ruleClassName": "whl_library",
+ "attributes": {
+ "dep_template": "@rules_python_publish_deps//{name}:{target}",
+ "experimental_target_platforms": [
+ "cp311_osx_aarch64",
+ "cp311_osx_x86_64",
+ "cp311_windows_x86_64"
+ ],
+ "filename": "charset_normalizer-3.4.0-cp311-cp311-macosx_10_9_universal2.whl",
+ "python_interpreter_target": "@@rules_python~~python~python_3_11_host//:python",
+ "repo": "rules_python_publish_deps_311",
+ "requirement": "charset-normalizer==3.4.0",
+ "sha256": "0d99dd8ff461990f12d6e42c7347fd9ab2532fb70e9621ba520f9e8637161d7c",
+ "urls": [
+ "https://files.pythonhosted.org/packages/9c/61/73589dcc7a719582bf56aae309b6103d2762b526bffe189d635a7fcfd998/charset_normalizer-3.4.0-cp311-cp311-macosx_10_9_universal2.whl"
+ ]
+ }
+ },
"rules_python_publish_deps_311_charset_normalizer_sdist_ebea339a": {
"bzlFile": "@@rules_python~//python/private/pypi:whl_library.bzl",
"ruleClassName": "whl_library",
@@ -8373,26 +8393,6 @@
]
}
},
- "rules_python_publish_deps_311_charset_normalizer_cp311_cp311_macosx_10_9_x86_64_573f6eac": {
- "bzlFile": "@@rules_python~//python/private/pypi:whl_library.bzl",
- "ruleClassName": "whl_library",
- "attributes": {
- "dep_template": "@rules_python_publish_deps//{name}:{target}",
- "experimental_target_platforms": [
- "cp311_osx_aarch64",
- "cp311_osx_x86_64",
- "cp311_windows_x86_64"
- ],
- "filename": "charset_normalizer-3.3.2-cp311-cp311-macosx_10_9_x86_64.whl",
- "python_interpreter_target": "@@rules_python~~python~python_3_11_host//:python",
- "repo": "rules_python_publish_deps_311",
- "requirement": "charset-normalizer==3.3.2",
- "sha256": "573f6eac48f4769d667c4442081b1794f52919e7edada77495aaed9236d13a96",
- "urls": [
- "https://files.pythonhosted.org/packages/3e/33/21a875a61057165e92227466e54ee076b73af1e21fe1b31f1e292251aa1e/charset_normalizer-3.3.2-cp311-cp311-macosx_10_9_x86_64.whl"
- ]
- }
- },
"rules_python_publish_deps_311_charset_normalizer_cp311_cp311_musllinux_1_1_aarch64_72966d1b": {
"bzlFile": "@@rules_python~//python/private/pypi:whl_library.bzl",
"ruleClassName": "whl_library",
diff --git a/examples/bzlmod_build_file_generation/.bazelrc b/examples/bzlmod_build_file_generation/.bazelrc
index acc7102..0289886 100644
--- a/examples/bzlmod_build_file_generation/.bazelrc
+++ b/examples/bzlmod_build_file_generation/.bazelrc
@@ -6,3 +6,4 @@
common --experimental_enable_bzlmod
coverage --java_runtime_version=remotejdk_11
+common:bazel7.x --incompatible_python_disallow_native_rules
diff --git a/examples/multi_python_versions/.bazelrc b/examples/multi_python_versions/.bazelrc
index 58080ab..97a973b 100644
--- a/examples/multi_python_versions/.bazelrc
+++ b/examples/multi_python_versions/.bazelrc
@@ -4,3 +4,4 @@
build --enable_runfiles
coverage --java_runtime_version=remotejdk_11
+common:bazel7.x --incompatible_python_disallow_native_rules
diff --git a/examples/pip_parse/.bazelrc b/examples/pip_parse/.bazelrc
index 9e7ef37..a569048 100644
--- a/examples/pip_parse/.bazelrc
+++ b/examples/pip_parse/.bazelrc
@@ -1,2 +1,3 @@
# https://docs.bazel.build/versions/main/best-practices.html#using-the-bazelrc-file
try-import %workspace%/user.bazelrc
+common:bazel7.x --incompatible_python_disallow_native_rules
diff --git a/examples/pip_parse_vendored/.bazelrc b/examples/pip_parse_vendored/.bazelrc
index 3818a03..be3555d 100644
--- a/examples/pip_parse_vendored/.bazelrc
+++ b/examples/pip_parse_vendored/.bazelrc
@@ -6,3 +6,4 @@
# Vendoring requirements.bzl files isn't necessary under bzlmod
# When workspace support is dropped, this example can be removed.
build --noexperimental_enable_bzlmod
+common:bazel7.x --incompatible_python_disallow_native_rules
diff --git a/examples/pip_repository_annotations/.bazelrc b/examples/pip_repository_annotations/.bazelrc
index 9ce0b72..4f62c6e 100644
--- a/examples/pip_repository_annotations/.bazelrc
+++ b/examples/pip_repository_annotations/.bazelrc
@@ -4,3 +4,4 @@
# This example is WORKSPACE specific. The equivalent functionality
# is in examples/bzlmod as the `whl_mods` feature.
build --experimental_enable_bzlmod=false
+common:bazel7.x --incompatible_python_disallow_native_rules
diff --git a/examples/py_proto_library/.bazelrc b/examples/py_proto_library/.bazelrc
index ef0e530..65d8a0a 100644
--- a/examples/py_proto_library/.bazelrc
+++ b/examples/py_proto_library/.bazelrc
@@ -1,2 +1,3 @@
# The equivalent bzlmod behavior is covered by examples/bzlmod/py_proto_library
common --noenable_bzlmod
+common:bazel7.x --incompatible_python_disallow_native_rules
diff --git a/gazelle/.bazelrc b/gazelle/.bazelrc
index e10cd78..9704090 100644
--- a/gazelle/.bazelrc
+++ b/gazelle/.bazelrc
@@ -11,10 +11,4 @@
# Windows makes use of runfiles for some rules
build --enable_runfiles
-# Do NOT implicitly create empty __init__.py files in the runfiles tree.
-# By default, these are created in every directory containing Python source code
-# or shared libraries, and every parent directory of those directories,
-# excluding the repo root directory. With this flag set, we are responsible for
-# creating (possibly empty) __init__.py files and adding them to the srcs of
-# Python targets as required.
-build --incompatible_default_to_explicit_init_py
+common:bazel7.x --incompatible_python_disallow_native_rules
diff --git a/python/private/common.bzl b/python/private/common.bzl
index 2dcc948..837cd19 100644
--- a/python/private/common.bzl
+++ b/python/private/common.bzl
@@ -17,24 +17,15 @@
load(":py_info.bzl", "PyInfo", "PyInfoBuilder")
load(":py_internal.bzl", "py_internal")
load(":reexports.bzl", "BuiltinPyInfo")
-load(
- ":semantics.bzl",
- "NATIVE_RULES_MIGRATION_FIX_CMD",
- "NATIVE_RULES_MIGRATION_HELP_URL",
-)
_testing = testing
_platform_common = platform_common
_coverage_common = coverage_common
-_py_builtins = py_internal
PackageSpecificationInfo = getattr(py_internal, "PackageSpecificationInfo", None)
# Extensions without the dot
_PYTHON_SOURCE_EXTENSIONS = ["py"]
-# NOTE: Must stay in sync with the value used in rules_python
-_MIGRATION_TAG = "__PYTHON_RULES_MIGRATION_DO_NOT_USE_WILL_BREAK__"
-
def create_binary_semantics_struct(
*,
create_executable,
@@ -477,65 +468,3 @@
if ctx.target_platform_has_constraint(constraint_value):
return True
return False
-
-def check_native_allowed(ctx):
- """Check if the usage of the native rule is allowed.
-
- Args:
- ctx: rule context to check
- """
- if not ctx.fragments.py.disallow_native_rules:
- return
-
- if _MIGRATION_TAG in ctx.attr.tags:
- return
-
- # NOTE: The main repo name is empty in *labels*, but not in
- # ctx.workspace_name
- is_main_repo = not bool(ctx.label.workspace_name)
- if is_main_repo:
- check_label = ctx.label
- else:
- # package_group doesn't allow @repo syntax, so we work around that
- # by prefixing external repos with a fake package path. This also
- # makes it easy to enable or disable all external repos.
- check_label = Label("@//__EXTERNAL_REPOS__/{workspace}/{package}".format(
- workspace = ctx.label.workspace_name,
- package = ctx.label.package,
- ))
- allowlist = ctx.attr._native_rules_allowlist
- if allowlist:
- allowed = ctx.attr._native_rules_allowlist[PackageSpecificationInfo].contains(check_label)
- allowlist_help = str(allowlist.label).replace("@//", "//")
- else:
- allowed = False
- allowlist_help = ("no allowlist specified; all disallowed; specify one " +
- "with --python_native_rules_allowlist")
- if not allowed:
- if ctx.attr.generator_function:
- generator = "{generator_function}(name={generator_name}) in {generator_location}".format(
- generator_function = ctx.attr.generator_function,
- generator_name = ctx.attr.generator_name,
- generator_location = ctx.attr.generator_location,
- )
- else:
- generator = "No generator (called directly in BUILD file)"
-
- msg = (
- "{target} not allowed to use native.{rule}\n" +
- "Generated by: {generator}\n" +
- "Allowlist: {allowlist}\n" +
- "Migrate to using @rules_python, see {help_url}\n" +
- "FIXCMD: {fix_cmd} --target={target} --rule={rule} " +
- "--generator_name={generator_name} --location={generator_location}"
- )
- fail(msg.format(
- target = str(ctx.label).replace("@//", "//"),
- rule = _py_builtins.get_rule_name(ctx),
- generator = generator,
- allowlist = allowlist_help,
- generator_name = ctx.attr.generator_name,
- generator_location = ctx.attr.generator_location,
- help_url = NATIVE_RULES_MIGRATION_HELP_URL,
- fix_cmd = NATIVE_RULES_MIGRATION_FIX_CMD,
- ))
diff --git a/python/private/py_executable.bzl b/python/private/py_executable.bzl
index ce1288c..b81f07e 100644
--- a/python/private/py_executable.bzl
+++ b/python/private/py_executable.bzl
@@ -33,7 +33,6 @@
load(":cc_helper.bzl", "cc_helper")
load(
":common.bzl",
- "check_native_allowed",
"collect_imports",
"collect_runfiles",
"create_instrumented_files_info",
@@ -269,7 +268,6 @@
def _validate_executable(ctx):
if ctx.attr.python_version != "PY3":
fail("It is not allowed to use Python 2")
- check_native_allowed(ctx)
def _declare_executable_file(ctx):
if target_platform_has_any_constraint(ctx, ctx.attr._windows_constraints):
diff --git a/python/private/py_library.bzl b/python/private/py_library.bzl
index 4f43116..1bc96b5 100644
--- a/python/private/py_library.bzl
+++ b/python/private/py_library.bzl
@@ -28,7 +28,6 @@
load(":builders.bzl", "builders")
load(
":common.bzl",
- "check_native_allowed",
"collect_imports",
"collect_runfiles",
"create_instrumented_files_info",
@@ -70,7 +69,6 @@
Returns:
A list of modern providers to propagate.
"""
- check_native_allowed(ctx)
direct_sources = filter_to_py_srcs(ctx.files.srcs)
precompile_result = semantics.maybe_precompile(ctx, direct_sources)
diff --git a/tests/integration/compile_pip_requirements/.bazelrc b/tests/integration/compile_pip_requirements/.bazelrc
index 8a42e64..b85f03b 100644
--- a/tests/integration/compile_pip_requirements/.bazelrc
+++ b/tests/integration/compile_pip_requirements/.bazelrc
@@ -2,3 +2,4 @@
# Windows requires these for multi-python support:
build --enable_runfiles
+common:bazel7.x --incompatible_python_disallow_native_rules
diff --git a/tests/integration/compile_pip_requirements_test_from_external_repo/.bazelrc b/tests/integration/compile_pip_requirements_test_from_external_repo/.bazelrc
index b98fc09..ab10c8c 100644
--- a/tests/integration/compile_pip_requirements_test_from_external_repo/.bazelrc
+++ b/tests/integration/compile_pip_requirements_test_from_external_repo/.bazelrc
@@ -1 +1,2 @@
test --test_output=errors
+common:bazel7.x --incompatible_python_disallow_native_rules
diff --git a/tests/integration/ignore_root_user_error/.bazelrc b/tests/integration/ignore_root_user_error/.bazelrc
index 27d7d13..bb7b574 100644
--- a/tests/integration/ignore_root_user_error/.bazelrc
+++ b/tests/integration/ignore_root_user_error/.bazelrc
@@ -4,3 +4,4 @@
# Windows requires these for multi-python support:
build --enable_runfiles
+common:bazel7.x --incompatible_python_disallow_native_rules
diff --git a/tests/integration/local_toolchains/.bazelrc b/tests/integration/local_toolchains/.bazelrc
index 551df40..39df41d 100644
--- a/tests/integration/local_toolchains/.bazelrc
+++ b/tests/integration/local_toolchains/.bazelrc
@@ -3,3 +3,4 @@
test --test_output=errors
# Windows requires these for multi-python support:
build --enable_runfiles
+common:bazel7.x --incompatible_python_disallow_native_rules
diff --git a/tests/integration/pip_parse/.bazelrc b/tests/integration/pip_parse/.bazelrc
index efeccbe..a749092 100644
--- a/tests/integration/pip_parse/.bazelrc
+++ b/tests/integration/pip_parse/.bazelrc
@@ -5,3 +5,4 @@
# https://docs.bazel.build/versions/main/best-practices.html#using-the-bazelrc-file
try-import %workspace%/user.bazelrc
+common:bazel7.x --incompatible_python_disallow_native_rules
diff --git a/tests/integration/py_cc_toolchain_registered/.bazelrc b/tests/integration/py_cc_toolchain_registered/.bazelrc
index 741d758..fb31561 100644
--- a/tests/integration/py_cc_toolchain_registered/.bazelrc
+++ b/tests/integration/py_cc_toolchain_registered/.bazelrc
@@ -1,2 +1,3 @@
# This aids debugging on failure
build --toolchain_resolution_debug=python
+common:bazel7.x --incompatible_python_disallow_native_rules