ml-stable-diffusion icon indicating copy to clipboard operation
ml-stable-diffusion copied to clipboard

Replace distutils usage for Python 3.12 compatibility

Open LeSingh1 opened this issue 6 months ago • 0 comments

Summary

Addresses #388. The repo doesn't import distutils directly — the dependency comes in transitively through the numpy<1.24 pin in setup.py. NumPy versions older than 1.24 import distutils internally, which Python 3.12 removed from the stdlib. So pip install . fails on Python 3.12.

This relaxes the upper bound to allow a modern numpy. NumPy 1.24+ no longer touches distutils, so the install path becomes 3.12-compatible.

Safety check

Searched the codebase for any of the numpy aliases removed in 1.24 (np.float_, np.bool_, np.int_, np.complex_, np.object_, np.str_, np.long):

$ grep -rn 'np\.\(float_\|bool_\|int_\|complex_\|object_\|str_\|long\)\b' --include='*.py' .
(no matches)

All numpy usage in the project sticks to explicit-bit-width types (np.float16, np.float32, np.int32) which are stable across the 1.24 → 2.x transition. Sibling pinned deps (coremltools>=8.0, diffusers[torch]==0.30.2, transformers==4.44.2, torch) all support modern numpy.

Test plan

  • [x] python3 -c "import ast; ast.parse(open('setup.py').read())" — setup.py still valid Python.
  • [x] Grep for deprecated numpy aliases in *.py — zero matches.

Scope

One-line change. I intentionally did not touch the CMake/Python-detection/wheel-naming items from #2376; they need separate consideration and were called out as needing maintainer discussion.

Risks / follow-ups

  • If a hard upper cap is preferred for reproducibility, numpy<3.0 would still cover both 1.24+ and 2.x and unblock 3.12. Happy to switch.
  • The Programming Language :: Python :: 3.7/3.8/3.9 classifiers in setup.py are now stale (3.7 and 3.8 are EOL upstream). Not touched in this PR.

LeSingh1 avatar May 18 '26 01:05 LeSingh1