Skip to content

Conversation

@skyswordw
Copy link

Description

This PR addresses an issue where import libero would fail with a ModuleNotFoundError when the libero package was installed in editable mode (pip install -e .) using recent versions of pip and setuptools. The root cause was related to how modern packaging tools handle editable installs for setup.py-based projects, where the default PEP 660 style "finder" mechanism did not consistently expose the project's path to sys.path.

This was particularly noticeable when trying to import libero from outside its root directory after an editable install. While a workaround (pip install --config-settings editable_mode=compat -e .) existed, this PR implements a more robust and future-proof solution.

Solution Implemented

To resolve this and align the project with current Python packaging best practices, the following changes were made:

  1. Migrated to pyproject.toml: All project metadata (name, version, dependencies, entry points, author information, etc.) and build system configurations have been migrated from setup.py to a pyproject.toml file. This adheres to PEP 517, PEP 518, and PEP 621.
  2. Simplified setup.py: The setup.py file has been reduced to a minimal shim that defers to setuptools (which now reads its configuration from pyproject.toml). This ensures compatibility for any tools that might still expect a setup.py file.

These changes allow pip install -e . to correctly configure the editable install using the modern PEP 660 mechanism, making the libero package importable lágrimas (system-wide, within the activated environment) without needing compatibility flags.

Benefits

  • Resolves ModuleNotFoundError: Fixes the import issues encountered with editable installs using modern pip versions.
  • Modernized Packaging: Aligns the project with current Python packaging standards, improving maintainability and compatibility with the broader Python ecosystem.
  • Improved Reliability: Standardized build dependency declaration and build backend invocation lead to more reliable and reproducible builds.
  • Future-Proofing: Ensures the project is better prepared for future changes in Python packaging tools.

How to Test

  1. Ensure you have a clean Python environment (e.g., Python 3.10+).
  2. Clone this branch.
  3. Navigate to the LIBERO directory (where pyproject.toml is now located).
  4. Install the package in editable mode: pip install -e .
  5. Navigate to a different directory (e.g., the parent GRAPE directory or any other directory outside LIBERO).
  6. Start a Python interpreter and try: import libero
    • The import should now succeed without errors.
    • You can also check libero.__path__ to see how it's being located.

This change should provide a smoother development experience for users relying on editable installs.

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.

1 participant