Skip to content

Remove usage of pkg_resources#2036

Merged
gabrielg5 merged 3 commits intofortra:masterfrom
AdrianVollmer:remove-pkg_resources
Sep 9, 2025
Merged

Remove usage of pkg_resources#2036
gabrielg5 merged 3 commits intofortra:masterfrom
AdrianVollmer:remove-pkg_resources

Conversation

@AdrianVollmer
Copy link
Contributor

Currently, a warning is emitted on each run:

UserWarning: pkg_resources is deprecated as an API. See
https://setuptools.pypa.io/en/latest/pkg_resources.html. The
pkg_resources package is slated for removal as early as 2025-11-30.
Refrain from using this package or pin to Setuptools<81.

This patch removes all usage of that package.

Fixes #1645.

Currently, a warning is emitted on each run:

    UserWarning: pkg_resources is deprecated as an API. See
    https://setuptools.pypa.io/en/latest/pkg_resources.html. The
    pkg_resources package is slated for removal as early as 2025-11-30.
    Refrain from using this package or pin to Setuptools<81.

This patch removes all usage of that package.

Fixes fortra#1645.
@gabrielg5 gabrielg5 self-assigned this Sep 8, 2025
@gabrielg5
Copy link
Collaborator

hey @AdrianVollmer, thanks for this PR!!

been checking it and have only one doubt, related to the except ImportError when trying to import both importlib.resources and importlib.metadata
in which cases should it be needed to catch it? As since py3.7 and py3.8 they seem to be included in the standard library according to python docs
and if so, fallback lib should be included in the requirements file, right?

@gabrielg5 gabrielg5 added enhancement Implemented features can be improved or revised waiting for response Further information is needed from people who opened the issue or pull request labels Sep 8, 2025
@AdrianVollmer
Copy link
Contributor Author

Good catch, we need to add importlib_resources to the requirements.txt. importlib_metadata is already a dependency of Flask, but it has been added in p3.8: https://docs.python.org/3/library/importlib.metadata.html#module-importlib.metadata

Since impacket seems to support python 3.8 and higher, I suppose we can remove the try-exception block in version.py.

importlib.resources in py<3.9 doesn't have files: https://docs.python.org/3/library/importlib.resources.html#importlib.resources.files

So if impacket wants to support py3.8, we need to catch that exception.

I'll push another commit. Let me know what you think.

(Minor remark: the requirements.txt seems unnecessary, as the dependencies are defined in setup.py.)

@gabrielg5
Copy link
Collaborator

Thank you!

mm yeah, that's true. Will check with the other maintainers and update here later today (being py3.8 an already EoL version perhaps we wanna remove it for next impacket version - as matter of fact, unit tests are not being executed for py3.8)

Will let you know later, thanks!

@gabrielg5 gabrielg5 removed the waiting for response Further information is needed from people who opened the issue or pull request label Sep 9, 2025
@gabrielg5
Copy link
Collaborator

hey, yes... we'll remove support for python 3.8 in the next release. We did it in the context of #1965 but didn't reflect this new req in the README (will update that now)

but, yes, I'd remove that exception catching there to simplify the code

Thanks!

@AdrianVollmer
Copy link
Contributor Author

Done! I can squash the commits if you prefer that

@gabrielg5
Copy link
Collaborator

Thank you @AdrianVollmer, merging now!

@gabrielg5 gabrielg5 merged commit 082dca3 into fortra:master Sep 9, 2025
7 checks passed
cjwatson added a commit to cjwatson/impacket that referenced this pull request Jan 8, 2026
It's needed to run `setup.py` itself, but that's not what
`install_requires` is for, and the rest of the package no longer uses it
(since fortra#2036).

I deliberately left the entry in `requirements.txt` in place, since
that's used by CI.
anadrianmanrique pushed a commit that referenced this pull request Jan 13, 2026
It's needed to run `setup.py` itself, but that's not what
`install_requires` is for, and the rest of the package no longer uses it
(since #2036).

I deliberately left the entry in `requirements.txt` in place, since
that's used by CI.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Implemented features can be improved or revised

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pkg_resources is deprecated

2 participants