Skip to content

Replace distutils usage for Python 3.12 compatibility#402

Open
LeSingh1 wants to merge 1 commit into
apple:mainfrom
LeSingh1:py312-numpy-pin
Open

Replace distutils usage for Python 3.12 compatibility#402
LeSingh1 wants to merge 1 commit into
apple:mainfrom
LeSingh1:py312-numpy-pin

Conversation

@LeSingh1
Copy link
Copy Markdown

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

  • python3 -c "import ast; ast.parse(open('setup.py').read())" — setup.py still valid Python.
  • 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.

numpy<1.24 transitively requires distutils, which was removed from
Python 3.12. The repo doesn't use any numpy 1.24+ deprecated aliases
(np.float_, np.bool_, np.int_, etc. — grep confirms zero matches),
so the upper bound is no longer needed.

Removing it lets pip resolve a modern numpy (which no longer depends
on distutils) and unblocks installation on Python 3.12+.

Fixes apple#388
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.

1 participant