installer
installer copied to clipboard
scripts.py utilizes the deprecated read_binary function from importlib.resources.
When building for Fedora I noticed a deprecation warning:
DeprecationWarning: read_binary is deprecated. Use files() instead. Refer to https://importlib-resources.readthedocs.io/en/latest/using.html#migrating-from-legacy for migration advice.
As mentioned in the docs it links to, you cannot really take advantage of this deprecation warning without dropping compat for 50% of supported python versions. Honestly it always seemed odd to me that it's a warning at all (but the stability of importlib.resources is a separate topic).
The current spot of use is:
https://github.com/pypa/installer/blob/8105b1d3a20f19d5a9026ede363015fbbd644ebc/src/installer/scripts.py#L6
I guess we could do something like:
if sys.version_info >= (3, 9):
from importlib.resources import files
def read_binary(package, file_path):
return (files(package) / file_path).read_binary()
else:
from importlib.resources import read_binary
It's dumb that I'll have to do this, but enough has been said about how messily the importlib.resources/importlib.metadata have handled backwards compatibility.
This has become the case with Python 3.13 from which read_binary was removed. We are already hit by this as downstream packagers in Fedora Linux during the early integration with Python 3.13 alpha 1.
I opened a PR: https://github.com/pypa/installer/pull/201