def best_effort_version(version: str) -> str:
    """Convert an arbitrary string into a version-like string.
    >>> best_effort_version("v0.2 beta")
    '0.2b0'

    >>> import warnings
    >>> warnings.simplefilter("ignore", category=SetuptoolsDeprecationWarning)
    >>> best_effort_version("ubuntu lts")
    'ubuntu.lts'
    """
    # See pkg_resources.safe_version
    try:
        return safe_version(version)
    except packaging.version.InvalidVersion:
        SetuptoolsDeprecationWarning.emit(
            f"Invalid version: {version!r}.",
            f"""
            Version {version!r} is not valid according to PEP 440.

            Please make sure to specify a valid version for your package.
            Also note that future releases of setuptools may halt the build process
            if an invalid version is given.
            """,
            see_url="https://peps.python.org/pep-0440/",
            due_date=(2023, 9, 26),  # See setuptools/dist _validate_version
        )
        v = version.replace(' ', '.')
        return safe_name(v)
Convert an arbitrary string into a version-like string.
    >>> best_effort_version("v0.2 beta")
    '0.2b0'

    >>> import warnings
    >>> warnings.simplefilter("ignore", category=SetuptoolsDeprecationWarning)
    >>> best_effort_version("ubuntu lts")
    'ubuntu.lts'
    
product/gradle-plugin/src/main/python/setuptools/_normalization.py