Skip to content

[BUG] ImportError: cannot import name 'LinkError' from 'distutils.ccompiler' #4866

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

Closed
ax3l opened this issue Mar 9, 2025 · 4 comments · Fixed by #4867
Closed

[BUG] ImportError: cannot import name 'LinkError' from 'distutils.ccompiler' #4866

ax3l opened this issue Mar 9, 2025 · 4 comments · Fixed by #4867
Assignees
Labels

Comments

@ax3l
Copy link

ax3l commented Mar 9, 2025

setuptools version

75.9.0

Python version

3.9

OS

Ubuntu 24.04

Additional environment information

GH actions

Description

Since the latest release 75.9.0, my mpi4py builds (version: 4.0.3) fail with ImportError: cannot import name 'LinkError' from 'distutils.ccompiler'

Expected behavior

Please do not fail, it worked a minor version ago :)

How to Reproduce

Install latest setuptools and then MPICH or OpenMPI (e.g., from apt) and then pip-install mpi4py.

Output

job-logs.txt

@jaraco
Copy link
Member

jaraco commented Mar 9, 2025

Some background - this issue is due to the refactoring in pypa/distutils#295, which is an attempt toward isolating the compiler functionality from distutils. The canonical place to find that class was in distutils.errors.LinkError, which has now been moved to distutils.compiler.C.errors. I did create some compatibility shims where I expected them to be used, but I see now there's at least one expectation that LinkError also be exposed under distutils.ccompiler. I'll re-add an alias for that too.

Thanks for the report and sorry for the inconvenience.

I am aiming ultimately to move everything from distutils.compilers into a separate package, so don't bother updating references yet. In fact, this issue reminds me to make it a private distutils._compilers so there's explicitly no expectation that these names are a public interface.

Expect a fix tomorrow.

@jaraco jaraco removed the Needs Triage Issues that need to be evaluated for severity and status. label Mar 9, 2025
@jaraco jaraco self-assigned this Mar 9, 2025
@jaraco
Copy link
Member

jaraco commented Mar 9, 2025

Oh, wow. I thought for sure the issue was that mpi4py was implicated in the deprecated usage, but the call is coming from inside the house:

2025-03-09T01:26:29.5545578Z         File "/tmp/pip-build-env-ayb2fipe/overlay/lib/python3.9/site-packages/setuptools/_distutils/command/config.py", line 242, in try_link
2025-03-09T01:26:29.5546675Z           from ..ccompiler import CompileError, LinkError
2025-03-09T01:26:29.5547969Z       ImportError: cannot import name 'LinkError' from 'distutils.ccompiler' (/tmp/pip-build-env-ayb2fipe/overlay/lib/python3.9/site-packages/setuptools/_distutils/ccompiler.py)

It's slightly stunning that neither the distutils nor setuptools tests managed to pick this issue up. I guess that means that Config.try_link is never tested. :(

@jaraco
Copy link
Member

jaraco commented Mar 9, 2025

I've gone ahead and yanked the release.

@ax3l
Copy link
Author

ax3l commented Mar 9, 2025

Thank you for the quick fix 🙏❤️

jonathanperret added a commit to jonathanperret/ayab-desktop that referenced this issue Mar 10, 2025
Release 75.9.0 of setuptools changed some internal module paths that broke PyInstaller,
and other stuff,  see pypa/setuptools#4866 for example.
jonathanperret added a commit to jonathanperret/ayab-desktop that referenced this issue Mar 10, 2025
Release 75.9.0 of setuptools changed some internal module paths that broke PyInstaller,
and other stuff, see pypa/setuptools#4866 for example.
dl1com pushed a commit to AllYarnsAreBeautiful/ayab-desktop that referenced this issue Mar 10, 2025
Release 75.9.0 of setuptools changed some internal module paths that broke PyInstaller,
and other stuff, see pypa/setuptools#4866 for example.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants