[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fab-user] import bug

From: Peter Sheats
Subject: [Fab-user] import bug
Date: Wed, 13 May 2009 16:52:12 -0400

So in regards to this code:

def load_fabfile(path):
    Import given fabfile path and return dictionary of its public callables.
    # Get directory and fabfile name
    directory, fabfile = os.path.split(path)
    # If the directory isn't in the PYTHONPATH, add it so our import will work
    added_to_path = False
    if directory not in sys.path:
        sys.path.insert(0, directory)
        added_to_path = True
    # Perform the import (trimming off the .py)
    imported = __import__(os.path.splitext(fabfile)[0])

    # Remove directory from path if we added it ourselves (just to be neat)
    if added_to_path:
        del sys.path[0]
    # Return dictionary of callables only (and don't include Fab operations or
    # underscored callables)
    return dict(filter(is_task, vars(imported).items()))

What it doesn't check is what is first on the path -- so all i have been getting is the fab commands (build_docs, push_docs, etc) whenever i run fab -l even though it is finding my fabfile.py.  The reason is because my src/fabric command is in my path before the "directory" mentioned in the code above is.  So all that ever gets in the imported list is commands from fabric's fabfile.py. 

Maybe this is because I run python setup.py develop?  Not sure if there is any reason for me to have src/fabric in my path...


reply via email to

[Prev in Thread] Current Thread [Next in Thread]