Replace pkg_resources with os.path for config file lookup#5510
Open
Mr-Neutr0n wants to merge 2 commits intofacebookresearch:mainfrom
Open
Replace pkg_resources with os.path for config file lookup#5510Mr-Neutr0n wants to merge 2 commits intofacebookresearch:mainfrom
Mr-Neutr0n wants to merge 2 commits intofacebookresearch:mainfrom
Conversation
pkg_resources is deprecated and will be removed in setuptools 81 (scheduled for 2025-12). Replace pkg_resources.resource_filename with a simple os.path.join using __file__ since the configs directory is already symlinked/copied into model_zoo during package installation. Fixes facebookresearch#5494
Author
|
bump — any thoughts on this? pkg_resources is deprecated and this swaps it for a simpler os.path approach. lmk if there's anything i should change |
Since pkg_resources is no longer imported anywhere in the codebase, remove it from the isort configuration as well.
Author
|
Friendly bump! Let me know if there's anything I should update or improve to help move this forward. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
pkg_resourcesfrom setuptoolspkg_resources.resource_filename()with simpleos.path.join()using__file__Related Issue
Fixes #5494
Technical Details
Since the
configsdirectory is already symlinked/copied intodetectron2/model_zoo/during package installation viapackage_data, we can simply useos.path.dirname(__file__)to locate it at runtime. This is simpler and more maintainable than usingimportlib.resources.Test plan
from detectron2 import model_zooworks without warningmodel_zoo.get_config_file()returns correct paths