Skip to content

feat: prioritize pyproject.toml when installing plugin dependencies#557

Merged
Yeuoly merged 9 commits into
mainfrom
feat/pyproject-compability
Jan 13, 2026
Merged

feat: prioritize pyproject.toml when installing plugin dependencies#557
Yeuoly merged 9 commits into
mainfrom
feat/pyproject-compability

Conversation

@Stream29

@Stream29 Stream29 commented Jan 6, 2026

Copy link
Copy Markdown
Contributor

Description

Accept and prioritize pyproject.toml when installing plugin dependencies.

Type of Change

  • Bug fix
  • New feature
  • Refactor
  • Performance improvement
  • Other

Essential Checklist

Testing

  • I have tested the changes locally and confirmed they work as expected
  • I have added unit tests where necessary and they pass successfully

Additional Information

Please provide any additional context that would help reviewers understand the changes.

@dosubot dosubot Bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Jan 6, 2026
@Stream29
Stream29 requested a review from Yeuoly January 6, 2026 22:58
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @Stream29, 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 introduces a significant enhancement to how Python plugin dependencies are managed by adding support for pyproject.toml. This change allows plugins to define their dependencies using the more modern and standardized pyproject.toml format, with the system intelligently prioritizing it over requirements.txt when both are present. The underlying installation mechanism has been adapted to use uv sync for pyproject.toml and uv pip install for requirements.txt, ensuring robust and efficient dependency resolution. This improves flexibility for plugin developers and keeps the dependency management system up-to-date with current Python ecosystem practices.

Highlights

  • Pyproject.toml Prioritization: The system now prioritizes pyproject.toml over requirements.txt when detecting and installing Python plugin dependencies, aligning with modern Python packaging standards.
  • Dependency Installation Logic: When pyproject.toml is detected, the uv sync command is used for dependency installation. If only requirements.txt is present, the existing uv pip install command is utilized.
  • Plugin SDK Version Patching: The logic responsible for patching the plugin SDK has been updated to correctly extract the dify-plugin SDK version from either pyproject.toml or requirements.txt.
  • Comprehensive Testing: New unit and integration tests have been added to validate the dependency file detection, prioritization, and installation processes across various scenarios, including plugins with pyproject.toml only, requirements.txt only, both, or neither.

🧠 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.

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.

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

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.

Code Review

This pull request introduces support for pyproject.toml as a primary dependency management file for Python plugins, prioritizing it over requirements.txt. The changes include adding new functions to detect the dependency file type (pyproject.toml or requirements.txt), prepare arguments for uv sync (for pyproject.toml) and uv pip install (for requirements.txt), and modify existing functions like InitPythonEnvironment and patchPluginSdk to utilize this new detection logic. Comprehensive unit and integration tests have been added to validate these changes, covering scenarios with pyproject.toml only, requirements.txt only, both files (with pyproject.toml taking precedence), and no dependency files. Review feedback suggests renaming a parameter in getPluginSdkVersion for clarity, improving the robustness of PipExtraArgs parsing in prepareSyncArgs and preparePipArgs to handle spaces in arguments, and optimizing file system access by reducing redundant calls to detectDependencyFileType.

Comment thread internal/core/local_runtime/patch.go Outdated
Comment thread internal/core/local_runtime/setup_python_environment.go
Comment thread internal/core/local_runtime/setup_python_environment.go
Comment thread internal/core/local_runtime/dependency_installation_integration_test.go Outdated
Comment thread internal/core/local_runtime/setup_python_environment.go Outdated
Comment thread internal/core/local_runtime/setup_python_environment.go Outdated
Comment thread internal/core/local_runtime/dependency_installation_test.go Outdated
Comment thread internal/core/local_runtime/dependency_installation_test.go Outdated
Comment thread internal/core/local_runtime/dependency_installation_integration_test.go Outdated
Comment thread internal/core/local_runtime/dependency_installation_integration_test.go Outdated
Comment thread internal/core/local_runtime/dependency_installation_integration_test.go Outdated
Comment thread internal/core/local_runtime/testdata/plugin-with-both/main.py Outdated
Comment thread internal/core/local_runtime/testdata/plugin-with-pyproject/main.py Outdated
@dosubot dosubot Bot added size:XXL This PR changes 1000+ lines, ignoring generated files. and removed size:XL This PR changes 500-999 lines, ignoring generated files. labels Jan 8, 2026
@Stream29

Stream29 commented Jan 8, 2026

Copy link
Copy Markdown
Contributor Author

@Yeuoly Thank you for your detailed review and suggestions.
I'm sorry that I only checked the changes to the main logic carefully and vibed the test without review.

I will improve my code quality.

@Stream29
Stream29 requested a review from Yeuoly January 8, 2026 06:57

@Yeuoly Yeuoly left a comment

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.

LGTM

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Jan 12, 2026
@Yeuoly
Yeuoly merged commit 91c5db6 into main Jan 13, 2026
7 checks passed
@Yeuoly
Yeuoly deleted the feat/pyproject-compability branch January 13, 2026 04:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer size:XXL This PR changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants