Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BLD: remove distutil from setup.py #77

Merged
merged 1 commit into from
Jul 13, 2024

Conversation

sabonerune
Copy link
Contributor

Remove distutil from setup.py

  • Remove distutils.version.LooseVersion.

    Cython version checking is done in pyproject.toml so there is no need to check it.

    The ability to build if you have a .cpp files even if Cython is not installed will continue to be supported.
    ref: https://setuptools.pypa.io/en/latest/userguide/ext_modules.html#distributing-extensions-compiled-with-cython

  • Remove distutils.spawn.spawn and distutils.errors.DistutilsExecError.

    pyopenjtalk/setup.py

    Lines 111 to 172 in 48dd78c

    # Workaround for `distutils.spawn` problem on Windows python < 3.9
    # See details: [bpo-39763: distutils.spawn now uses subprocess (GH-18743)]
    # (https://github.com/python/cpython/commit/1ec63b62035e73111e204a0e03b83503e1c58f2e)
    def test_quoted_arg_change():
    child_script = """
    import os
    import sys
    if len(sys.argv) > 5:
    try:
    os.makedirs(sys.argv[1], exist_ok=True)
    with open(sys.argv[2], mode=sys.argv[3], encoding=sys.argv[4]) as fd:
    fd.write(sys.argv[5])
    except OSError:
    pass
    """
    try:
    # write
    package_build_dir = "build"
    file_name = join(package_build_dir, "quoted_arg_output")
    output_mode = "w"
    file_encoding = "utf8"
    arg_value = '"ARG"'
    spawn(
    [
    sys.executable,
    "-c",
    child_script,
    package_build_dir,
    file_name,
    output_mode,
    file_encoding,
    arg_value,
    ]
    )
    # read
    with open(file_name, mode="r", encoding=file_encoding) as fd:
    return fd.readline() != arg_value
    except (DistutilsExecError, TypeError):
    return False
    def escape_string_macro_arg(s):
    return s.replace("\\", "\\\\").replace('"', '\\"')
    def escape_macro_element(x):
    (k, arg) = x
    return (k, escape_string_macro_arg(arg)) if type(arg) == str else x
    def escape_macros(macros):
    return list(map(escape_macro_element, macros))
    custom_define_macros = (
    escape_macros
    if platform_is_windows and test_quoted_arg_change()
    else (lambda macros: macros)
    )

    This bug seems to have been patched by setuptools>=60.0.0.
    Therefore, this code can be made unnecessary by changing the version of setuptools only on Windows.

    It may be better to upgrade the version of setuptools on other OS as well.
    However, since I can't reproduce pyopenjtalk cannot be installed in google colab #27 , So I leave it as is.

@r9y9 r9y9 merged commit f0d4d22 into r9y9:master Jul 13, 2024
6 checks passed
@sabonerune sabonerune deleted the bld/remove-distutil branch July 14, 2024 23:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants