From b1394cb49a1a509dee245022c83cd70bc15d562c Mon Sep 17 00:00:00 2001 From: Timur Bazhirov Date: Sat, 12 Sep 2026 11:27:19 -0700 Subject: [PATCH] chore: pin numpy only where pymatgen needs it, and declare scipy for the core numpy<=1.26.4 sat in the core dependencies on pymatgen's behalf, but only the tools extra imports pymatgen. Every downstream package that used made's core alone -- lattices, reciprocal lattices, symmetry points -- was forced down to numpy 1.26 regardless. Worse, pip resolves the conflict with any package that wants numpy 2 by silently backtracking made rather than failing: q3's `pip install -e .[test,relax,build]` landed on mat3ra-made 2024.6.12, two years old and without mat3ra.made.reciprocal, and failed at import time. The pin moves into [tools], next to pymatgen. Verifying that turned up a second declaration bug: basis/__init__.py imports scipy.spatial at load time and material.py imports basis, but scipy was declared only in [tools], so a core install could not import Material. scipy moves to the core dependencies. Checked: - core on numpy 2.5.3 (scipy 1.18): test_cell, test_lattice, test_lattice_type_extended, test_reciprocal_lattice, test_symmetry_points, test_reciprocal_paths -- 76 passed; Material.create, its basis, cell volume and to_dict also work there. - [tools] still resolves numpy 1.26.4 with pymatgen 2024.4.13 and scipy 1.17.1, so pymatgen users are unaffected. Co-Authored-By: Claude Opus 5 Signed-off-by: Timur Bazhirov --- pyproject.toml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 02a974e40..2cf7f8f7e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,14 +18,20 @@ dependencies = [ "mat3ra-code", "mat3ra-esse", "mat3ra-utils>=2026.7.3.post0", - # new verison of numpy==2.0.0 is not handled by pymatgen yet - "numpy<=1.26.4", + "numpy", + # basis/__init__.py imports scipy.spatial at load time, and material.py + # imports basis, so a core install without scipy cannot import Material. + "scipy", ] [project.optional-dependencies] # tracking separately the deps required to use the tools module tools = [ - "scipy", + # pymatgen 2024.4.13 does not handle numpy 2. The pin lives with pymatgen, in + # this extra, rather than in the core dependencies: the core (lattice, + # reciprocal lattice, material, basis) runs on numpy 2, and pinning it there + # forced every downstream package to numpy 1.26 whether or not it used tools. + "numpy<=1.26.4", "pymatgen==2024.4.13", "ase", "pymatgen-analysis-defects==2024.4.23",