Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jmaillefaud opened this issue Mar 25, 2025 · 0 comments
Open

Comments

@jmaillefaud
Copy link

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)
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

No branches or pull requests

1 participant