def do_remove_extension(*args):
    """Remove the compiled C extension, no matter what its name."""

    so_patterns = """
        tracer.so
        tracer.*.so
        tracer.pyd
        tracer.*.pyd
        """.split()

    if "--from-install" in args:
        # Get the install location using a subprocess to avoid
        # locking the file we are about to delete
        root = os.path.dirname(
            subprocess.check_output(
                [
                    sys.executable,
                    "-Xutf8",
                    "-c",
                    "import coverage; print(coverage.__file__)",
                ],
                encoding="utf-8",
            ).strip(),
        )
        roots = [root]
    else:
        roots = [
            "coverage",
            "build/*/coverage",
            ".tox/*/[Ll]ib/*/site-packages/coverage",
            ".tox/*/[Ll]ib/site-packages/coverage",
        ]

    for root, pattern in itertools.product(roots, so_patterns):
        pattern = os.path.join(root, pattern)
        if VERBOSITY > 1:
            print(f"Searching for {pattern} from {os.getcwd()}")
        for filename in glob.glob(pattern):
            if os.path.exists(filename):
                if VERBOSITY > 1:
                    print(f"Removing {os.path.abspath(filename)}")
                try:
                    os.remove(filename)
                except OSError as exc:
                    if VERBOSITY > 1:
                        print(f"Couldn't remove {os.path.abspath(filename)}: {exc}")
Remove the compiled C extension, no matter what its name.
igor.py