Skip to content

MAINT: remove numpy.distutils - #30340

Merged
charris merged 5 commits into
numpy:mainfrom
mattip:remove-distutils
Dec 2, 2025
Merged

MAINT: remove numpy.distutils#30340
charris merged 5 commits into
numpy:mainfrom
mattip:remove-distutils

Conversation

@mattip

@mattip mattip commented Dec 1, 2025

Copy link
Copy Markdown
Member

Remove numpy.distutils after the 2.5 branch

  • remove the module
  • move numpy.distutils/conv_template.py to numpy/_build_utils/conv_template.py
  • move numpy/distutils/checks to numpy/_core/src/_simd/checks
  • remove references from documentation, tests, typing stubs.
  • inline a helper function that used importlib

The tricky part was removing the f2py/_backend and adjusting the f2pye script. I tried to check spin docs, spin test, spin check-docs, spin check-tutorials.

@mattip mattip left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

A few questions for the reviewers. Also: are there tests that were in distutils that should be preserved?

Comment thread doc/neps/scope.rst
Comment thread doc/source/conf.py Outdated
Comment thread doc/source/f2py/buildtools/distutils.rst Outdated
Comment thread doc/source/f2py/usage.rst
@@ -1,219 +0,0 @@
.. _numpy-distutils-refguide:

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Should this be a stub so outside links are not broken?

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.

Hmm, don't know. Who might have links?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I checked SciPy, they don't.

default keyword-only argument specifies an object to return if
the provided iterable is empty.
With two or more arguments, return the largest argument.
With two or more ...arguments, return the largest argument.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Not needed for the deprecation, but is needed for a different error message on Python3.14

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.

Needs a space before "arguments".

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

No, then the old formatting breaks. The two messages are

With two or more arguments, return the largest argument

vs

With two or more positional arguments, return the largest argument

If I add a space on either side, then the old message fails since it does not have two spaces.

Comment thread numpy/__init__.py Outdated
Comment thread numpy/f2py/f2py2e.py Outdated
Comment thread numpy/f2py/_backends/_distutils.py
@jorenham jorenham changed the title remove numpy.distutils MAINT: remove numpy.distutils Dec 1, 2025
Comment thread numpy/f2py/f2py2e.py
@jorenham

jorenham commented Dec 1, 2025

Copy link
Copy Markdown
Member

I just noticed that it's 22k LOC 🤯

@charris

charris commented Dec 1, 2025

Copy link
Copy Markdown
Member

close/reopen

@charris charris closed this Dec 1, 2025
@charris charris reopened this Dec 1, 2025
@charris

charris commented Dec 1, 2025

Copy link
Copy Markdown
Member

Looks like you need to rebase this to get circleci to run with Python 3.12.

@mattip

mattip commented Dec 2, 2025

Copy link
Copy Markdown
Member Author

Rebased

@charris

charris commented Dec 2, 2025

Copy link
Copy Markdown
Member

Can confirm that circleci ran with Python 3.12.

Comment thread numpy/f2py/f2py2e.py
"--fcompiler cannot be used with meson,"
"set compiler with the FC environment variable\n"
)
for s in del_list:

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.

Heh, del_list is empty AFAICT.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah, this all needs a cleanup but I would prefer to leave it for #30353

@rgommers rgommers 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.

A bunch of little things to finalize, but overall looks great (and a very satisfying PR:)). Thanks @mattip!

Comment thread doc/neps/scope.rst Outdated
Comment thread doc/source/dev/depending_on_numpy.rst Outdated
Comment thread doc/source/f2py/buildtools/distutils-to-meson.rst Outdated
Comment thread doc/source/f2py/buildtools/distutils-to-meson.rst Outdated
Comment thread doc/source/f2py/buildtools/distutils-to-meson.rst Outdated
Comment thread doc/source/reference/distutils_status_migration.rst Outdated
Comment thread doc/source/reference/distutils_status_migration.rst Outdated
Comment thread numpy/f2py/diagnose.py Outdated
Comment thread numpy/f2py/f2py2e.py Outdated
Comment thread numpy/__init__.py Outdated

@mattip mattip left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks for the review

Comment thread doc/neps/scope.rst
Comment thread doc/source/f2py/usage.rst
Comment thread numpy/f2py/tests/test_f2py2e.py
Comment thread numpy/f2py/diagnose.py Outdated
Comment thread numpy/f2py/f2py2e.py
"--fcompiler cannot be used with meson,"
"set compiler with the FC environment variable\n"
)
for s in del_list:

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah, this all needs a cleanup but I would prefer to leave it for #30353

Comment thread numpy/f2py/f2py2e.py Outdated
Comment thread doc/source/reference/distutils_status_migration.rst Outdated
@mattip

mattip commented Dec 2, 2025

Copy link
Copy Markdown
Member Author

I repurposed test_no_distutils_backend in the f2py tests to make sure f2py errors when

@charris
charris merged commit 489c0ea into numpy:main Dec 2, 2025
76 checks passed
@charris

charris commented Dec 2, 2025

Copy link
Copy Markdown
Member

Let's get this in. Thanks Matti.

@rgommers rgommers added this to the 2.5.0 Release milestone Dec 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants