Marvin
11/18/2025, 3:48 AMMarvin
11/18/2025, 3:51 AMpip install prefect-shell
2) Call shell_run_command inside your flow (or task) and point it at the directory with your Makefile via `cwd`:
from prefect import flow
from prefect_shell.commands import shell_run_command
@flow
def run_make():
# Run the default target in the Makefile
shell_run_command("make", cwd="/path/to/project")
# Or run a specific target
result = shell_run_command("make build", cwd="/path/to/project")
print("Make output:", result)
if __name__ == "__main__":
run_make()
Notes:
- cwd should be the directory containing the Makefile (alternatively, use make -C /path/to/project build).
- You can pass environment variables with env, e.g.:
shell_run_command("make deploy", cwd="/path/to/project", env={"ENV": "prod"})
- The command’s output is captured and available as the return value; a non-zero exit status will fail the task.
- Ensure make is installed and available on the PATH in your execution environment (e.g., your worker image).
Docs:
- prefect-shell integration docs
- prefect-shell GitHub
If you share where your Makefile lives and how you’re running (local, Docker, k8s), I can tailor the example (e.g., correct cwd, environment vars, or container setup).