Skip to content

buildsystem: pull in setuptools so Cython finds distutils#1804

Open
nicolassanchez02 wants to merge 1 commit into
SFTtech:masterfrom
nicolassanchez02:fix/cythonize-distutils
Open

buildsystem: pull in setuptools so Cython finds distutils#1804
nicolassanchez02 wants to merge 1 commit into
SFTtech:masterfrom
nicolassanchez02:fix/cythonize-distutils

Conversation

@nicolassanchez02
Copy link
Copy Markdown
Contributor

Merge Checklist

On Python 3.12 distutils is gone from the stdlib, but cythonize() still does from distutils.extension import Extension deep in its dependency scan, so the build dies with ModuleNotFoundError: 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.

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.
@nicolassanchez02
Copy link
Copy Markdown
Contributor Author

The macOS-CI failure here isn't anything in this PR: configure aborts at find_package(Eigen3 3.3) rejecting the Eigen 5 the runner ships, before the build runs. That's the issue #1801 fixes. Once #1801 lands I'll rebase this onto master and the check goes green.

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.

Cythonize error when building with nyan

1 participant