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

scripts.py utilizes the deprecated read_binary function from importlib.resources. #132

Closed
stratakis opened this issue Aug 3, 2022 · 4 comments · Fixed by #201
Closed
Labels
component: scripts Related to script generation type: task Something that needs to be done that is not a bug or feature

Comments

@stratakis
Copy link

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.
@eli-schwartz
Copy link
Contributor

eli-schwartz commented Aug 3, 2022

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).

@pradyunsg pradyunsg added the type: task Something that needs to be done that is not a bug or feature label Nov 25, 2022
@pradyunsg
Copy link
Member

The current spot of use is:

from importlib.resources import read_binary

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.

@pradyunsg pradyunsg added the component: scripts Related to script generation label Dec 13, 2022
@befeleme
Copy link

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.

@edgarrmondragon
Copy link
Contributor

I opened a PR: #201

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: scripts Related to script generation type: task Something that needs to be done that is not a bug or feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants