pydoit / doit

CLI task management & automation tool
http://pydoit.org
MIT License
1.87k stars 175 forks source link

Trying to understand the behavior of targets and action execution #435

Closed sandeep-gh closed 2 years ago

sandeep-gh commented 2 years ago

In this simple code picked from tutorials:

def task_hello():
    """hello py """

    def python_hello(times, text, targets):
        with open(targets[0], "w") as output:
            output.write(times * text)

    return {'actions': [(python_hello, [3, "py!\n"])],
            'targets': ["hello.txt"],
            }

def task_compile():
    return {'actions': ["cc -c main.c"],
            'file_dep': ["main.c", "defs.h"],
            'targets': ["main.o"]
            }

when I run this code multiple times I get following output:

.  hello
-- compile

my question is why is the task_hello getting executed if though its targets are clearly present for last execution. For task_compile, I get the expected behavior. It doesn't run again after the first invocation. What is so special about the open command.

Upvote & Fund

Fund with Polar