Skip to content

chore: drop pkg_resources usage and setuptools dependency#2243

Merged
henchaves merged 2 commits intomainfrom
chore/drop-setuptools-dep
Feb 12, 2026
Merged

chore: drop pkg_resources usage and setuptools dependency#2243
henchaves merged 2 commits intomainfrom
chore/drop-setuptools-dep

Conversation

@henchaves
Copy link
Copy Markdown
Member

@henchaves henchaves commented Feb 11, 2026

Description

This PR replaces the usage of pkg_resources in analytics, since it's not availanable anymore for setuptools>=81.

Related Issue

Type of Change

  • 📚 Examples / docs / tutorials / dependencies update
  • 🔧 Bug fix (non-breaking change which fixes an issue)
  • 🥂 Improvement (non-breaking change which improves an existing feature)
  • 🚀 New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to change)
  • 🔐 Security fix

@henchaves henchaves added the Lockfile Temporary label to update pdm.lock label Feb 11, 2026
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @henchaves, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on modernizing the project's dependency management by eliminating the use of the deprecated pkg_resources library for version introspection. It streamlines the core dependencies by removing setuptools where it's no longer directly needed, while carefully managing its presence in test environments to maintain compatibility with other tools.

Highlights

  • Dependency Modernization: The pkg_resources library, which is deprecated, has been entirely removed from the core version retrieval logic, favoring importlib.metadata.
  • Setuptools Dependency Refinement: The direct setuptools dependency for the main project has been removed, while a specific version constraint (setuptools<81) was added to the test dependencies to accommodate transitive requirements like mlflow.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • giskard/init.py
    • Removed the deprecated pkg_resources import and usage for package version retrieval.
    • Updated the version retrieval fallback mechanism to use importlib_metadata.distribution instead of pkg_resources.get_distribution.
  • pyproject.toml
    • Removed setuptools<70 from the main project dependencies.
    • Added setuptools<81 to the test dependency group, explicitly noting its requirement for pkg_resources within mlflow.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions github-actions bot removed the Lockfile Temporary label to update pdm.lock label Feb 11, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request successfully removes the dependency on pkg_resources and setuptools from the project's runtime dependencies, which is a great modernization step. The fallback mechanism for version discovery has been updated to use importlib_metadata. I've included one suggestion to make the version retrieval logic more concise and Pythonic. The changes to pyproject.toml are appropriate, removing setuptools from the core dependencies while pinning it for tests, which is likely a necessary workaround for a dependency like mlflow.

Comment on lines 27 to 30
res = importlib_metadata.version(__name__)
if res is None:
# importlib_metadata can return None https://github.com/python/importlib_metadata/issues/371
# fallback to pkg_resources even if it's deprecated
import pkg_resources

return pkg_resources.get_distribution(__name__).version
return importlib_metadata.distribution(__name__).version
return res
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This block can be made more concise and Pythonic by using the or operator for the fallback. If importlib_metadata.version(__name__) returns None, the expression after or will be evaluated and returned.

Suggested change
res = importlib_metadata.version(__name__)
if res is None:
# importlib_metadata can return None https://github.com/python/importlib_metadata/issues/371
# fallback to pkg_resources even if it's deprecated
import pkg_resources
return pkg_resources.get_distribution(__name__).version
return importlib_metadata.distribution(__name__).version
return res
return importlib_metadata.version(__name__) or importlib_metadata.distribution(__name__).version

@sonarqubecloud
Copy link
Copy Markdown

@henchaves henchaves changed the title drop pkg_resources usage and setuptools dep chore: drop pkg_resources usage and setuptools dependency Feb 11, 2026
@henchaves henchaves self-assigned this Feb 11, 2026
@henchaves henchaves requested a review from mattbit February 11, 2026 12:28
@henchaves henchaves marked this pull request as ready for review February 12, 2026 09:28
@henchaves henchaves merged commit e98fc0b into main Feb 12, 2026
18 checks passed
@henchaves henchaves deleted the chore/drop-setuptools-dep branch February 12, 2026 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants