buildsystem: pull in setuptools so Cython finds distutils#1804
Open
nicolassanchez02 wants to merge 1 commit into
Open
buildsystem: pull in setuptools so Cython finds distutils#1804nicolassanchez02 wants to merge 1 commit into
nicolassanchez02 wants to merge 1 commit into
Conversation
On Python 3.12 distutils is gone from the stdlib, but Cython's cythonize() still does `from distutils.extension import Extension` deep in its dependency scan, so the build dies with "No module named 'distutils'". setuptools ships a stand-in and wires up the import shim when it's imported, but the site-startup shim isn't always active (it depends on how setuptools landed on the box), which is why some people hit this even with setuptools installed. Import setuptools explicitly at the top of cythonize.py so the shim is in place before Cython looks, and bail with a clear "install setuptools" message instead of a deep traceback if it isn't there at all. Closes SFTtech#1769.
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Merge Checklist
make checkmergeOn Python 3.12 distutils is gone from the stdlib, but
cythonize()still doesfrom distutils.extension import Extensiondeep in its dependency scan, so the build dies withModuleNotFoundError: No module named 'distutils'. setuptools ships a stand-in and installs the import shim when it's imported, but the site-startup shim isn't always active depending on how setuptools landed on the box, which is why people hit this even with setuptools installed.cythonize.py now imports setuptools explicitly before Cython, so the shim is in place before Cython goes looking, and if setuptools genuinely isn't there it bails with an "install setuptools" message instead of a deep traceback.
Reproduced on a python without setuptools (distutils import fails); with the change cythonize.py prints the clear message, and the normal build with setuptools present runs through untouched.
Closes #1769.