Skip to content

Remove almost identical copies of methods already defined in distutils#4996

Merged
jaraco merged 2 commits intopypa:mainfrom
abravalheri:cleanup-distutils
May 14, 2025
Merged

Remove almost identical copies of methods already defined in distutils#4996
jaraco merged 2 commits intopypa:mainfrom
abravalheri:cleanup-distutils

Conversation

@abravalheri
Copy link
Contributor

Summary of changes

There are 2 methods defined for setuptools.Command that just look like copies of the ones defined in distutils.cmd.Command (except for formatting, rust auto-fixes). They seem to have been introduced in #1180.

https://www.diffchecker.com/w6na9oHI/

I am struggling to see the reason why we need to re-define them, unless the code was there just for backward compatibility with old Python versions (i.e. fixes were backported into distutils).

I can see however that this code exists since before Python 3.6...
It definetelly exists in the stdlib in 3.9 (minimum version supported by setuptools):

https://github.com/python/cpython/blob/3.9/Lib/distutils/cmd.py#L207-L215

https://github.com/python/cpython/blob/3.9/Lib/distutils/cmd.py#L223-L242

This PR tries to remove this code duplication.
If there is a reason for the duplication we should see regression tests failing.

Closes

Pull Request Checklist

@abravalheri abravalheri changed the title Remove methods already defined in Distutils Remove almost identical copies of methods already defined in distutils May 12, 2025
@abravalheri
Copy link
Contributor Author

abravalheri commented May 12, 2025

Possibly what happened is that in #1180 there was a subtle difference: it was using six.string_types instead of str.

However, with the move away from Python 2, the method returned to str and then became identical to the stdlib implementation.

@abravalheri abravalheri marked this pull request as ready for review May 12, 2025 17:34
@abravalheri abravalheri requested a review from jaraco May 13, 2025 14:48
@jaraco
Copy link
Member

jaraco commented May 14, 2025

Yeah, there's a lot of code that can be consolidated once we can drop support for distutils from stdlib (which is approximately now, although I need to finish the deprecation/removal). Happy to see this incremental progress. Thanks!

@jaraco jaraco merged commit 1089223 into pypa:main May 14, 2025
22 of 24 checks passed
@abravalheri abravalheri deleted the cleanup-distutils branch May 14, 2025 20:22
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.

2 participants