Skip to main content

A task-centric build system with simple declarative recipes specified in Python

Project description

🧑‍🍳 Cook

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")
>>> create_task("cc", dependencies=["hello.c"], targets=["hello"],
...             action="cc -o hello hello.c")
>>> create_task("hello", dependencies=["hello"], action="./hello")

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

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

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

$ 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:6> ...
INFO: completed <task `cc` @ /.../recipe.py:6> in 0:00:...
INFO: executing <task `hello` @ /.../recipe.py:9> ...
INFO: completed <task `hello` @ /.../recipe.py:9> in 0:00:...

To rerun a task, tell Cook to reset it.

$ cook reset cc
INFO: reset 1 task

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

$ cook --help
usage: cook [-h] [--recipe RECIPE] [--module MODULE] [--db DB]
            [--log-level {warning,error,info,debug}]
            {exec,ls,info,reset} ...

positional arguments:
  {exec,ls,info,reset}
    exec                Execute one or more tasks.
    ls                  List tasks.
    info                Display information about one or more tasks.
    reset               Reset the status of one or more tasks.

options:
  -h, --help            show this help message and exit
  --recipe RECIPE       file containing declarative recipe for tasks
  --module, -m MODULE   module containing declarative recipe for tasks
  --db DB               database for keeping track of assets
  --log-level {warning,error,info,debug}
                        log level

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.6.2.tar.gz (25.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cook_build-0.6.2-py3-none-any.whl (21.1 kB view details)

Uploaded Python 3

File details

Details for the file cook_build-0.6.2.tar.gz.

File metadata

  • Download URL: cook_build-0.6.2.tar.gz
  • Upload date:
  • Size: 25.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cook_build-0.6.2.tar.gz
Algorithm Hash digest
SHA256 3cdf3cfddf32ec9f7661aea0063261f26b08c6d13cf3ec4409a2121d7da45287
MD5 e5fdc3a4a5f37423b556c247af17e9f4
BLAKE2b-256 fda63fd5ef0e2a5e52ca3e12121fa0d2803fd5ec89cf5628976cc9252456b5cd

See more details on using hashes here.

Provenance

The following attestation bundles were made for cook_build-0.6.2.tar.gz:

Publisher: main.yaml on tillahoffmann/cook-build

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cook_build-0.6.2-py3-none-any.whl.

File metadata

  • Download URL: cook_build-0.6.2-py3-none-any.whl
  • Upload date:
  • Size: 21.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cook_build-0.6.2-py3-none-any.whl
Algorithm Hash digest
SHA256 52590af47a605d1971c7b00145ef0d229826db8864d14cb9661628b8edb1d3ed
MD5 50c8f6283d54b6805b427c24ffca1978
BLAKE2b-256 09efc34aaa38d51f73fb6b371fa7efda4ba59f2e93eca23550ccadfab5746f2e

See more details on using hashes here.

Provenance

The following attestation bundles were made for cook_build-0.6.2-py3-none-any.whl:

Publisher: main.yaml on tillahoffmann/cook-build

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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