Skip to content

Migrator CLI tool does not work properly when using pyenv virtualenv #682

Open
@jmaillefaud

Description

@jmaillefaud

As dynamic module import are performed in import_submodules in the migrate cli tool, the project root needs to be in sys.path for the dynamic imports to work. In the case where pyenv is used, as the binaries are not stored with the project, the cli tool is not able to find the project root and ìmport_submodules` will always fail.

My current fix is to change import submodules to:

def import_submodules(root_module_name: str):
    """Import all submodules of a module, recursively."""
    # TODO: Call this without specifying a module name, to import everything?
    
    # --- Added code ---
    import os
    import sys
    sys.path.insert(0, os.getcwd())
    
    # --- Existing code ---
    root_module = importlib.import_module(root_module_name)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions