setuptools icon indicating copy to clipboard operation
setuptools copied to clipboard

Statically alias distutils-stubs to setuptools._distutils

Open Avasam opened this issue 1 year ago • 1 comments

Summary of changes

Closes https://github.com/pypa/setuptools/issues/4689 This is an alternative to https://github.com/pypa/setuptools/pull/4691. This makes type-checkers and editors see distutils as basically an alias to setuptools.

Advantage:

  • Less maintenance work, these stubs can be autogenerated when updating the vendored stubs (if a file is removed or added)
  • No need to keep in sync with typeshed
  • Static typing follows directly pypa/distutils without concerns with stdlib/distutils compatibility

Disadvantage:

  • Typing isn't as good or as complete as typeshed's (solved by https://github.com/pypa/distutils/pull/329)
  • Typing improvements and fixes need to be done "in source" in pypa/distutils. But this is somewhat already the long-term plan (https://github.com/pypa/setuptools/issues/2345#issuecomment-1627561833 but directly in pypa/distutils)
  • pypa/distutils could accidentally introduce a typing breaking change for setuptools, which probably needs to be ignored with a TODO when updating the vendor.

Pull Request Checklist

  • [x] Changes have tests (existing type-checking tests)
  • [ ] News fragment added in newsfragments/. (no need until this is shipped with setuptools) (See documentation for details)

Avasam avatar Oct 25 '24 16:10 Avasam

I've added a comment at the top of geenrated files to make it clear that they are generated and how to regenerate them.

Avasam avatar Nov 25 '24 18:11 Avasam

I'm currently putting my efforts towards https://github.com/pypa/setuptools/pull/4861 as a solution. Which does the same thing, but autogenerates the stubs on install/wheel creation instead of having them being checked in.

Avasam avatar Apr 21 '25 17:04 Avasam