Skip to main content

No project description provided

Project description

oak-build

A make-like build system written on python

How to use

Create oak_build.py file in your project directory. Every method marked with @task decorator can be called from CLI.

from pathlib import Path

from oak_build import task


@task
def create_file():
    with open(Path("result.txt"), "w") as txt:
        txt.write("test content\n")

To execute create_file task call oak create_file from console.

Task dependencies

You can link dependent tasks with depends_on parameter.

from oak_build import task, run


@task
def unit_tests():
    run("poetry run pytest tests")


@task
def integration_tests():
    run("poetry run pytest integration_tests")


@task(
    depends_on=[
        unit_tests,
        integration_tests,
    ]
)
def tests():
    pass

When oak tests is called oak build will execute unit_tests and integration_tests tasks as well.

CLI params

You can pass parameters to tasks with --param key=value parameter of command line. Oak will try to parse all task function params regarding its annotation type.

Example:

from enum import Enum, auto
from oak_build import task


class TaskEnum(Enum):
    VALUE = auto()


@task
def enum_param(param: TaskEnum):
    pass

Task results

Exit code

All int return value from task will be treated as return code. If return is integer and not zero task will be marked as failed and further execution will be stopped.

from oak_build import task

@task
def exit_code_task():
    return 0

Result dict

All dict return value will be treated as result. Those results can be used in another tasks with tas name prefix (see example below).

from oak_build import task

@task
def source():
    return {
        "result": 123,
    }

@task(depends_on=[source])
def result_consumer(source_result):
    pass

Please note that CLI params have greater priority than arguments deducted from task results.

Code and result

You can return Tuple[int, Dict[str, Any]] from task, and it will be treated as return code and result dict. If code is not zero task is considered failed. The result dict processing is the same as in dict result

Exceptions

If task throws exception it is considered faled and further execution will be stopped.

Examples

For examples see integration tests files and self build oak_file.py.

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

oak_build-0.1.2.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

oak_build-0.1.2-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

Details for the file oak_build-0.1.2.tar.gz.

File metadata

  • Download URL: oak_build-0.1.2.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for oak_build-0.1.2.tar.gz
Algorithm Hash digest
SHA256 43ee6eca34c74028d4867b7ea9145a2c5c71198a7a942186cece45bc21279607
MD5 d9eff51a003218d55513ea871769b08a
BLAKE2b-256 e6f20fc4636ab448b80f0b1cc4e8447ccc6f735413013fb03f9c37da4396ecba

See more details on using hashes here.

Provenance

File details

Details for the file oak_build-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: oak_build-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 10.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for oak_build-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a9be92e467a0afb0558f34b3d68df3f9d62d1c89506e531603dd84a38a59ca14
MD5 070951e0b0d1fabebf514d63df0d6db3
BLAKE2b-256 7eab6b5092d133645f3cb4ee34e7b6108c788a2ed6335fc6ffce81051e7e5832

See more details on using hashes here.

Provenance

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