Skip to content

Python 3.14 support#4516

Merged
shyuep merged 5 commits intomaterialsproject:masterfrom
DanielYang59:python-3.14
Nov 7, 2025
Merged

Python 3.14 support#4516
shyuep merged 5 commits intomaterialsproject:masterfrom
DanielYang59:python-3.14

Conversation

@DanielYang59
Copy link
Contributor

@DanielYang59 DanielYang59 commented Oct 9, 2025

  • Build wheels for Python 3.14
  • Skip optional dependencies that don't support Python 3.14 yet
  • Waiting for some optional dependencies to support Python 3.14 (at least the actively updated ones)
  • [Need confirm] remove [tool.pdm.dev-dependencies] section from pyproject.toml (seems like the pdm.lock was removed in fb6ba71?)

@DanielYang59 DanielYang59 force-pushed the python-3.14 branch 2 times, most recently from 3e8c458 to 68539ab Compare October 9, 2025 11:48
assert procar.get_occupation(0, "s")[Spin.up] == approx(0.35381249999999997)
assert procar.get_occupation(0, "p")[Spin.up] == approx(1.19540625)
with pytest.raises(ValueError, match="'m' is not in list"):
with pytest.raises(ValueError, match="not in list"):
Copy link
Contributor Author

@DanielYang59 DanielYang59 Oct 9, 2025

Choose a reason for hiding this comment

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

Python 3.14 changed the error message:

>>> uv run -p 3.13 python -c '["a"].index(1)'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
    ["a"].index(1)
    ~~~~~~~~~~~^^^
ValueError: 1 is not in list

>>> uv run -p 3.14 python -c '["a"].index(1)'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
    ["a"].index(1)
    ~~~~~~~~~~~^^^
ValueError: list.index(x): x not in list

@DanielYang59 DanielYang59 marked this pull request as ready for review October 9, 2025 12:53
@DanielYang59 DanielYang59 marked this pull request as draft October 9, 2025 15:07
python: "3.13"
resolution: lowest-direct
python: "3.14"
resolution: highest
Copy link
Contributor Author

@DanielYang59 DanielYang59 Oct 9, 2025

Choose a reason for hiding this comment

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

I think we should test highest resolution in Ubuntu (likely mostly used) as it's the default strategy, so it would be closer to what most users get:

By default, uv tries to use the latest version of each package

"@deprecated",
"def __repr__",
"except ImportError:",
"if TYPE_CHECKING:",
Copy link
Contributor Author

@DanielYang59 DanielYang59 Oct 9, 2025

Choose a reason for hiding this comment

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

It's now excluded by default:

A branch just for type checkers: if TYPE_CHECKING:.

Added in version 7.10.0: the ... and TYPE_CHECKING defaults.

@DanielYang59 DanielYang59 force-pushed the python-3.14 branch 4 times, most recently from 05e4016 to ae9fa91 Compare October 13, 2025 14:59
@DanielYang59 DanielYang59 force-pushed the python-3.14 branch 13 times, most recently from 38be5b2 to a9ff0be Compare October 21, 2025 16:08
fail back to 3.13 for lint as pyright is not installable

revert win to 3.11 for now (cannot recreate locally)

resolve to highest in Ubuntu

fix different err msg in 3.14

➜  temp uv run -p 3.13 test_index.py
Traceback (most recent call last):
  File "/Users/yang/developer/temp/test_index.py", line 1, in <module>
    print(["a"].index(1))
          ~~~~~~~~~~~^^^
ValueError: 1 is not in list

➜  temp uv run -p 3.14 test_index.py
Traceback (most recent call last):
  File "/Users/yang/developer/temp/test_index.py", line 1, in <module>
    print(["a"].index(1))
          ~~~~~~~~~~~^^^
ValueError: list.index(x): x not in list

skip netcdf4 in 3.13

skip more py 3.14 incompatible deps

matcalc seems installable on python 3.13 and 3.14

skip more packages that doesn't support 3.14 now

remove pin for pure python analysis-alloy

remove comment

drop openai pin

unblock h5py

unpin netcdf4
@mkhorton
Copy link
Member

mkhorton commented Nov 4, 2025

@DanielYang59 Thank you for this.

I'm comfortable merging given that the only dependencies that do not yet support Python 3.14 are optional and you have cleanly marked these dependencies with python_version<'3.14', so it should not cause any difficulty for people installing pymatgen. These deps can be updated in a subsequent PR. Would you have any objection to this approach?

@DanielYang59 DanielYang59 marked this pull request as ready for review November 4, 2025 08:57
@DanielYang59
Copy link
Contributor Author

DanielYang59 commented Nov 4, 2025

Hi @mkhorton no problem at all.

Sure we could go with this and I would add another PR once numba and vtk support 3.14

@shyuep shyuep merged commit 94c78f2 into materialsproject:master Nov 7, 2025
44 checks passed
@shyuep
Copy link
Member

shyuep commented Nov 7, 2025

Thanks.

@DanielYang59 DanielYang59 deleted the python-3.14 branch November 7, 2025 18:17
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.

3 participants