python / cpython

The Python programming language
https://www.python.org
Other
63.77k stars 30.54k forks source link

Meta issue for cleaning up import system cruft #97850

Open warsaw opened 2 years ago

warsaw commented 2 years ago

This is a meta issue tracking all the things that need to be cleaned up in the import system. From removing long deprecated APIs to migrating internal access to __spec__, we'll have several task lists for each related set of clean ups.

@brettcannon @ericsnowcurrently for visibility.

Removing deprecated APIs

Over in What's New for Python 3.11 there's a long list of things that have been deprecated long enough that they can be removed in Python 3.12. Here's that task list for tracking purposes. Watch for linked PRs (maybe one big one or many small ones -- we'll see!).

@brettcannon @ericsnowcurrently for visibility.

Update docs

Missing deprecations

Here's a list of related APIs that have not yet been deprecated, but should be. We'll deprecate them in 3.12 and remove them in 3.14.

Other:

sobolevn commented 2 years ago

I've removed importlib.utils.set_loader, importlib.utils.set_package, and importlib.utils.module_for_loader from importlib.utils in https://github.com/python/cpython/pull/97898 🎉

sobolevn commented 2 years ago

I've created a PR: https://github.com/python/cpython/pull/98520 to complete these two tasks:

  • [ ] pkgutil.find_loader()
  • [ ] pkgutil.get_loader() (or it needs to be reimplemented to not use find_loader())
brettcannon commented 2 years ago

FYI https://github.com/python/cpython/issues/64138 is a tracking issue for pkgutil all up.

warsaw commented 1 year ago

From the meta checklist:

Deprecate pkgutil.find_loader()

I kind of think we're okay here, at least for 3.12. This uses importlib.util.find_spec() so I feel like it's not so urgent to deprecate and actually probably has some utility.

Deprecate pkgutil.get_loader()

Similarly, I'm not sure this even needs to be deprecated. It is implemented in terms of the above, and thus find_spec(), and it has some potentially useful wrapper semantics.

I'm going to mark both issues as complete and not deprecate it in 3.12.

warsaw commented 1 year ago

@brettcannon @ericsnowcurrently - I think this PR is ready for review. I feel good that we've implemented all the removals we need for 3.12. Like the other issues, we can address the doc updates after beta 1.

warsaw commented 1 year ago

The removal branch has been merged, but I'm leaving this meta issue open for now so we can address the documentation checklist during the beta cycle.

ericsnowcurrently commented 1 year ago

Thanks again for tackling this, @warsaw!

hugovk commented 1 year ago

[For the imp module, I created issues for most of the 71 projects in the PyPI top 5k (listed at python/cpython#98573 (comment)), where I could find their tracker. And some already had issues.

I've checked off projects which had already fixed but not yet released, or have fixed since I created the issue, or where the project is unmaintained or otherwise abandoned and a fix is unlikely in any case.

Currently 24/71 (34%) are checked off. In the issue I pointed to the 3.11 imp docs which have suggestions of how to upgrade each functions/constants, and most seemed fine with that so far, except for one noting imp.load_source has no suggestions.


Edit 2024-10-17: 57/71 (80%)

mdmintz commented 1 year ago

Due to nose being unmaintained (number 41 in your list), that's why there's pynose now (number 55 in your list). It's a complete drop-in replacement for all occurrences. (Let me know if that isn't the case.)

hugovk commented 1 year ago

Edit 2023-11-05: 36/71 (52%)

We're now over 50% of those in the checklist.

hugovk commented 5 months ago

Edit 2024-06-07: 55/71 (78%)

We're now at 78% (fixed or unmaintained/abandoned).