(
    wheel_ctx: InWheelCtx, platforms: List[str], remove_platforms: Iterable[str] = ()
)
return out_wheel
Add platform tags `platforms` to a wheel

    Add any platform tags in `platforms` that are missing
    to wheel_ctx's filename and ``WHEEL`` file.

    Parameters
    ----------
    wheel_ctx : InWheelCtx
        An open wheel context
    platforms : list
        platform tags to add to wheel filename and WHEEL tags - e.g.
        ``('macosx_10_9_intel', 'macosx_10_9_x86_64')
    remove_platforms : iterable
        platform tags to remove to the wheel filename and WHEEL tags, e.g.
        ``('linux_x86_64',)`` when ``('manylinux_x86_64')`` is added
Add platform tags `platforms` to a wheel
Add platform tags platforms to a wheel
def add_platforms(
    wheel_ctx: InWheelCtx, platforms: List[str], remove_platforms: Iterable[str] = ()
) -> str:
    """Add platform tags `platforms` to a wheel

    Add any platform tags in `platforms` that are missing
    to wheel_ctx's filename and ``WHEEL`` file.

    Parameters
    ----------
    wheel_ctx : InWheelCtx
        An open wheel context
    platforms : list
        platform tags to add to wheel filename and WHEEL tags - e.g.
        ``('macosx_10_9_intel', 'macosx_10_9_x86_64')
    remove_platforms : iterable
        platform tags to remove to the wheel filename and WHEEL tags, e.g.
        ``('linux_x86_64',)`` when ``('manylinux_x86_64')`` is added
    """
    definitely_not_purelib = False

    if wheel_ctx.path is None:
        raise ValueError(
            "This function should be called from wheel_ctx context manager"
        )

    info_fname = pjoin(_dist_info_dir(wheel_ctx.path), "WHEEL")
    info = read_pkg_info(info_fname)
    # Check what tags we have
    if wheel_ctx.out_wheel is not None:
        out_dir = dirname(wheel_ctx.out_wheel)
        wheel_fname = basename(wheel_ctx.out_wheel)
    else:
        out_dir = "."
        wheel_fname = basename(wheel_ctx.in_wheel)

    parsed_fname = WHEEL_INFO_RE.match(wheel_fname)
    fparts = parsed_fname.groupdict()
    original_fname_tags = fparts["plat"].split(".")
    logger.info("Previous filename tags: %s", ", ".join(original_fname_tags))
    fname_tags = [tag for tag in original_fname_tags if tag not in remove_platforms]
    fname_tags = unique_by_index(fname_tags + platforms)

    # Can't be 'any' and another platform
    if "any" in fname_tags and len(fname_tags) > 1:
        fname_tags.remove("any")
        remove_platforms.append("any")
        definitely_not_purelib = True

    if fname_tags != original_fname_tags:
        logger.info("New filename tags: %s", ", ".join(fname_tags))
    else:
        logger.info("No filename tags change needed.")

    _, ext = splitext(wheel_fname)
    fparts["plat"] = ".".join(fname_tags)
    fparts["ext"] = ext
    out_wheel_fname = "{namever}-{pyver}-{abi}-{plat}{ext}".format(**fparts)
    out_wheel = pjoin(out_dir, out_wheel_fname)

    in_info_tags = [tag for name, tag in info.items() if name == "Tag"]
    logger.info("Previous WHEEL info tags: %s", ", ".join(in_info_tags))
    # Python version, C-API version combinations
    pyc_apis = ["-".join(tag.split("-")[:2]) for tag in in_info_tags]
    # unique Python version, C-API version combinations
    pyc_apis = unique_by_index(pyc_apis)
    # Add new platform tags for each Python version, C-API combination
    wanted_tags = ["-".join(tup) for tup in product(pyc_apis, platforms)]
    new_tags = [tag for tag in wanted_tags if tag not in in_info_tags]
    unwanted_tags = ["-".join(tup) for tup in product(pyc_apis, remove_platforms)]
    updated_tags = [tag for tag in in_info_tags if tag not in unwanted_tags]
    updated_tags += new_tags
    if updated_tags != in_info_tags:
        del info["Tag"]
        for tag in updated_tags:
            info.add_header("Tag", tag)

        if definitely_not_purelib:
            info["Root-Is-Purelib"] = "False"
            logger.info("Changed wheel type to Platlib")

        logger.info("New WHEEL info tags: %s", ", ".join(info.get_all("Tag")))
        write_pkg_info(info_fname, info)
    else:
        logger.info("No WHEEL info change needed.")
    return out_wheel
def add_platforms ( wheel_ctx : InWheelCtx , platforms : List [ str ] , remove_platforms : Iterable [ str ] = ( ) ) -> str : definitely_not_purelib = False if wheel_ctx . path is None : raise ValueError ( "This function should be called from wheel_ctx context manager" ) info_fname = pjoin ( _dist_info_dir ( wheel_ctx . path ) , "WHEEL" ) info = read_pkg_info ( info_fname ) # Check what tags we have if wheel_ctx . out_wheel is not None : out_dir = dirname ( wheel_ctx . out_wheel ) wheel_fname = basename ( wheel_ctx . out_wheel ) else : out_dir = "." wheel_fname = basename ( wheel_ctx . in_wheel ) parsed_fname = WHEEL_INFO_RE . match ( wheel_fname ) fparts = parsed_fname . groupdict ( ) original_fname_tags = fparts [ "plat" ] . split ( "." ) logger . info ( "Previous filename tags: %s" , ", " . join ( original_fname_tags ) ) fname_tags = [ tag for tag in original_fname_tags if tag not in remove_platforms ] fname_tags = unique_by_index ( fname_tags + platforms ) # Can't be 'any' and another platform if "any" in fname_tags and len ( fname_tags ) > 1 : fname_tags . remove ( "any" ) remove_platforms . append ( "any" ) definitely_not_purelib = True if fname_tags != original_fname_tags : logger . info ( "New filename tags: %s" , ", " . join ( fname_tags ) ) else : logger . info ( "No filename tags change needed." ) _ , ext = splitext ( wheel_fname ) fparts [ "plat" ] = "." . join ( fname_tags ) fparts [ "ext" ] = ext out_wheel_fname = "{namever}-{pyver}-{abi}-{plat}{ext}" . format ( * * fparts ) out_wheel = pjoin ( out_dir , out_wheel_fname ) in_info_tags = [ tag for name , tag in info . items ( ) if name == "Tag" ] logger . info ( "Previous WHEEL info tags: %s" , ", " . join ( in_info_tags ) ) # Python version, C-API version combinations pyc_apis = [ "-" . join ( tag . split ( "-" ) [ : 2 ] ) for tag in in_info_tags ] # unique Python version, C-API version combinations pyc_apis = unique_by_index ( pyc_apis ) # Add new platform tags for each Python version, C-API combination wanted_tags = [ "-" . join ( tup ) for tup in product ( pyc_apis , platforms ) ] new_tags = [ tag for tag in wanted_tags if tag not in in_info_tags ] unwanted_tags = [ "-" . join ( tup ) for tup in product ( pyc_apis , remove_platforms ) ] updated_tags = [ tag for tag in in_info_tags if tag not in unwanted_tags ] updated_tags += new_tags if updated_tags != in_info_tags : del info [ "Tag" ] for tag in updated_tags : info . add_header ( "Tag" , tag ) if definitely_not_purelib : info [ "Root-Is-Purelib" ] = "False" logger . info ( "Changed wheel type to Platlib" ) logger . info ( "New WHEEL info tags: %s" , ", " . join ( info . get_all ( "Tag" ) ) ) write_pkg_info ( info_fname , info ) else : logger . info ( "No WHEEL info change needed." ) return out_wheel