Update djblets.extensions to drop usage of pkg_resources.

Review Request #13100 — Created June 6, 2023 and submitted

Information

Djblets
release-4.x

Reviewers

pkg_resources has long been deprecated, but until recently has
remained consistent in behavior. The replacements can be found in
importlib.resources, importlib.metadata, and packaging modules.

Over time, pkg_resources began to wrap newer versions of some of these
modules, breaking backwards-compatibility. While not ideal, it's
incentive to move toward the modern packaging support in Python.

This change updates djblets.extensions to (almost) fully move to these
new packages. In some cases, the updates are fairly straight-forward,
but in others there's some rewriting that needs to take place:

  • Version parsing is now strict, so we need to better bullet-proof
    against parsing issues.

  • Metadata is now handled by importlib.metadata, allowing us to remove
    a bunch of old code.

  • The old extension package installation code had to be wired off. This
    was never truly supported, couldn't install wheels, and had a big
    scary warning in the docs, so we're not going through a deprecation
    cycle for this.

The packaging support still uses pkg_resources, as that's what
setuptools.Command uses. This will need to be converted in time.

There may be some fallout from this change, as there may be behavioral
differences in results/error handling in some cases. If any issues come
up from this change, we'll need to identify the differences and
proactively address them.

Djblets and Review Board unit tests pass. Tested on Python 3.7 and 3.12
with the latest versions of packaging, importlib_metadata, and
importlib_resources packages.

Tested Review Board with loading and using extensions (integrations,
Review Bot, and Power Pack).

Summary ID
Update djblets.extensions to drop usage of pkg_resources.
`pkg_resources` has long been deprecated, but until recently has remained consistent in behavior. The replacements can be found in `importlib.resources`, `importlib.metadata`, and `packaging` modules. Over time, `pkg_resources` began to wrap newer versions of some of these modules, breaking backwards-compatibility. While not ideal, it's incentive to move toward the modern packaging support in Python. This change updates `djblets.extensions` to (almost) fully move to these new packages. In some cases, the updates are fairly straight-forward, but in others there's some rewriting that needs to take place: * Version parsing is now strict, so we need to better bullet-proof against parsing issues. * Metadata is now handled by `importlib.metadata`, allowing us to remove a bunch of old code. * The old extension package installation code had to be wired off. This was never truly supported, couldn't install wheels, and had a big scary warning in the docs, so we're not going through a deprecation cycle for this. The packaging support still uses `pkg_resources`, as that's what `setuptools.Command` uses. This will need to be converted in time. There may be some fallout from this change, as there may be behavioral differences in results/error handling in some cases. If any issues come up from this change, we'll need to identify the differences and proactively address them.
ba9da8c7ffb2159849263287abdf49d2f405d947
Description From Last Updated

Is this really something we want to do for 3.x?

daviddavid

'typing.Dict' imported but unused Column: 1 Error code: F401

reviewbotreviewbot

line too long (80 > 79 characters) Column: 80 Error code: E501

reviewbotreviewbot

'importlib_resources' imported but unused Column: 1 Error code: F401

reviewbotreviewbot

'pathlib.PosixPath' imported but unused Column: 1 Error code: F401

reviewbotreviewbot

'importlib_resources' imported but unused Column: 1 Error code: F401

reviewbotreviewbot
Checks run (1 failed, 1 succeeded)
flake8 failed.
JSHint passed.

flake8

chipx86
david
  1. 
      
  2. Is this really something we want to do for 3.x?

    1. No, I really don't. I had hit regressions due to modern pkg_resources pulling in modern packaging and importlib stuff, but perhaps I can work around those in a less invasive way for now.

      pkg_resources is strongly marked as deprecated, throwing warnings on access, so I'm a little concerned about whether these versions will be able to be installed long-term (and I don't want to have to cap setuptools, as packages probably shouldn't be capping package installation code), but maybe that's just a problem for later.

  3. 
      
chipx86
david
  1. Ship It!
  2. 
      
chipx86
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-4.x (6472c13)
Loading...