diff --git a/MODULE.bazel b/MODULE.bazel index 565a5372e8..71596a3fcc 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -28,16 +28,13 @@ use_repo( "pypi__coverage_cp310_aarch64-apple-darwin", "pypi__coverage_cp310_aarch64-unknown-linux-gnu", "pypi__coverage_cp310_x86_64-apple-darwin", - "pypi__coverage_cp310_x86_64-pc-windows-msvc", "pypi__coverage_cp310_x86_64-unknown-linux-gnu", "pypi__coverage_cp38_aarch64-apple-darwin", "pypi__coverage_cp38_aarch64-unknown-linux-gnu", "pypi__coverage_cp38_x86_64-apple-darwin", - "pypi__coverage_cp38_x86_64-pc-windows-msvc", "pypi__coverage_cp38_x86_64-unknown-linux-gnu", "pypi__coverage_cp39_aarch64-apple-darwin", "pypi__coverage_cp39_aarch64-unknown-linux-gnu", "pypi__coverage_cp39_x86_64-apple-darwin", - "pypi__coverage_cp39_x86_64-pc-windows-msvc", "pypi__coverage_cp39_x86_64-unknown-linux-gnu", ) diff --git a/python/private/coverage_deps.bzl b/python/private/coverage_deps.bzl index 0a27f03e8c..fe72296ed2 100644 --- a/python/private/coverage_deps.bzl +++ b/python/private/coverage_deps.bzl @@ -26,12 +26,6 @@ _coverage_deps = [ "ef8674b0ee8cc11e2d574e3e2998aea5df5ab242e012286824ea3c6970580e53", "x86_64-apple-darwin", ), - ( - "pypi__coverage_cp310_x86_64-pc-windows-msvc", - "https://files.pythonhosted.org/packages/ae/a3/f45cb5d32de0751863945d22083c15eb8854bb53681b2e792f2066c629b9/coverage-6.5.0-cp310-cp310-win_amd64.whl", - "59f53f1dc5b656cafb1badd0feb428c1e7bc19b867479ff72f7a9dd9b479f10e", - "x86_64-pc-windows-msvc", - ), ( "pypi__coverage_cp310_x86_64-unknown-linux-gnu", "https://files.pythonhosted.org/packages/3c/7d/d5211ea782b193ab8064b06dc0cc042cf1a4ca9c93a530071459172c550f/coverage-6.5.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", @@ -56,12 +50,6 @@ _coverage_deps = [ "d900bb429fdfd7f511f868cedd03a6bbb142f3f9118c09b99ef8dc9bf9643c3c", "x86_64-apple-darwin", ), - ( - "pypi__coverage_cp38_x86_64-pc-windows-msvc", - "https://files.pythonhosted.org/packages/06/f1/5177428c35f331f118e964f727f79e3a3073a10271a644c8361d3cea8bfd/coverage-6.5.0-cp38-cp38-win_amd64.whl", - "7ccf362abd726b0410bf8911c31fbf97f09f8f1061f8c1cf03dfc4b6372848f6", - "x86_64-pc-windows-msvc", - ), ( "pypi__coverage_cp38_x86_64-unknown-linux-gnu", "https://files.pythonhosted.org/packages/bd/a0/e263b115808226fdb2658f1887808c06ac3f1b579ef5dda02309e0d54459/coverage-6.5.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", @@ -86,12 +74,6 @@ _coverage_deps = [ "633713d70ad6bfc49b34ead4060531658dc6dfc9b3eb7d8a716d5873377ab745", "x86_64-apple-darwin", ), - ( - "pypi__coverage_cp39_x86_64-pc-windows-msvc", - "https://files.pythonhosted.org/packages/b6/08/a88a9f3a11bb2d97c7a6719535a984b009728433838fbc65766488867c80/coverage-6.5.0-cp39-cp39-win_amd64.whl", - "fc2af30ed0d5ae0b1abdb4ebdce598eafd5b35397d4d75deb341a614d333d987", - "x86_64-pc-windows-msvc", - ), ( "pypi__coverage_cp39_x86_64-unknown-linux-gnu", "https://files.pythonhosted.org/packages/6b/f2/919f0fdc93d3991ca074894402074d847be8ac1e1d78e7e9e1c371b69a6f/coverage-6.5.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", diff --git a/python/repositories.bzl b/python/repositories.bzl index 2961d6d305..248aedf12f 100644 --- a/python/repositories.bzl +++ b/python/repositories.bzl @@ -267,7 +267,7 @@ py_runtime_pair( python_path = python_bin, python_version = python_short_version, python_version_nodot = python_short_version.replace(".", ""), - coverage_tool = rctx.attr.coverage_tool if rctx.attr.coverage_tool == None else "\"{}\"".format(rctx.attr.coverage_tool), + coverage_tool = rctx.attr.coverage_tool if rctx.attr.coverage_tool == None and "windows" not in rctx.os.name else "\"{}\"".format(rctx.attr.coverage_tool), ) rctx.delete("python") rctx.symlink(python_bin, "python") @@ -418,7 +418,7 @@ def python_register_toolchains( # allow passing in a tool version coverage_tool = None coverage_tool = tool_versions[python_version].get("coverage_tool", {}).get(platform, None) - if register_coverage_tool and coverage_tool == None: + if register_coverage_tool and coverage_tool == None and "windows" not in platform: python_short_version = python_version.rpartition(".")[0] coverage_tool = Label("@pypi__coverage_cp{python_version_nodot}_{platform}//:coverage".format( python_version_nodot = python_short_version.replace(".", ""), diff --git a/python/tests/toolchains/defs.bzl b/python/tests/toolchains/defs.bzl index 24c0bca554..c8289dde3a 100644 --- a/python/tests/toolchains/defs.bzl +++ b/python/tests/toolchains/defs.bzl @@ -24,15 +24,13 @@ powershell.exe -c "& ./{interpreter_path} {run_acceptance_test_py}" """ def _acceptance_test_impl(ctx): - cov_suffix = "cov" if ctx.attr.register_coverage_tool else "nocov" - base = "/".join([ctx.attr.python_version, cov_suffix]) + base = "/".join([ctx.attr.python_version]) workspace = ctx.actions.declare_file("/".join([base, "WORKSPACE"])) ctx.actions.expand_template( template = ctx.file._workspace_tmpl, output = workspace, substitutions = { "%python_version%": ctx.attr.python_version, - "%register_coverage_tool%": "True" if ctx.attr.register_coverage_tool else "False", }, ) @@ -54,7 +52,6 @@ def _acceptance_test_impl(ctx): template = ctx.file._run_acceptance_test_tmpl, output = run_acceptance_test_py, substitutions = { - "%is_coverage%": str(ctx.attr.register_coverage_tool), "%is_windows%": str(ctx.attr.is_windows), "%python_version%": ctx.attr.python_version, "%test_location%": "/".join([ctx.attr.test_location, base]), @@ -68,7 +65,7 @@ def _acceptance_test_impl(ctx): interpreter_path = py3_runtime.interpreter.short_path if ctx.attr.is_windows: - executable = ctx.actions.declare_file("run_test_{}_{}.bat".format(ctx.attr.python_version, cov_suffix)) + executable = ctx.actions.declare_file("run_test_{}.bat".format(ctx.attr.python_version)) ctx.actions.write( output = executable, content = _WINDOWS_RUNNER_TEMPLATE.format( @@ -78,7 +75,7 @@ def _acceptance_test_impl(ctx): is_executable = True, ) else: - executable = ctx.actions.declare_file("run_test_{}_{}.sh".format(ctx.attr.python_version, cov_suffix)) + executable = ctx.actions.declare_file("run_test_{}.sh".format(ctx.attr.python_version)) ctx.actions.write( output = executable, content = "exec '{interpreter_path}' '{run_acceptance_test_py}'".format( @@ -119,10 +116,6 @@ _acceptance_test = rule( doc = "The Python version to be used when requesting the toolchain.", mandatory = True, ), - "register_coverage_tool": attr.bool( - doc = "Whether to register the coverage tool to the toolchain.", - mandatory = True, - ), "test_location": attr.string( doc = "(Provided by the macro) The value of native.package_name().", mandatory = True, @@ -176,15 +169,12 @@ def acceptance_tests(): if platform not in TOOL_VERSIONS[python_version]["sha256"]: continue - for register_coverage_tool in [True, False]: - acceptance_test( - name = "python_{python_version}_{platform}_{cov}_test".format( - python_version = python_version.replace(".", "_"), - platform = platform, - cov = "cov" if register_coverage_tool else "nocov", - ), - python_version = python_version, - register_coverage_tool = register_coverage_tool, - target_compatible_with = meta.compatible_with, - tags = ["acceptance-test"], - ) + acceptance_test( + name = "python_{python_version}_{platform}_test".format( + python_version = python_version.replace(".", "_"), + platform = platform, + ), + python_version = python_version, + target_compatible_with = meta.compatible_with, + tags = ["acceptance-test"], + ) diff --git a/python/tests/toolchains/run_acceptance_test.py.tmpl b/python/tests/toolchains/run_acceptance_test.py.tmpl index 55967f3f4e..76c0df5418 100644 --- a/python/tests/toolchains/run_acceptance_test.py.tmpl +++ b/python/tests/toolchains/run_acceptance_test.py.tmpl @@ -40,13 +40,9 @@ class TestPythonVersion(unittest.TestCase): rules_python_path.replace("\\", "/") ), "build --test_output=errors", + "coverage --java_runtime_version=remotejdk_11", ] - if %is_coverage%: - bazelrc_lines.append( - "coverage --java_runtime_version=remotejdk_11" - ) - with open(".bazelrc", "w") as bazelrc: bazelrc.write(os.linesep.join(bazelrc_lines)) @@ -57,14 +53,14 @@ class TestPythonVersion(unittest.TestCase): subprocess.run("bazel test //...", shell=True, check=True) - if %is_coverage%: - subprocess.run("bazel coverage //...", shell=True, check=True) - return - stream = os.popen("bazel info execution_root") exec_root = pathlib.Path(stream.read().strip()) external = exec_root / "external" - self.assertEqual([], list(external.glob("pypi__coverage_*")), "coverage toolchain should not be downloaded") + self.assertEqual([], list(external.glob("pypi__coverage_*")), "coverage toolchain should not be downloaded upon bazel test") + + @unittest.skipIf(%is_windows%, "not supported on Windows") + def test_coverage_toolchain(self): + subprocess.run("bazel coverage //...", shell=True, check=True) if __name__ == "__main__": diff --git a/python/tests/toolchains/workspace_template/WORKSPACE.tmpl b/python/tests/toolchains/workspace_template/WORKSPACE.tmpl index 8d3d91031c..d0aa700928 100644 --- a/python/tests/toolchains/workspace_template/WORKSPACE.tmpl +++ b/python/tests/toolchains/workspace_template/WORKSPACE.tmpl @@ -24,5 +24,4 @@ load("@rules_python//python:repositories.bzl", "python_register_toolchains") python_register_toolchains( name = "python", python_version = "%python_version%", - register_coverage_tool = %register_coverage_tool%, ) diff --git a/tools/update_coverage_deps.py b/tools/update_coverage_deps.py index 0508e0ab9f..562a7e2c11 100755 --- a/tools/update_coverage_deps.py +++ b/tools/update_coverage_deps.py @@ -17,7 +17,8 @@ # This should be kept in sync with //python:versions.bzl _supported_platforms = { - "win_amd64": "x86_64-pc-windows-msvc", + # Windows is unsupported right now + # "win_amd64": "x86_64-pc-windows-msvc", "manylinux2014_x86_64": "x86_64-unknown-linux-gnu", "manylinux2014_aarch64": "aarch64-unknown-linux-gnu", "macosx_11_0_arm64": "aarch64-apple-darwin",