From 13ae13c3ff13e59d2677b3075110b10dd8f98960 Mon Sep 17 00:00:00 2001 From: Protobuf Team Bot Date: Mon, 13 May 2024 03:08:17 -0700 Subject: [PATCH] Replace system python with hermetic python from rules_python Closes #15850 PiperOrigin-RevId: 633147621 --- .readthedocs.yml | 2 +- MODULE.bazel | 24 +- WORKSPACE | 38 ++- protobuf_deps.bzl | 43 +-- python/BUILD.bazel | 2 - python/build_targets.bzl | 9 +- python/dist/BUILD.bazel | 8 +- python/dist/dist.bzl | 43 ++- python/dist/system_python.bzl | 275 ------------------ python/internal.bzl | 4 - python/pb_unit_tests/BUILD | 4 - python/pb_unit_tests/pyproto_test_wrapper.bzl | 4 - python/py_extension.bzl | 9 +- third_party/rules_fuzzing.patch | 38 +-- 14 files changed, 94 insertions(+), 409 deletions(-) delete mode 100644 python/dist/system_python.bzl diff --git a/.readthedocs.yml b/.readthedocs.yml index 88f4c100f36a..10e8fbdc6f79 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -16,7 +16,7 @@ conda: environment: python/docs/environment.yml python: - version: 3.7 + version: 3.8 install: - method: setuptools path: python diff --git a/MODULE.bazel b/MODULE.bazel index a389538d3c3d..14e6b67000a0 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -20,9 +20,29 @@ bazel_dep(name = "rules_cc", version = "0.0.9") bazel_dep(name = "rules_java", version = "5.3.5") bazel_dep(name = "rules_jvm_external", version = "5.1") bazel_dep(name = "rules_pkg", version = "0.7.0") -bazel_dep(name = "rules_python", version = "0.10.2") +bazel_dep(name = "rules_python", version = "0.28.0") bazel_dep(name = "platforms", version = "0.0.8") bazel_dep(name = "zlib", version = "1.2.11") # TODO: remove after toolchain types are moved to protobuf -bazel_dep(name = "rules_proto", version = "4.0.0") \ No newline at end of file +bazel_dep(name = "rules_proto", version = "4.0.0") + +SUPPORTED_PYTHON_VERSIONS = [ + "3.8", + "3.9", + "3.10", + "3.11", + "3.12", +] + +python = use_extension("@rules_python//python/extensions:python.bzl", "python") + +[ + python.toolchain( + # Required to avoid an error when running as root in OSS-Fuzz. + ignore_root_user_error = True, + is_default = python_version == SUPPORTED_PYTHON_VERSIONS[-1], + python_version = python_version, + ) + for python_version in SUPPORTED_PYTHON_VERSIONS +] \ No newline at end of file diff --git a/WORKSPACE b/WORKSPACE index ef112bb54878..f5114c7f2c1a 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -25,6 +25,10 @@ load("@rules_python//python:repositories.bzl", "py_repositories") py_repositories() +load("@rules_python//python/pip_install:repositories.bzl", "pip_install_dependencies") + +pip_install_dependencies() + # Bazel platform rules. http_archive( name = "platforms", @@ -164,11 +168,31 @@ http_archive( patch_cmds = ["find google -type f -name BUILD.bazel -delete"], ) -load("@system_python//:pip.bzl", "pip_parse") +load("@rules_python//python:repositories.bzl", "python_register_multi_toolchains") + +SUPPORTED_PYTHON_VERSIONS = [ + "3.8", + "3.9", + "3.10", + "3.11", + "3.12", +] + +python_register_multi_toolchains( + name = "python", + default_version = SUPPORTED_PYTHON_VERSIONS[-1], + python_versions = SUPPORTED_PYTHON_VERSIONS, + ignore_root_user_error = True, +) + +load("@python_{}//:defs.bzl".format(SUPPORTED_PYTHON_VERSIONS[-1].replace(".", "_")), "interpreter") + +load("@rules_python//python:pip.bzl", "pip_parse") pip_parse( name = "pip_deps", - requirements = "//python:requirements.txt", + requirements_lock = "//python:requirements.txt", + python_interpreter_target = interpreter, ) load("@pip_deps//:requirements.bzl", "install_deps") @@ -177,9 +201,9 @@ install_deps() http_archive( name = "rules_fuzzing", - sha256 = "ff52ef4845ab00e95d29c02a9e32e9eff4e0a4c9c8a6bcf8407a2f19eb3f9190", - strip_prefix = "rules_fuzzing-0.4.1", - urls = ["https://github.com/bazelbuild/rules_fuzzing/releases/download/v0.4.1/rules_fuzzing-0.4.1.zip"], + sha256 = "77206c54b71f4dd5335123a6ff2a8ea688eca5378d34b4838114dff71652cf26", + strip_prefix = "rules_fuzzing-0.5.1", + urls = ["https://github.com/bazelbuild/rules_fuzzing/releases/download/v0.5.1/rules_fuzzing-0.5.1.zip"], patches = ["//third_party:rules_fuzzing.patch"], patch_args = ["-p1"], ) @@ -192,10 +216,6 @@ load("@rules_fuzzing//fuzzing:init.bzl", "rules_fuzzing_init") rules_fuzzing_init() -load("@fuzzing_py_deps//:requirements.bzl", fuzzing_py_deps_install_deps = "install_deps") - -fuzzing_py_deps_install_deps() - http_archive( name = "rules_rust", sha256 = "9ecd0f2144f0a24e6bc71ebcc50a1ee5128cedeceb32187004532c9710cb2334", diff --git a/protobuf_deps.bzl b/protobuf_deps.bzl index 9fee18a2a6ec..7a52e2bb1f60 100644 --- a/protobuf_deps.bzl +++ b/protobuf_deps.bzl @@ -2,7 +2,6 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("//python/dist:python_downloads.bzl", "python_nuget_package", "python_source_archive") -load("//python/dist:system_python.bzl", "system_python") PROTOBUF_MAVEN_ARTIFACTS = [ "com.google.caliper:caliper:1.0-beta-3", @@ -100,15 +99,9 @@ def protobuf_deps(): if not native.existing_rule("rules_python"): http_archive( name = "rules_python", - sha256 = "9d04041ac92a0985e344235f5d946f71ac543f1b1565f2cdbc9a2aaee8adf55b", - strip_prefix = "rules_python-0.26.0", - url = "https://github.com/bazelbuild/rules_python/releases/download/0.26.0/rules_python-0.26.0.tar.gz", - ) - - if not native.existing_rule("system_python"): - system_python( - name = "system_python", - minimum_python_version = "3.7", + sha256 = "d70cd72a7a4880f0000a6346253414825c19cdd40a28289bdf67b8e6480edff8", + strip_prefix = "rules_python-0.28.0", + url = "https://github.com/bazelbuild/rules_python/releases/download/0.28.0/rules_python-0.28.0.tar.gz", ) if not native.existing_rule("rules_jvm_external"): @@ -149,33 +142,3 @@ def protobuf_deps(): urls = ["https://github.com/bazelbuild/rules_kotlin/releases/download/v1.8.1/rules_kotlin_release.tgz"], sha256 = "a630cda9fdb4f56cf2dc20a4bf873765c41cf00e9379e8d59cd07b24730f4fde", ) - - # Python Downloads - python_source_archive( - name = "python-3.8.0", - sha256 = "f1069ad3cae8e7ec467aa98a6565a62a48ef196cb8f1455a245a08db5e1792df", - ) - python_nuget_package( - name = "nuget_python_i686_3.8.0", - sha256 = "87a6481f5eef30b42ac12c93f06f73bd0b8692f26313b76a6615d1641c4e7bca", - ) - python_nuget_package( - name = "nuget_python_x86-64_3.8.0", - sha256 = "96c61321ce90dd053c8a04f305a5f6cc6d91350b862db34440e4a4f069b708a0", - ) - python_nuget_package( - name = "nuget_python_i686_3.9.0", - sha256 = "229abecbe49dc08fe5709e0b31e70edfb3b88f23335ebfc2904c44f940fd59b6", - ) - python_nuget_package( - name = "nuget_python_x86-64_3.9.0", - sha256 = "6af58a733e7dfbfcdd50d55788134393d6ffe7ab8270effbf724bdb786558832", - ) - python_nuget_package( - name = "nuget_python_i686_3.10.0", - sha256 = "e115e102eb90ce160ab0ef7506b750a8d7ecc385bde0a496f02a54337a8bc333", - ) - python_nuget_package( - name = "nuget_python_x86-64_3.10.0", - sha256 = "4474c83c25625d93e772e926f95f4cd398a0abbb52793625fa30f39af3d2cc00", - ) diff --git a/python/BUILD.bazel b/python/BUILD.bazel index 3e34bbdbc48b..94e0fd102bb4 100644 --- a/python/BUILD.bazel +++ b/python/BUILD.bazel @@ -138,8 +138,6 @@ selects.config_setting_group( # begin:github_only _message_target_compatible_with = { "@platforms//os:windows": ["@platforms//:incompatible"], - "@system_python//:none": ["@platforms//:incompatible"], - "@system_python//:unsupported": ["@platforms//:incompatible"], "//conditions:default": [], } diff --git a/python/build_targets.bzl b/python/build_targets.bzl index 1014514a4b27..d59045d7c019 100644 --- a/python/build_targets.bzl +++ b/python/build_targets.bzl @@ -87,7 +87,7 @@ def build_targets(name): ], deps = select({ "//conditions:default": [], - ":use_fast_cpp_protos": ["@system_python//:python_headers"], + ":use_fast_cpp_protos": ["@rules_python//python/cc:current_py_cc_headers"], }), ) @@ -136,7 +136,7 @@ def build_targets(name): "@com_google_absl//absl/strings", ] + select({ "//conditions:default": [], - ":use_fast_cpp_protos": ["@system_python//:python_headers"], + ":use_fast_cpp_protos": ["@rules_python//python/cc:current_py_cc_headers"], }), ) @@ -426,7 +426,7 @@ def build_targets(name): hdrs = ["google/protobuf/proto_api.h"], visibility = ["//visibility:public"], deps = [ - "@system_python//:python_headers", + "@rules_python//python/cc:current_py_cc_headers", ], ) @@ -440,7 +440,6 @@ def build_targets(name): env = {"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": "python"}, failure_list = "//conformance:failure_list_python.txt", target_compatible_with = select({ - "@system_python//:none": ["@platforms//:incompatible"], ":use_fast_cpp_protos": ["@platforms//:incompatible"], "//conditions:default": [], }), @@ -455,7 +454,6 @@ def build_targets(name): env = {"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": "cpp"}, failure_list = "//conformance:failure_list_python.txt", target_compatible_with = select({ - "@system_python//:none": ["@platforms//:incompatible"], ":use_fast_cpp_protos": [], "//conditions:default": ["@platforms//:incompatible"], }), @@ -469,7 +467,6 @@ def build_targets(name): env = {"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": "upb"}, failure_list = "//conformance:failure_list_python_upb.txt", target_compatible_with = select({ - "@system_python//:none": ["@platforms//:incompatible"], ":use_fast_cpp_protos": ["@platforms//:incompatible"], "//conditions:default": [], }), diff --git a/python/dist/BUILD.bazel b/python/dist/BUILD.bazel index 265d9b8851a7..a1a6374a5ef9 100644 --- a/python/dist/BUILD.bazel +++ b/python/dist/BUILD.bazel @@ -11,7 +11,6 @@ load("@pip_deps//:requirements.bzl", "requirement") load("@rules_pkg//pkg:mappings.bzl", "pkg_files", "strip_prefix") load("@rules_pkg//pkg:tar.bzl", "pkg_tar") load("@rules_python//python:packaging.bzl", "py_wheel") -load("@system_python//:version.bzl", "SYSTEM_PYTHON_VERSION") load("//:protobuf_version.bzl", "PROTOBUF_PYTHON_VERSION") load(":dist.bzl", "py_dist", "py_dist_module") load(":py_proto_library.bzl", "py_proto_library") @@ -272,7 +271,6 @@ pkg_tar( package_file_name = "protobuf.tar.gz", strip_prefix = ".", target_compatible_with = select({ - "@system_python//:none": ["@platforms//:incompatible"], "//conditions:default": [], }), ) @@ -291,7 +289,6 @@ genrule( mv protobuf/dist/*.tar.gz $@ """, target_compatible_with = select({ - "@system_python//:none": ["@platforms//:incompatible"], "//conditions:default": [], }), tools = [requirement("setuptools")], @@ -338,7 +335,7 @@ py_wheel( ("//python:limited_api_3.8", "//python:full_api_3.8"): "cp38", "//python:full_api_3.9": "cp39", "//python:limited_api_3.10": "cp310", - "//conditions:default": "cp" + SYSTEM_PYTHON_VERSION, + "//conditions:default": "cp38", # TODO: Make more formal }), # LINT.ThenChange( # :full_api_version, @@ -350,7 +347,6 @@ py_wheel( "src/", ], target_compatible_with = select({ - "@system_python//:none": ["@platforms//:incompatible"], "//conditions:default": [], }), version = PROTOBUF_PYTHON_VERSION, @@ -390,7 +386,6 @@ py_wheel( "src/", ], target_compatible_with = select({ - "@system_python//:none": ["@platforms//:incompatible"], "//conditions:default": [], }), version = PROTOBUF_PYTHON_VERSION, @@ -416,7 +411,6 @@ py_wheel( "src/", ], target_compatible_with = select({ - "@system_python//:none": ["@platforms//:incompatible"], "//conditions:default": [], }), version = PROTOBUF_PYTHON_VERSION, diff --git a/python/dist/dist.bzl b/python/dist/dist.bzl index 061125ede637..e088e67a55b1 100644 --- a/python/dist/dist.bzl +++ b/python/dist/dist.bzl @@ -1,7 +1,6 @@ """Rules to create python distribution files and properly name them""" load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo") -load("@system_python//:version.bzl", "SYSTEM_PYTHON_VERSION") def _get_suffix(limited_api, python_version, cpu): """Computes an ABI version tag for an extension module per PEP 3149.""" @@ -15,30 +14,29 @@ def _get_suffix(limited_api, python_version, cpu): else: fail("Unsupported CPU: " + cpu) return ".cp{}-{}.{}".format(python_version, abi, "pyd") - - if python_version == "system": - python_version = SYSTEM_PYTHON_VERSION - if int(python_version) < 38: - python_version += "m" - abis = { - "darwin_arm64": "darwin", - "darwin_x86_64": "darwin", - "darwin": "darwin", - "osx-x86_64": "darwin", - "osx-aarch_64": "darwin", - "linux-aarch_64": "aarch64-linux-gnu", - "linux-x86_64": "x86_64-linux-gnu", - "k8": "x86_64-linux-gnu", - } - - return ".cpython-{}-{}.{}".format( - python_version, - abis[cpu], - "so" if limited_api else "abi3.so", - ) elif limited_api: return ".abi3.so" + python_version = runtime.interpreter_version_info + if int(python_version) < 38: + python_version += "m" + abis = { + "darwin_arm64": "darwin", + "darwin_x86_64": "darwin", + "darwin": "darwin", + "osx-x86_64": "darwin", + "osx-aarch_64": "darwin", + "linux-aarch_64": "aarch64-linux-gnu", + "linux-x86_64": "x86_64-linux-gnu", + "k8": "x86_64-linux-gnu", + } + + return ".cpython-{}-{}.{}".format( + python_version, + abis[cpu], + "so" if limited_api else "abi3.so", + ) + fail("Unsupported combination of flags") def _declare_module_file(ctx, module_name, python_version, limited_api): @@ -114,6 +112,7 @@ def _py_dist_module_impl(ctx): py_dist_module = rule( implementation = _py_dist_module_impl, + toolchains = ["@rules_python//python:toolchain_type"], attrs = { "module_name": attr.string(mandatory = True), "extension": attr.label( diff --git a/python/dist/system_python.bzl b/python/dist/system_python.bzl deleted file mode 100644 index 29400be223ac..000000000000 --- a/python/dist/system_python.bzl +++ /dev/null @@ -1,275 +0,0 @@ -# Copyright (c) 2009-2021, Google LLC -# All rights reserved. -# -# Use of this source code is governed by a BSD-style -# license that can be found in the LICENSE file or at -# https://developers.google.com/open-source/licenses/bsd - -"""Repository rule for using Python 3.x headers from the system.""" - -# Mock out rules_python's pip.bzl for cases where no system python is found. -_mock_pip = """ -def _pip_install_impl(repository_ctx): - repository_ctx.file("BUILD.bazel", ''' -py_library( - name = "noop", - visibility = ["//visibility:public"], -) -''') - repository_ctx.file("requirements.bzl", ''' -def install_deps(*args, **kwargs): - print("WARNING: could not install pip dependencies") - -def requirement(*args, **kwargs): - return "@{}//:noop" -'''.format(repository_ctx.attr.name)) -pip_install = repository_rule( - implementation = _pip_install_impl, - attrs = { - "requirements": attr.string(), - "requirements_overrides": attr.string_dict(), - "python_interpreter_target": attr.string(), - }, -) -pip_parse = pip_install -""" - -# Alias rules_python's pip.bzl for cases where a system python is found. -_alias_pip = """ -load("@rules_python//python:pip.bzl", _pip_install = "pip_install", _pip_parse = "pip_parse") - -def _get_requirements(requirements, requirements_overrides): - for version, override in requirements_overrides.items(): - if version in "{python_version}": - requirements = override - break - return requirements - -def pip_install(requirements, requirements_overrides={{}}, **kwargs): - _pip_install( - python_interpreter_target = "@{repo}//:interpreter", - requirements = _get_requirements(requirements, requirements_overrides), - **kwargs, - ) -def pip_parse(requirements, requirements_overrides={{}}, **kwargs): - _pip_parse( - python_interpreter_target = "@{repo}//:interpreter", - requirements = _get_requirements(requirements, requirements_overrides), - **kwargs, - ) -""" - -_mock_fuzzing_py = """ -def fuzzing_py_install_deps(): - print("WARNING: could not install fuzzing_py dependencies") -""" - -# Alias rules_fuzzing's requirements.bzl for cases where a system python is found. -_alias_fuzzing_py = """ -load("@fuzzing_py_deps//:requirements.bzl", _fuzzing_py_install_deps = "install_deps") - -def fuzzing_py_install_deps(): - _fuzzing_py_install_deps() -""" - -_build_file = """ -load("@bazel_skylib//lib:selects.bzl", "selects") -load("@bazel_skylib//rules:common_settings.bzl", "string_flag") -load("@bazel_tools//tools/python:toolchain.bzl", "py_runtime_pair") - -cc_library( - name = "python_headers", - hdrs = glob(["python/**/*.h"], allow_empty = True), - includes = ["python"], - visibility = ["//visibility:public"], -) - -string_flag( - name = "internal_python_support", - build_setting_default = "{support}", - values = [ - "None", - "Supported", - "Unsupported", - ] -) - -config_setting( - name = "none", - flag_values = {{ - ":internal_python_support": "None", - }}, - visibility = ["//visibility:public"], -) - -config_setting( - name = "supported", - flag_values = {{ - ":internal_python_support": "Supported", - }}, - visibility = ["//visibility:public"], -) - -config_setting( - name = "unsupported", - flag_values = {{ - ":internal_python_support": "Unsupported", - }}, - visibility = ["//visibility:public"], -) - -selects.config_setting_group( - name = "exists", - match_any = [":supported", ":unsupported"], - visibility = ["//visibility:public"], -) - -sh_binary( - name = "interpreter", - srcs = ["interpreter"], - visibility = ["//visibility:public"], -) - -py_runtime( - name = "py3_runtime", - interpreter_path = "{interpreter}", - python_version = "PY3", -) - -py_runtime_pair( - name = "runtime_pair", - py3_runtime = ":py3_runtime", -) - -toolchain( - name = "python_toolchain", - toolchain = ":runtime_pair", - toolchain_type = "@rules_python//python:toolchain_type", -) -""" - -_register = """ -def register_system_python(): - native.register_toolchains("@{}//:python_toolchain") -""" - -_mock_register = """ -def register_system_python(): - pass -""" - -def _get_python_version(repository_ctx): - py_program = "import sys; print(str(sys.version_info.major) + '.' + str(sys.version_info.minor) + '.' + str(sys.version_info.micro))" - result = repository_ctx.execute(["python3", "-c", py_program]) - return (result.stdout).strip().split(".") - -def _get_python_path(repository_ctx): - py_program = "import sysconfig; print(sysconfig.get_config_var('%s'), end='')" - result = repository_ctx.execute(["python3", "-c", py_program % ("INCLUDEPY")]) - if result.return_code != 0: - return None - return result.stdout - -def _populate_package(ctx, path, python3, python_version): - ctx.symlink(path, "python") - supported = True - for idx, v in enumerate(ctx.attr.minimum_python_version.split(".")): - if int(python_version[idx]) < int(v): - supported = False - break - if "win" in ctx.os.name: - # buildifier: disable=print - print("WARNING: python is not supported on Windows") - supported = False - - build_file = _build_file.format( - interpreter = python3, - support = "Supported" if supported else "Unsupported", - ) - - ctx.file("interpreter", "#!/bin/sh\nexec {} \"$@\"".format(python3)) - ctx.file("BUILD.bazel", build_file) - ctx.file("version.bzl", "SYSTEM_PYTHON_VERSION = '{}{}'".format(python_version[0], python_version[1])) - ctx.file("register.bzl", _register.format(ctx.attr.name)) - if supported: - ctx.file("pip.bzl", _alias_pip.format( - python_version = ".".join(python_version), - repo = ctx.attr.name, - )) - ctx.file("fuzzing_py.bzl", _alias_fuzzing_py) - else: - # Dependencies are unlikely to be satisfiable for unsupported versions of python. - ctx.file("pip.bzl", _mock_pip) - ctx.file("fuzzing_py.bzl", _mock_fuzzing_py) - -def _populate_empty_package(ctx): - # Mock out all the entrypoints we need to run from WORKSPACE. Targets that - # actually need python should use `target_compatible_with` and the generated - # @system_python//:exists or @system_python//:supported constraints. - ctx.file( - "BUILD.bazel", - _build_file.format( - interpreter = "", - support = "None", - ), - ) - ctx.file("version.bzl", "SYSTEM_PYTHON_VERSION = 'None'") - ctx.file("register.bzl", _mock_register) - ctx.file("pip.bzl", _mock_pip) - ctx.file("fuzzing_py.bzl", _mock_fuzzing_py) - -def _system_python_impl(repository_ctx): - path = _get_python_path(repository_ctx) - python3 = repository_ctx.which("python3") - python_version = _get_python_version(repository_ctx) - - if path and python_version[0] == "3": - _populate_package(repository_ctx, path, python3, python_version) - else: - # buildifier: disable=print - print("WARNING: no system python available, builds against system python will fail") - _populate_empty_package(repository_ctx) - -# The system_python() repository rule exposes information from the version of python installed in the current system. -# -# In WORKSPACE: -# system_python( -# name = "system_python_repo", -# minimum_python_version = "3.7", -# ) -# -# This repository exposes some repository rules for configuring python in Bazel. The python toolchain -# *must* be registered in your WORKSPACE: -# load("@system_python_repo//:register.bzl", "register_system_python") -# register_system_python() -# -# Pip dependencies can optionally be specified using a wrapper around rules_python's repository rules: -# load("@system_python//:pip.bzl", "pip_install") -# pip_install( -# name="pip_deps", -# requirements = "@com_google_protobuf//python:requirements.txt", -# ) -# An optional argument `requirements_overrides` takes a dictionary mapping python versions to alternate -# requirements files. This works around the requirement for fully pinned dependencies in python_rules. -# -# Four config settings are exposed from this repository to help declare target compatibility in Bazel. -# For example, `@system_python_repo//:exists` will be true if a system python version has been found. -# The `none` setting will be true only if no python version was found, and `supported`/`unsupported` -# correspond to whether or not the system version is compatible with `minimum_python_version`. -# -# This repository also exposes a header rule that you can depend on from BUILD files: -# cc_library( -# name = "foobar", -# srcs = ["foobar.cc"], -# deps = ["@system_python_repo//:python_headers"], -# ) -# -# The headers should correspond to the version of python obtained by running -# the `python3` command on the system. -system_python = repository_rule( - implementation = _system_python_impl, - local = True, - attrs = { - "minimum_python_version": attr.string(default = "3.7"), - }, -) diff --git a/python/internal.bzl b/python/internal.bzl index 8f99becec4ce..426f29aab8a3 100644 --- a/python/internal.bzl +++ b/python/internal.bzl @@ -126,9 +126,5 @@ def internal_py_test(deps = [], **kwargs): native.py_test( imports = ["."], deps = deps + ["//python:python_test_lib"], - target_compatible_with = select({ - "@system_python//:supported": [], - "//conditions:default": ["@platforms//:incompatible"], - }), **kwargs ) diff --git a/python/pb_unit_tests/BUILD b/python/pb_unit_tests/BUILD index 74b01c8eefda..12b92e133b98 100644 --- a/python/pb_unit_tests/BUILD +++ b/python/pb_unit_tests/BUILD @@ -40,10 +40,6 @@ py_test( name = "numpy_test", srcs = ["numpy_test_wrapper.py"], main = "numpy_test_wrapper.py", - target_compatible_with = select({ - "@system_python//:supported": [], - "//conditions:default": ["@platforms//:incompatible"], - }), deps = [ requirement("numpy"), "//python:_message", diff --git a/python/pb_unit_tests/pyproto_test_wrapper.bzl b/python/pb_unit_tests/pyproto_test_wrapper.bzl index 3ddf6302954d..06e2d23b7e16 100644 --- a/python/pb_unit_tests/pyproto_test_wrapper.bzl +++ b/python/pb_unit_tests/pyproto_test_wrapper.bzl @@ -37,10 +37,6 @@ def pyproto_test_wrapper(name, deps = []): # "//third_party/py/google/protobuf/internal:" + name + "_for_deps", # "//third_party/py/google/protobuf:use_upb_protos", # ], -# target_compatible_with = select({ -# "@platforms//os:windows": ["@platforms//:incompatible"], -# "//conditions:default": [], -# }), # ) # # end:google_only diff --git a/python/py_extension.bzl b/python/py_extension.bzl index 9a2828b950d3..400d35c2bcf8 100644 --- a/python/py_extension.bzl +++ b/python/py_extension.bzl @@ -27,14 +27,7 @@ def py_extension(name, srcs, copts, deps = [], **kwargs): linkshared = True, linkstatic = True, deps = deps + select({ - "//python:limited_api_3.8": ["@python-3.8.0//:python_headers"], - "//python:full_api_3.8_win32": ["@nuget_python_i686_3.8.0//:python_full_api"], - "//python:full_api_3.8_win64": ["@nuget_python_x86-64_3.8.0//:python_full_api"], - "//python:full_api_3.9_win32": ["@nuget_python_i686_3.9.0//:python_full_api"], - "//python:full_api_3.9_win64": ["@nuget_python_x86-64_3.9.0//:python_full_api"], - "//python:limited_api_3.10_win32": ["@nuget_python_i686_3.10.0//:python_limited_api"], - "//python:limited_api_3.10_win64": ["@nuget_python_x86-64_3.10.0//:python_limited_api"], - "//conditions:default": ["@system_python//:python_headers"], + "//conditions:default": ["@rules_python//python/cc:current_py_cc_headers"], }), **kwargs ) diff --git a/third_party/rules_fuzzing.patch b/third_party/rules_fuzzing.patch index 596a44dc768d..5e5965ad8033 100644 --- a/third_party/rules_fuzzing.patch +++ b/third_party/rules_fuzzing.patch @@ -1,25 +1,13 @@ -diff --git a/fuzzing/tools/validate_dict.py b/fuzzing/tools/validate_dict.py -index d561e68..52cbcb8 100644 ---- a/fuzzing/tools/validate_dict.py -+++ b/fuzzing/tools/validate_dict.py -@@ -19,7 +19,7 @@ Validates and merges a set of fuzzing dictionary files into a single output. - - from absl import app - from absl import flags --from dict_validation import validate_line -+from fuzzing.tools.dict_validation import validate_line - from sys import stderr - - FLAGS = flags.FLAGS -diff --git a/fuzzing/requirements.txt b/fuzzing/requirements.txt -index 01482d4..4b36f4f 100644 ---- a/fuzzing/requirements.txt -+++ b/fuzzing/requirements.txt -@@ -1,5 +1,5 @@ - # Python requirements for the tools supporting the fuzzing rules. These are - # installed automatically through the WORKSPACE configuration. - --absl-py==0.11.0 --hash=sha256:b3d9eb5119ff6e0a0125f6dabf2f9fae02f8acae7be70576002fac27235611c5 --six==1.15.0 --hash=sha256:8b74bedcbbbaca38ff6d7491d76f2b06b3592611af620f8426e82dddb04a5ced -+absl-py==2.0.0 --hash=sha256:9a28abb62774ae4e8edbe2dd4c49ffcd45a6a848952a5eccc6a49f3f0fc1e2f3 -+six==1.16.0 --hash=sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254 +diff --git a/fuzzing/private/binary.bzl b/fuzzing/private/binary.bzl +index 4c85aed..8ff9723 100644 +--- a/fuzzing/private/binary.bzl ++++ b/fuzzing/private/binary.bzl +@@ -114,7 +114,7 @@ def _fuzzing_binary_impl(ctx): + else: + default_info = ctx.attr.binary[DefaultInfo] + binary_runfiles = default_info.default_runfiles +- binary_repo_mapping_manifest = getattr(default_info.files_to_run, "repo_mapping_manifest") ++ binary_repo_mapping_manifest = getattr(default_info.files_to_run, "repo_mapping_manifest", None) + other_runfiles = [] + if ctx.file.corpus: + other_runfiles.append(ctx.file.corpus) \ No newline at end of file