Skip to content

[python-package] Bump minimum supported Python version to 3.10 - #7276

Merged
jameslamb merged 8 commits into
masterfrom
bump-3.10
May 15, 2026
Merged

jameslamb merged 8 commits into
masterfrom
bump-3.10

Conversation

@borchero

Copy link
Copy Markdown
Member

Motivation

Python 3.9 reached EOL on Oct 31, 2025.

Dropping support for it will simplify bumping the floor on some dependencies required for #7275.

@jameslamb jameslamb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Support this, thanks!

We'll probably want to bump the oldest-supported-versions test versions here:

# oldest versions of dependencies published after
# minimum supported Python version's first release,
# for which there are wheels compatible with the
# python:{version} image

And might end up needing to bump some things in ci-core-py310.txt.

Just leaving a blocking review until CI is passing, @ me when you're ready for another review and I'll come look at whatever was necessary to get this working.

Comment thread python-package/pyproject.toml Resolved
@jameslamb jameslamb added in progress blocking CI will be unsuccessful until this is resolved. breaking and removed blocking CI will be unsuccessful until this is resolved. labels May 14, 2026
@borchero

borchero commented May 14, 2026 •

Copy link
Copy Markdown
Member Author

@jameslamb have you seen an issue like the one in https://github.com/lightgbm-org/LightGBM/actions/runs/25888309590/job/76085467194?pr=7276 before?

__________ ERROR collecting tests/python_package_test/test_sklearn.py __________
ImportError while importing test module '/__w/LightGBM/LightGBM/tests/python_package_test/test_sklearn.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/opt/miniforge/envs/test-env/lib/python3.10/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/python_package_test/test_sklearn.py:14: in <module>
    from scipy.stats import spearmanr
/opt/miniforge/envs/test-env/lib/python3.10/site-packages/scipy/stats/__init__.py:441: in <module>
    from .stats import *
/opt/miniforge/envs/test-env/lib/python3.10/site-packages/scipy/stats/stats.py:43: in <module>
    from . import distributions
/opt/miniforge/envs/test-env/lib/python3.10/site-packages/scipy/stats/distributions.py:8: in <module>
    from ._distn_infrastructure import (rv_discrete, rv_continuous, rv_frozen)
/opt/miniforge/envs/test-env/lib/python3.10/site-packages/scipy/stats/_distn_infrastructure.py:24: in <module>
    from scipy import optimize
/opt/miniforge/envs/test-env/lib/python3.10/site-packages/scipy/optimize/__init__.py:400: in <module>
    from .optimize import *
/opt/miniforge/envs/test-env/lib/python3.10/site-packages/scipy/optimize/optimize.py:36: in <module>
    from ._numdiff import approx_derivative
/opt/miniforge/envs/test-env/lib/python3.10/site-packages/scipy/optimize/_numdiff.py:8: in <module>
    from ._group_columns import group_dense, group_sparse
E   ImportError: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.26' not found (required by /opt/miniforge/envs/test-env/lib/python3.10/site-packages/scipy/optimize/_group_columns.cpython-310-x86_64-linux-gnu.so)

Claude suggested

# ensure the conda env ships its own libstdc++ so that conda-built
# .so files (e.g. scipy) find the GLIBCXX symbols they were linked
# against, even on base images with an older system libstdc++
# (e.g. manylinux_2_28, which lacks GLIBCXX_3.4.26)
libstdcxx-ng>=12

let's see, what it does


UPDATE: doesn't help

@jameslamb

Copy link
Copy Markdown
Member

Yep this GLIBC / GLIBCXX issues like this can happen when you mix packages across distributions (in this case, compiler toolchain + MPI libraries from Alma Linux 8 or whatever that manylinux image is based on).

I'm guessing the root cause here is some mix of:

  • now this Python 3.10 job is using the pins to old packages that were in ci-core-py39.txt (since you just renamed the file but didn't update the pins)
  • the MPI libraries we yum install are linked against a different GLIBCXX

All the other Python 3.10 Linux jobs are failing (like this one in the same image), so it's gotta be something specific to MPI.

Let's try just updating to Python 3.11 in that failing job. If that fixes it, let's not worry any more about it any more. I don't think it's critical to cover the full range of Python versions, compilers, etc. for the MPI build. We rarely receive user questions about it, I'm not sure if anyone uses it 🀷🏻

@borchero

Copy link
Copy Markdown
Member Author

All right, green CI @jameslamb πŸ˜„

@jameslamb jameslamb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I'm comfortable with the bumps in these pins, they all still allow a couple years' worth of versions of our dependencies. Appreciate the care you took to make the changes so minimal.

I left one suggestion on that new ruff finding, it can be a follow-up. I'll merge this right now.

[tool.ruff.lint]
ignore = [
# (flake8-bugbear) Zip calls without an explicit strict parameter
"B905",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh this one is useful for correctness! I wouldn't want to just skip it.

From https://docs.astral.sh/ruff/rules/zip-without-explicit-strict/

By default, if the iterables passed to zip are of different lengths, the resulting iterator will be silently truncated to the length of the shortest iterable. This can lead to subtle bugs.

I glanced at git grep -E 'zip\(' and I don't think there are cases where we're intentionally relying on that behavior. If adding strict=True breaks anything in CI, that probably means it's found a bug.

I'm ok with merging this PR as-is so you don't have to go through more commits and CI runs, but would you please put up a follow-up reverting this and adding strict=True everywhere?

@jameslamb
jameslamb merged commit fe26737 into master May 15, 2026
59 checks passed
@jameslamb
jameslamb deleted the bump-3.10 branch May 15, 2026 15:15
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 this pull request may close these issues.

2 participants