Skip to content
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

Re-implement newer and newer_group to avoid deprecated distutils.util #2141

Closed
wants to merge 2 commits into from

Conversation

Avasam
Copy link
Collaborator

@Avasam Avasam commented Nov 1, 2023

Work towards #2119

setuptools.util does not currently re-expose methods from distutils.util. And may not want to do so (see discussion in pypa/setuptools#4069 ). This PR explores re-implementing newer and newer_group methods to avoid depending on deprecated distutils.util.
There might be a better location to move these methods.

The two usages of newer_group in setup.py also come with a comment suggesting that this method may not be necessary and possibly improved/removed in the future. To me it looks like a build optimization to not regenerate certain files. I would like your thoughts on this @mhammond

@mhammond
Copy link
Owner

mhammond commented Nov 2, 2023

Why the TestLoader as TestLoader?

But in general, I guess this is fine if there's an actual problem, but I'm not sure this is worthwhile until the functions no longer work. What is the actual impact of not taking this at the current time?

@Avasam
Copy link
Collaborator Author

Avasam commented Nov 2, 2023

Why the TestLoader as TestLoader?

Explicit re-export since it is used elsewhere and not in this module. Probably better left for a future static checking PR.

What is the actual impact of not taking this at the current time?

Honestly, minor to none in the short-term:

  • Until .exe installers or Python 3.9 support is dropped, distutils will have some presence in code due to bdist_wininst.
  • Python 3.12+ requires that we import setuptools first.
  • There are static analysis issues with distutils due to setuptool's monkeypatching. But those also won't be relevant to pywin32 until a couple PRs past Basic type-checking with mypy and pyright #2102 in supporting static typing.

I was looking at what is possible to migrate now to help static-checking efforts and deprecated/obsolete code update. And if you had any more insight or input on why these functions are used and if they're there to stay. But this may be deferred to after bdist_wininst removal (see first point)

@Avasam
Copy link
Collaborator Author

Avasam commented Nov 3, 2023

Also wondering if there's a common module I could move these to that can be used both by setup.py and by tests.

@mhammond
Copy link
Owner

mhammond commented Nov 3, 2023

both by setup.py and by tests.

One doesn't exist already - setup.py would need to do sys.path mangling to make that work as it can't assume such a module already was installed (and if it does, it could not assume it's the "correct" version)

@Avasam Avasam marked this pull request as draft November 3, 2023 16:46
@Avasam
Copy link
Collaborator Author

Avasam commented Nov 8, 2023

setuptools will re-export distutils.dep_util as setuptools.modified. I'd like to keep this here exploratory PR as-is for posterity. I'll re-open a new one after the next setuptools release.

@Avasam Avasam closed this Nov 8, 2023
@Avasam Avasam deleted the Avoid-distutils.util branch November 8, 2023 18:43
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