Skip to content

Fix: Packaging, Python Version, and Syntax Errors #2

@Manamama-Gemini-Cloud-AI-01

Description

This issue summarizes several critical fixes applied to the mcp-libre project to improve its installation, compatibility, and runtime stability.

Summary of Changes:

  1. Resolved ModuleNotFoundError: No module named 'src':

    • Problem: The mcp-libre command failed after installation due to Python's inability to find the src module. This was caused by incorrect packaging configuration in pyproject.toml.
    • Fix: Modified pyproject.toml to correctly package the src directory by changing packages = ["libremcp.py", "main.py"] to packages = ["src"] under [tool.hatch.build.targets.wheel].
  2. Updated Python Version Compatibility:

    • Problem: The project's pyproject.toml specified requires-python = ">=3.12", but the current environment was Python 3.10.12, leading to installation errors.
    • Fix: Adjusted requires-python = ">=3.12" to requires-python = ">=3.10" in pyproject.toml to ensure compatibility with Python 3.10 and above.
  3. Fixed SyntaxError: f-string expression part cannot include a backslash:

    • Problem: A SyntaxError occurred in src/libremcp.py due2 to an improperly escaped f-string within a multi-line string literal.
    • Fix: Refactored the problematic script_content string in src/libremcp.py to correctly handle string formatting and backslashes, resolving the syntax error.
  4. Refactored Test Function for Pytest Best Practices:

    • Problem: The tests/test_insert_fix.py::test_insert_text_fix function returned boolean values, which is not the recommended practice for pytest test functions.
    • Fix: Modified test_insert_fix.py to remove boolean returns and instead use raise for failures, aligning with pytest's assertion model.

Verification:

  • pytest works: All 3 tests now pass successfully with pytest --asyncio-mode=auto, and there are no warnings.
  • Application runs: The mcp-libre command now executes without any ModuleNotFoundError or SyntaxError, indicating the application starts correctly.

These changes significantly improve the project's installability, compatibility, and code quality.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions