Skip to content

fix(deps): sync requirements.txt with pyproject.toml - #10705

Merged
mantoujun12 merged 4 commits into
AstrBotDevs:masterfrom
inertialobs:fix/deps-sync-requirements-txt
Dec 1, 2026
Merged

mantoujun12 merged 4 commits into
AstrBotDevs:masterfrom
inertialobs:fix/deps-sync-requirements-txt

Conversation

@inertialobs

@inertialobs inertialobs commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

pyproject.toml and requirements.txt had drifted. Commit #8837 raised
faiss-cpu to >=1.14.3 in pyproject.toml but left requirements.txt
at >=1.12.0.

This matters because requirements.txt is consumed by the Docker build,
the smoke test workflow, and the in-app updater. The two install paths
could therefore resolve different FAISS versions.

Modifications / 改动点

  • Align faiss-cpu in requirements.txt with pyproject.toml
    (>=1.12.0 -> >=1.14.3).

  • This is NOT a breaking change. / 这不是一个破坏性变更。

Screenshots or Test Results / 运行截图或测试结果

Have no behavior change to the main program

Checklist / 检查清单

  • 😊 If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc.
    / 如果 PR 中有新加入的功能,已经通过 Issue / 邮件等方式和作者讨论过。

  • 👀 My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above.
    / 我的更改经过了良好的测试,并已在上方提供了“验证步骤”和“运行截图”。

  • 📚 I checked the affected WebUI instructions and screenshots in docs/zh and docs/en against the changed navigation, page structure, and labels, and updated them in this PR (or explained why no documentation update is needed). For renamed, moved, or merged entry points, I included an old entry → new entry mapping in the documentation and changelog.
    / 我已对照变化后的 WebUI 入口、页面结构和术语,核对并在本 PR 中更新 docs/zh 和 docs/en 的相关操作说明与截图(或说明无需更新文档的原因)。入口改名、移动或合并时,已在文档和 changelog 中补充 旧入口 → 新入口 对照。
    没有对应文档需要更新

  • 🤓 I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations in requirements.txt and pyproject.toml.
    / 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到 requirements.txt 和 pyproject.toml 文件相应位置。

  • 😮 My changes do not introduce malicious code.
    / 我的更改没有引入恶意代码。

Summary by Sourcery

Synchronize runtime dependency declarations and enforce consistency between requirements.txt and pyproject.toml.

Bug Fixes:

  • Align the faiss-cpu requirement across requirements.txt and pyproject.toml to ensure all installation paths use version 1.14.3 or newer.

Enhancements:

  • Add automated checks that keep dependency package sets, extras, version constraints, and environment markers synchronized between the two dependency files.

Tests:

  • Add dependency synchronization tests covering normalized requirements and reporting missing, unexpected, or mismatched dependencies.

@sourcery-ai sourcery-ai 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.

Hey - I've found 3 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="tests/test_dependency_sync.py" line_range="41" />
<code_context>
+    """
+    dependencies = {}
+    for entry in entries:
+        requirement = Requirement(entry)
+        dependencies[canonicalize_name(requirement.name)] = (
+            frozenset(requirement.extras),
</code_context>
<issue_to_address>
**Valid pip directives fail the check**

When requirements.txt contains a supported pip option or nested-requirements directive, `Requirement(entry)` parses every non-comment line as a package requirement, so a valid pip directive such as `--extra-index-url` or `-r base.txt` raises a parsing error and fails the sync test instead of checking the declared packages.

Reuse the repository's requirements-file parsing behavior to expand or skip supported directives before normalizing package requirements.
</issue_to_address>

### Comment 2
<location path="tests/test_dependency_sync.py" line_range="44" />
<code_context>
+        requirement = Requirement(entry)
+        dependencies[canonicalize_name(requirement.name)] = (
+            frozenset(requirement.extras),
+            str(requirement.specifier),
+            str(requirement.marker or ""),
+        )
</code_context>
<issue_to_address>
**Equivalent constraints fail the check**

When the equivalent version constraints are written in different orders in the two manifests, `str(requirement.specifier)` preserves the order of constraints, so equivalent declarations such as `>=1,<2` and `<2,>=1` compare as different and fail the test even though they allow the same versions.

Canonicalize the individual specifiers before comparing them.
</issue_to_address>

### Comment 3
<location path="tests/test_dependency_sync.py" line_range="45" />
<code_context>
+        dependencies[canonicalize_name(requirement.name)] = (
+            frozenset(requirement.extras),
+            str(requirement.specifier),
+            str(requirement.marker or ""),
+        )
+    return dependencies
</code_context>
<issue_to_address>
**Equivalent markers fail comparison**

When equivalent marker clauses are written in a different order in the manifests, `_normalize` compares the strings produced by `str(requirement.marker or "")`, so reordered equivalent clauses fail the sync test even though both manifests install the dependency under the same conditions.

Compare markers in a canonical form that treats equivalent clause orderings as equal.
</issue_to_address>

Sourcery assessment

Approval pending. 2 findings to address first.

Blocking findings: tests/test_dependency_sync.py:44, tests/test_dependency_sync.py:45


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread tests/test_dependency_sync.py Resolved
Comment thread tests/test_dependency_sync.py Resolved
Comment thread tests/test_dependency_sync.py Resolved
@inertialobs

Copy link
Copy Markdown
Contributor Author

问题1,3已确认, 第二个为误报: specifier是packaging.requirements.SpecifierSet, 本身已经消序

sourcery-ai[bot]
sourcery-ai Bot previously approved these changes Oct 23, 2026

@sourcery-ai sourcery-ai 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.

Sourcery assessment

Approved.

@inertialobs

Copy link
Copy Markdown
Contributor Author

或者我就改一个同步的地方?

@inertialobs
inertialobs changed the base branch from master to dev December 1, 2026 13:27
@inertialobs
inertialobs changed the base branch from dev to master December 1, 2026 13:36
@inertialobs
inertialobs dismissed sourcery-ai[bot]’s stale review December 1, 2026 13:36

The base branch was changed.

requirements.txt still declared faiss-cpu>=1.12.0 while pyproject.toml
has required >=1.14.3 since AstrBotDevs#8837. Restore the matching baseline so
installs from requirements.txt resolve the intended version.
Parse both dependency files and compare package names, extras, version
specifiers, and environment markers. This catches changes that update
only one file, which is how the faiss-cpu drift slipped in.
Reuse the existing requirements-file parser so pip directives and nested -r includes are expanded or skipped instead of failing requirement parsing.

Canonicalize markers into a structured frozenset-based key so reordered and/or clauses compare equal without relying on string order, while preserving parentheses and operator precedence.
@inertialobs
inertialobs force-pushed the fix/deps-sync-requirements-txt branch from 2458c4e to f974ba1 Compare December 1, 2026 18:07
@mantoujun12
mantoujun12 merged commit 54a69fb into AstrBotDevs:master Dec 1, 2026
8 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in AstrBot Roadmap Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants