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

setuptools patching (semi-randomly) breaks setuptools-rust, resulting in nonfunctional packages #413

Closed
mgorny opened this issue Jun 24, 2023 · 0 comments · Fixed by #414

Comments

@mgorny
Copy link

mgorny commented Jun 24, 2023

If setuptools-rust and scikit-build-core are installed within the same build environment, depending on plugin load order, the latter could cause Rust extensions to be silently skipped and nonfunctional packages to be built.

The problem is that both packages define setuptools.finalize_distribution_options entry points, and both override has_ext_modules method:

If the entry point from setuptools-rust is executed first, then scikit-build-core overwrites its has_ext_modules method. As a result, the Rust extensions aren't detected, build command doesn't invoke build_rust and the package is installed without any Rust extensions.

FWICS setuptools-rust avoids the problem by storing and calling the previous value of has_ext_modules rather than the generic method from Distribution. FWICS doing the same in scikit-build-core fixes building Rust extensions (but I haven't tested whether it doesn't break something related to scikit-build-core). I tested changing the linked line to:

    orig_has_ext_modules = dist.has_ext_modules
    dist.has_ext_modules = lambda: orig_has_ext_modules() or _has_cmake(dist)

Gentoo bug report: https://bugs.gentoo.org/909035

henryiii added a commit that referenced this issue Jun 24, 2023
Fix #413.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
henryiii added a commit that referenced this issue Jun 14, 2024
This is a sort of follow up to #413 and #414. In sage-on-gentoo we
discovered that the presence of scikit-build-core breaks the building
sagemath (cschwan/sage-on-gentoo#783).
scikit-build-core also happens to be an indirect dependency for building
sagemath's documentation.
On the basis that the presence of setuptolls_rust does not break
sagemath's build, I studied the difference with scikit-build-core. I
noticed that the elements `bundled in the single
"finalize_distribution_options" entrypoint in scikit is split between
two different setuptools entrypoints.
This PR reproduce that setup and does a bit of clean up. The bundling of
the old _prepare_extension_detection and _prepare_build_cmake_command
into finalize_distribution_options being redundant after attributing
them directly to separate entrypoints. I also renamed the functions to
better characterise them.

Using this PR, sagemath builds without problems and pyzmq, which uses
scikit-build-core also builds properly.

---------

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>
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 a pull request may close this issue.

1 participant