Skip to content

gh-132415: Use shutil.which() in missing_compiler_executable() #132906

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

Merged
merged 1 commit into from
Apr 25, 2025

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Apr 25, 2025

Replace deprecated distutils.spawn.find_executable() with shutil.which() in missing_compiler_executable() of test.support.

Replace deprecated distutils.spawn.find_executable() with
shutil.which() in missing_compiler_executable() of test.support.
@vstinner
Copy link
Member Author

test_peg_generator fails with DeprecationWarning.

Example: https://buildbot.python.org/#/builders/64/builds/9220

ERROR: test_c_parser (test.test_peg_generator.test_c_parser.TestCParser.test_c_parser)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.x.cstratak-RHEL8-x86_64.lto/build/Lib/test/test_peg_generator/test_c_parser.py", line 113, in setUp
    cmd = support.missing_compiler_executable()
  File "/home/buildbot/buildarea/3.x.cstratak-RHEL8-x86_64.lto/build/Lib/test/support/__init__.py", line 1963, in missing_compiler_executable
    if spawn.find_executable(cmd[0]) is None:
       ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
  File "/home/buildbot/buildarea/3.x.cstratak-RHEL8-x86_64.lto/build/build/test_python_626928æ/tempcwd/venv/lib/python3.14/site-packages/setuptools/_distutils/spawn.py", line 104, in find_executable
    warnings.warn(
    ~~~~~~~~~~~~~^
        'Use shutil.which instead of find_executable', DeprecationWarning, stacklevel=2
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
DeprecationWarning: Use shutil.which instead of find_executable

@vstinner vstinner merged commit de6482e into python:main Apr 25, 2025
43 of 44 checks passed
@vstinner vstinner deleted the which branch April 25, 2025 09:50
@miss-islington-app
Copy link

Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Apr 25, 2025
…ythonGH-132906)

Replace deprecated distutils.spawn.find_executable() with
shutil.which() in missing_compiler_executable() of test.support.
(cherry picked from commit de6482e)

Co-authored-by: Victor Stinner <vstinner@python.org>
@bedevere-app
Copy link

bedevere-app bot commented Apr 25, 2025

GH-132916 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Apr 25, 2025
vstinner added a commit that referenced this pull request Apr 25, 2025
…GH-132906) (#132916)

gh-132415: Use shutil.which() in missing_compiler_executable() (GH-132906)

Replace deprecated distutils.spawn.find_executable() with
shutil.which() in missing_compiler_executable() of test.support.
(cherry picked from commit de6482e)

Co-authored-by: Victor Stinner <vstinner@python.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant