Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 14, 2025

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