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

Use importlib in favor of deprecated pkg_resources #5048

Merged
merged 16 commits into from Aug 1, 2023

Conversation

jayceslesar
Copy link
Contributor

Description

Please include a concise summary, in clear English, of the changes in this pull request. If it closes an issue, please mention it here.

Bad practice to be using just import pkg_resources instead of import importlib.resources as pkg_resources, as this led to my org having trouble installing and explicitly needing to add setuptools as a dependency which doesnt quite make sense. This is a drop in replacement and has existed since python 3.7.

The issue arose from having gradio installed in an application my org is developing, and running it resulted in

gradio/flagging.py", line 17, in <module>
    import pkg_resources
ModuleNotFoundError: No module named 'pkg_resources'

This is a drop in replacement.

Closes: #(issue)
N/A

🎯 PRs Should Target Issues

Before your create a PR, please check to see if there is an existing issue for this change. If not, please create an issue before you create this PR, unless the fix is very small.

Not adhering to this guideline will result in the PR being closed.

Tests

  1. PRs will only be merged if tests pass on CI. To run the tests locally, please set up your Gradio environment locally and run the tests: bash scripts/run_all_tests.sh

  2. You may need to run the linters: bash scripts/format_backend.sh and bash scripts/format_frontend.sh

@vercel
Copy link

vercel bot commented Jul 31, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
gradio ✅ Ready (Inspect) Visit Preview Aug 1, 2023 4:21pm

@abidlabs
Copy link
Member

Thanks @jayceslesar for opening the PR, indeed pkg_resources is deprecated so we should migrate

@gradio-pr-bot
Copy link
Contributor

gradio-pr-bot commented Jul 31, 2023

🦄 change detected

This Pull Request includes changes to the following packages.

Package Version
gradio minor
  • Maintainers can select this checkbox to manually select packages to update.

With the following changelog entry.

Use importlib in favor of deprecated pkg_resources

Maintainers or the PR author can modify the PR title to modify this entry.

Something isn't right?

  • Maintainers can change the version label to modify the version bump.
  • If the bot has failed to detect any changes, or if this pull request needs to update multiple packages to different versions or requires a more comprehensive changelog entry, maintainers can update the changelog file directly.

@gradio-pr-bot
Copy link
Contributor

gradio-pr-bot commented Jul 31, 2023

All the demos for this PR have been deployed at https://huggingface.co/spaces/gradio-pr-deploys/pr-5048-all-demos


You can install the changes in this PR by running:

pip install https://gradio-builds.s3.amazonaws.com/b62cb721143dde5a7f86ae79d7a1c70efbb09983/gradio-3.39.0-py3-none-any.whl

@jayceslesar
Copy link
Contributor Author

@abidlabs going to be a little more involved, I will patch the rest of pkg_resources stuff

@jayceslesar jayceslesar changed the title fix(pkg_resources): use importlib.resources fix(pkg_resources): use importlib in favor of pkg_resources Jul 31, 2023
@jayceslesar
Copy link
Contributor Author

@abidlabs should be good now!

@abidlabs
Copy link
Member

Thanks @jayceslesar! It turns out that we didn't even need that version check in flagging.py so I've removed it and made a few other tweaks. Will merge in once CI passes. Thanks again

@jayceslesar
Copy link
Contributor Author

Absolutely! Ill see what I can do about getting types in a good spot to get CI to pass

@abidlabs abidlabs changed the title fix(pkg_resources): use importlib in favor of pkg_resources use importlib in favor of pkg_resources Aug 1, 2023
@abidlabs abidlabs changed the title use importlib in favor of pkg_resources Use importlib in favor of deprecated pkg_resources Aug 1, 2023
@jayceslesar
Copy link
Contributor Author

@abidlabs thanks for the cleanup!

@abidlabs
Copy link
Member

abidlabs commented Aug 1, 2023

No worries! I'll fix the final typing issues and then merge once CI passes

@abidlabs
Copy link
Member

abidlabs commented Aug 1, 2023

Ok I think we should be good to go. I've just asked @yvrjsharma to test on a Windows machine as well to make sure all the paths resolve correctly

@yvrjsharma
Copy link
Collaborator

I have just run couple of demos locally on my Windows machine, and all work fine.

@abidlabs
Copy link
Member

abidlabs commented Aug 1, 2023

Thanks @jayceslesar and @yvrjsharma will merge in after CI passes

@abidlabs abidlabs merged commit 0b74a15 into gradio-app:main Aug 1, 2023
12 checks passed
@pngwn pngwn mentioned this pull request Aug 1, 2023
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

Successfully merging this pull request may close these issues.

None yet

4 participants