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

Replace deprecated imp module with importlib #13

Closed
hugovk opened this issue Apr 29, 2023 · 2 comments
Closed

Replace deprecated imp module with importlib #13

hugovk opened this issue Apr 29, 2023 · 2 comments

Comments

@hugovk
Copy link

hugovk commented Apr 29, 2023

This project uses the imp module which has been deprecated since Python 3.4 and removed in 3.12:

Python 3.12 is set for release on 2023-10-02 and this library is one of the top 5,000 most-downloaded from PyPI.

Please could you upgrade to use importlib? The imp docs have suggestions on what to use to replace each function and constant.

@facelessuser
Copy link
Owner

In general, this library should not be used as all Python versions where this is useful are now "end of life". Python 3.7+ do not need this, and even 3.7 is close to EOL.

Most libraries should only conditionally include this as a dependency if they choose to support really old Python < 3.7.

With that said it is fairly trivial to update the setup script to use importlib as I've done so in some other projects. I believe this will work.

def get_version():
    """Get version_info without importing the entire module."""

    import importlib.util

    path = os.path.join(os.path.dirname(__file__), "pep562", "__meta__.py")
    spec = importlib.util.spec_from_file_location("__meta__", path)
    module = importlib.util.module_from_spec(spec)
    spec.loader.exec_module(module)
    return module.__version_info__._get_dev_status()

PRs are also welcome. If we do this, this is likely to be the last release of this project as all Python versions that depend upon this are now EOL.

@hugovk
Copy link
Author

hugovk commented Apr 29, 2023

Thanks for the reply. I think it's acceptable to say 3.12 isn't supported.

In fact, I now see the README says this:

Once Python 3.6 is end of life, this module will be irrelevant and will no longer receive active support.

And 3.6 has been EOL since 2021-12-23.

Feel free to close this, and thank you for your time :)

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

No branches or pull requests

2 participants