{"id":20132820,"url":"https://github.com/jcomo/snake","last_synced_at":"2025-07-10T02:37:58.501Z","repository":{"id":52705715,"uuid":"54737467","full_name":"jcomo/snake","owner":"jcomo","description":"A python port of the popular build script utility - Rake","archived":false,"fork":false,"pushed_at":"2021-04-20T17:07:27.000Z","size":60,"stargazers_count":9,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-06T02:44:17.828Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jcomo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-03-25T18:06:38.000Z","updated_at":"2019-08-09T05:00:51.000Z","dependencies_parsed_at":"2022-08-22T08:00:23.612Z","dependency_job_id":null,"html_url":"https://github.com/jcomo/snake","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/jcomo/snake","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcomo%2Fsnake","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcomo%2Fsnake/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcomo%2Fsnake/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcomo%2Fsnake/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jcomo","download_url":"https://codeload.github.com/jcomo/snake/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcomo%2Fsnake/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264519719,"owners_count":23621858,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T20:55:16.060Z","updated_at":"2025-07-10T02:37:58.482Z","avatar_url":"https://github.com/jcomo.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# snake [![Build Status](https://travis-ci.org/jcomo/snake.svg?branch=master)](https://travis-ci.org/jcomo/snake)\n\nBuild script utility for Python.\nPorted from the popular Ruby tool, [Rake](https://github.com/ruby/rake).\nStill very much a work in progress.\n\n## Motivation\n\nRake is a tried and true build tool for the Ruby community and there are many of us in the Python community who use it to automate steps of our builds or aspects of our development environments.\nWhat Rake really lacks when using it with a Python project is the ability to hook into Python code within the project. Usually the pattern is to create a python script and then expose it with a Rake task, which is a lot of overhead for a tool whose goal is to reduce overhead.\nSnake is meant to be a comparable tool to Rake with familiar syntax and concepts that allows Python developers to write automation tasks in the same language of their project.\n\nSnake maintains a similar goal of Rake, which is to reduce the overhead to add automation to a project. It does this by providing terse, straightforward syntax in a flexible, yet simple DSL.\n\n## Installation\n\nFirst, install Snake. It is recommended to install it to your system Python instead of a local Python installation since it is meant to be a global exectuable.\nUse a local installation if you need a specific version.\n\n```\npip install pyrake\n```\n\n## Usage\n\nSimilar to Rake, Snake uses a manifest file called the `Snakefile`, which contains definitions for your build tasks.\n\n```python\nfrom snake import *\n\n@task\ndef hello(name='World'):\n    \"\"\"Say hello\"\"\"\n    sh('echo Hello, %s!' % name)\n```\n\nFrom the directory containing your `Snakefile`, you can run the `hello` task using\n\n```sh\nsnake hello  # echos \"Hello, World!\"\nsnake hello name=Github  # echos \"Hello, Github!\"\n```\n\n### Defining Tasks\n\nTo define a task, decorate a function with `@task(description)`.\nThe description is a quick blurb explaining the goal of the task.\n\nFunctions that become tasks can accept keyword arguments that will be specified on the command line.\nHowever, keyword arguments supplied to the function via Snake will always be strings.\nThe function itself is not modified in any way by `@task` so the function can be called normally everywhere else in the program.\n\nDependeny tasks can be defined with the `requires` keyword arg to `@task`.\nIt accepts a list of strings where each string is the label of another task.\nTask dependencies are resolved from left to right.\nIn the following example, executing the `install` task will always cause `bootstrap` to be executed first.\n\nNamespaces can also be used to group sets of related tasks by using the `@namespace` decorator.\nNote that the decorator accepts no parameters. The function that it decorates must also not accept any parameters.\n\nA default task can be defined by setting `default` to a string corresponding to the name of the task function in the `Snakefile`.\n\nHere we define regular tasks, tasks with dependencies, and task namespaces.\n\n```python\nfrom snake import *\n\ndefault = 'build:tools'\n\n\n@task\ndef bootstrap():\n    \"\"\"Bootstraps the environment\"\"\"\n    sh('echo Bootstrapping...')\n\n\n@task(requires=['bootstrap'])\ndef install():\n    \"\"\"Installs dependencies\"\"\"\n    sh('echo Installing...')\n\n\n@namespace\ndef build():\n\n    @task\n    def tools(typ='core'):\n        \"\"\"Builds the tools\"\"\"\n        sh('echo Building the %s tools' % typ)\n\n    @task\n    def app(target):\n        \"\"\"Builds the application\"\"\"\n        sh('echo Building the application for %s' % target)\n```\n\n### Listing Tasks\n\nTo list the available tasks, use `snake -T`.\nThe output will consist of all available tasks and their respective descriptions.\n\nHere is example output using the `Snakefile` from the previous section.\n\n```\n$ snake -T\n\nsnake bootstrap                  # Bootstraps the environment\nsnake install                    # Installs dependencies\nsnake build:app target={target}  # Builds the tools\nsnake build:tools [typ=core]     # Builds the application\n```\n\n## API Reference\n\n#### `@task(requires=None)`\n\nDecorates a function that then exposes it as a task to be run.\nThe name of the function becomes the name of the task.\nThe `requires` parameter, if specified, is a list of strings where each string is the name of a task that this one depends on.\n\n#### `@namespace`\n\nDecorates a function so that it exposes a task namespace.\nThe name of the function becomes the name of the namespace.\nTasks and nested namespaces can be defined in the namespace and will be called as `namespace:task`.\n\n#### `sh(command, silent=False)`\n\nRuns a shell command.\nIf silent is not specified, an exception will be raised if the resulting status of the command is nonzero.\n\n#### `ENV`\n\nA dict that gives you access to environment variables.\nIt has a special property that accessing by key using brackets will not raise a `KeyError` but will return `None` instead.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcomo%2Fsnake","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjcomo%2Fsnake","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcomo%2Fsnake/lists"}