Skip to content

[python-package] Remove dead Python 2 guard and sklearn.cross_validation fallback#12107

Closed
RAMitchell wants to merge 4 commits intodmlc:masterfrom
RAMitchell:pr-12086-ci-fix
Closed

[python-package] Remove dead Python 2 guard and sklearn.cross_validation fallback#12107
RAMitchell wants to merge 4 commits intodmlc:masterfrom
RAMitchell:pr-12086-ci-fix

Conversation

@RAMitchell
Copy link
Copy Markdown
Member

Summary

This supersedes PR #12086 with the same Python-package cleanup plus a fix for the macOS x86_64 wheel CI failure.

The original change removes dead compatibility code in compat.py:

  • remove the dead Python 2 guard
  • remove the unreachable sklearn.cross_validation fallback

Additional CI Fix

The failing job was:

  • Build macOS wheel (macosx_x86_64)

delocate failed while repairing the wheel because libxgboost.dylib picked up Homebrew LLVM's libunwind.1.0.dylib, and that dependency requires macOS 14.0 even though the wheel target is macOS 10.15.

On the macOS Intel runner, the wheel build was resolving OpenMP through Homebrew. That in turn introduced a dependency on Homebrew LLVM's libunwind, which caused wheel repair to fail with:

delocate.libsana.DelocationError: Library dependencies do not satisfy target MacOS version 10.15:
.../libunwind.1.0.dylib has a minimum target of 14.0

This PR makes the macOS wheel build prefer Conda's llvm-openmp runtime instead of relying on Homebrew's OpenMP path:

  • install llvm-openmp in the Conda environment during macOS wheel builds
  • add CMAKE_PREFIX_PATH=$CONDA_PREFIX for the wheel build
  • update FindOpenMPMacOS.cmake to prefer $CONDA_PREFIX/lib/libomp.dylib when available
  • keep the Conda lib directory ahead of Homebrew in the macOS runtime search path

This avoids pulling Homebrew LLVM's libunwind into the wheel repair step and preserves the existing macOS 10.15 deployment target.

Why not bump the deployment target?

A simpler workaround would be to raise the Intel macOS wheel target from 10.15 to 14.0, but that would be a significant compatibility drop for macOS x86_64 users. This change keeps the current support target intact and fixes the dependency resolution instead.

PavelGuzenfeld and others added 4 commits March 15, 2026 20:46
- Remove `assert sys.version_info[0] == 3` — XGBoost requires
  Python >= 3.10 (pyproject.toml), making this check dead code.
  Using `assert` for version checks is also incorrect as assertions
  are stripped under `python -O`.

- Remove `sklearn.cross_validation` import fallback —
  `sklearn.cross_validation` was removed in scikit-learn 0.20 (2018).
  Any scikit-learn version supporting Python 3.10+ will have
  `sklearn.model_selection`.
@RAMitchell RAMitchell closed this Mar 19, 2026
@RAMitchell RAMitchell deleted the pr-12086-ci-fix branch March 19, 2026 11:39
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.

2 participants