Skip to main content

No project description provided

Project description

https://github.com/tillahoffmann/cook-build/actions/workflows/main.yaml/badge.svg https://img.shields.io/pypi/v/cook-build

Cook is a task-centric build system with simple declarative recipes specified in Python.

Getting Started

Tasks are declared in a recipe.py file using the ~cook.manager.create_task function. Each task must have a unique name, may depend on files or other tasks, and can execute an action, typically a shell command. The simple example below creates a C source file, compiles it, and executes the binary.

>>> from cook import create_task

>>> create_task("src", targets=["hello.c"],
...             action="echo 'int main() { return 0; }' > hello.c")  # doctest: +IGNORE_RESULT
>>> create_task("cc", dependencies=["hello.c"], targets=["hello"],
...             action="cc -o hello hello.c")  # doctest: +IGNORE_RESULT
>>> create_task("hello", dependencies=["hello"], action="./hello")  # doctest: +IGNORE_RESULT

Running cook ls from the command line lists all known tasks, e.g.,

:cwd: examples/getting_started

$ cook ls
<task `src` @ /.../recipe.py:3>
<task `cc` @ /.../recipe.py:4>
<task `hello` @ /.../recipe.py:5>

Running cook exec hello creates the source file, compiles it, and executes the binary (using --log-level=debug can provide additional information).

:cwd: examples/getting_started
:stderr:

$ cook exec hello
INFO: executing <task `src` @ /.../recipe.py:3> ...
INFO: completed <task `src` @ /.../recipe.py:3> in 0:00:...
INFO: executing <task `cc` @ /.../recipe.py:4> ...
INFO: completed <task `cc` @ /.../recipe.py:4> in 0:00:...
INFO: executing <task `hello` @ /.../recipe.py:5> ...
INFO: completed <task `hello` @ /.../recipe.py:5> in 0:00:...

To rerun a task, tell Cook to reset it.

:cwd: examples/getting_started
:stderr:

$ cook reset cc
INFO: reset 1 task

The full set of available commands can be explored using cook --help as shown below.

Tasks Are Dumb; Contexts Are Smart

~cook.task.Tasks do not provide any functionality beyond storing metadata, including

  • targets, the files generated by the task,

  • dependencies, the files the task depends on,

  • action, the ~cook.actions.Action to execute when the task is run,

  • task_dependencies, other tasks that should be executed first,

  • location, filename and line number where the task was defined.

All logic is handled by ~cook.contexts.Contexts which are applied to each task when it is created. For example, ~cook.contexts.create_group adds all tasks created within the context to a group. This group can be executed to execute all child tasks.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cook-build-0.5.1.tar.gz (23.4 kB view details)

Uploaded Source

File details

Details for the file cook-build-0.5.1.tar.gz.

File metadata

  • Download URL: cook-build-0.5.1.tar.gz
  • Upload date:
  • Size: 23.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for cook-build-0.5.1.tar.gz
Algorithm Hash digest
SHA256 049286e3353430a8510225c1f9e67808a90f5c8710a89afe447bcac02d954069
MD5 24c005152336a3d635727fbce615cebd
BLAKE2b-256 a9c5b3304ae5a18a16e5ec99ebfa050762db256dba97f55f22ca7ef734c3d0b5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page