exr-builder 0.1.7
Lightweight Python Build Tool.
License: MIT License
Keywords: devops,build tool

|Build Status|

Why I did this fork and what will happen here?
==============================================

This project was forked from Pynt. `Raghunandan
Rao <https://github.com/rags/pynt>`__

We appreciate work made by `Raghunandan Rao <https://github.com/rags>`__
and will push any good parts of out changes to initial
`rags/pynt <https://github.com/rags/pynt>`__ repo.

Aim of this exr-builder project is to support exrny.com applications
with lightweight and easy to use python devops tool. We are going to
accumulate work done by `Raghunandan Rao <https://github.com/rags>`__
and other pynt contributers here. Our own changes and new features will
be implemented here and pushed as PR to original pynt repo.

A pynt of Python build.
=======================

Features
--------

-  Easy to learn.
-  Build tasks are just python funtions.
-  Manages dependencies between tasks.
-  Automatically generates a command line interface.
-  Rake style param passing to tasks
-  Supports python 2.7 and python 3.x

Todo Features
-------------

-  Async tasks
-  Additional tasks timing reporting

Installation
------------

You can install exr-builder from the Python Package Index (PyPI) or from
source.

Using pip

.. code:: bash

    $ pip install exr-builder

Using easy_install

.. code:: bash

    $ easy_install exr-builder

Example
-------

The build script is written in pure Python and exr-builder takes care of
managing any dependencies between tasks and generating a command line
interface.

Writing build tasks is really simple, all you need to know is the @task
decorator. Tasks are just regular Python functions marked with the
``@task()`` decorator. Dependencies are specified with ``@task()`` too.
Tasks can be ignored with the ``@task(ignore=True)``. Disabling a task
is an useful feature to have in situations where you have one task that
a lot of other tasks depend on and you want to quickly remove it from
the dependency chains of all the dependent tasks.

**build.py**
------------

.. code:: python


    #!/usr/bin/python

    import sys
    from exr.builder import task

    @task()
    def clean():
        '''Clean build directory.'''
        print 'Cleaning build directory...'

    @task(clean)
    def html(target='.'):
        '''Generate HTML.'''
        print 'Generating HTML in directory "%s"' %  target

    @task(clean, ignore=True)
    def images():
        '''Prepare images.'''
        print 'Preparing images...'

    @task(html,images)
    def start_server(server='localhost', port = '80'):
        '''Start the server'''
        print 'Starting server at %s:%s' % (server, port)

    @task(start_server) #Depends on task with all optional params
    def stop_server():
        print 'Stopping server....'

    @task()
    def copy_file(src, dest):
        print 'Copying from %s to %s' % (src, dest)

    @task()
    def echo(*args,**kwargs):
        print args
        print kwargs
        
    # Default task (if specified) is run when no task is specified in the command line
    # make sure you define the variable __DEFAULT__ after the task is defined
    # A good convention is to define it at the end of the module
    # __DEFAULT__ is an optional member

    __DEFAULT__=start_server

**Running exr-builder tasks**
-----------------------------

The command line interface and help is automatically generated. Task
descriptions are extracted from function docstrings.

.. code:: bash

    $ exrb -h
    usage: exrb [-h] [-l] [-v] [-f file] [task [task ...]]

    positional arguments:
      task                  perform specified task and all its dependencies

    optional arguments:
      -h, --help            show this help message and exit
      -l, --list-tasks      List the tasks
      -v, --version         Display the version information
      -f file, --file file  Build file to read the tasks from. Default is
                            'build.py'

.. code:: bash

    $ exrb -l
    Tasks in build file ./build.py:
      clean                       Clean build directory.
      copy_file                   
      echo                        
      html                        Generate HTML.
      images           [Ignored]  Prepare images.
      start_server     [Default]  Start the server
      stop_server                 

    Powered by exr-builder - A Lightweight Python Build Tool.

exr-builder takes care of dependencies between tasks. In the following
case start_server depends on clean, html and image generation (image
task is ignored).

.. code:: bash

    $ exrb #Runs the default task start_server. It does exactly what "exrb start_server" would do.
    [ example.py - Starting task "clean" ]
    Cleaning build directory...
    [ example.py - Completed task "clean" ]
    [ example.py - Starting task "html" ]
    Generating HTML in directory "."
    [ example.py - Completed task "html" ]
    [ example.py - Ignoring task "images" ]
    [ example.py - Starting task "start_server" ]
    Starting server at localhost:80
    [ example.py - Completed task "start_server" ]

The first few characters of the task name is enough to execute the task,
as long as the partial name is unambigious. You can specify multiple
tasks to run in the commandline. Again the dependencies are taken taken
care of.

.. code:: bash

    $ exrb cle ht cl
    [ example.py - Starting task "clean" ]
    Cleaning build directory...
    [ example.py - Completed task "clean" ]
    [ example.py - Starting task "html" ]
    Generating HTML in directory "."
    [ example.py - Completed task "html" ]
    [ example.py - Starting task "clean" ]
    Cleaning build directory...
    [ example.py - Completed task "clean" ]

The ‘html’ task dependency ‘clean’ is run only once. But clean can be
explicitly run again later.

exrb tasks can accept parameters from commandline.

.. code:: bash

    $ exrb "copy_file[/path/to/foo, path_to_bar]"
    [ example.py - Starting task "clean" ]
    Cleaning build directory...
    [ example.py - Completed task "clean" ]
    [ example.py - Starting task "copy_file" ]
    Copying from /path/to/foo to path_to_bar
    [ example.py - Completed task "copy_file" ]

exrb can also accept keyword arguments.

.. code:: bash

    $ exrb start[port=8888]
    [ example.py - Starting task "clean" ]
    Cleaning build directory...
    [ example.py - Completed task "clean" ]
    [ example.py - Starting task "html" ]
    Generating HTML in directory "."
    [ example.py - Completed task "html" ]
    [ example.py - Ignoring task "images" ]
    [ example.py - Starting task "start_server" ]
    Starting server at localhost:8888
    [ example.py - Completed task "start_server" ]
        
    $ exrb echo[hello,world,foo=bar,blah=123]
    [ example.py - Starting task "echo" ]
    ('hello', 'world')
    {'blah': '123', 'foo': 'bar'}
    [ example.py - Completed task "echo" ]

**Organizing build scripts**
----------------------------

You can break up your build files into modules and simple import them
into your main build file.

.. code:: python

    from deploy_tasks import *
    from test_tasks import functional_tests, report_coverage

Contributors/Contributing
-------------------------

-  Raghunandan Rao - exr-builder is preceded by and forked from
   `pynt <https://github.com/rags/pynt>`__, which was created by
   `Raghunandan Rao <https://github.com/rags/pynt>`__.
-  Calum J. Eadie - pynt is preceded by and forked from
   `microbuild <https://github.com/CalumJEadie/microbuild>`__, which was
   created by `Calum J. Eadie <https://github.com/CalumJEadie>`__.

If you want to make changes the repo is at
https://github.com/exrny/exr-builder. You will need
`pytest <http://www.pytest.org>`__ to run the tests

.. code:: bash

    $ ./b t

It will be great if you can raise a `pull
request <https://help.github.com/articles/using-pull-requests>`__ once
you are done.

If you find any bugs or need new features please raise a ticket in the
`issues section <https://github.com/exrny/exr-builder/issues>`__ of the
github repo.

License
-------

exr-builder is licensed under a `MIT
license <http://opensource.org/licenses/MIT>`__

.. |Build Status| image:: https://travis-ci.org/exrny/exr-builder.png?branch=master
   :target: https://travis-ci.org/exrny/exr-builder

Changes
=======

0.1.0 - 04/02/2018
------------------

-  Initial commit