Lightweight Python Build Tool.
Project description
`|Build Status| <https://travis-ci.org/rags/pynt>`_
A pynt of Python build.
=======================
`Raghunandan Rao <https://github.com/rags>`_
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
Installation
------------
You can install pynt from the Python Package Index (PyPI) or from
source.
Using pip
::
$ pip install pynt
Using easy\_install
::
$ easy_install pynt
Example
-------
The build script is written in pure Python and pynt 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. Note that any task
whose name starts with an underscore(\ ``_``) will be considered
private. Private tasks are not listed in with ``pynt -l``, but they can
still be run with ``pynt _private_task_name``
**build.py**
------------
::
#!/usr/bin/python
import sys
from pynt 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()
def _copy_resources():
'''Copy resource files. This is a private task. "pynt -l" will not list this'''
print('Copying resource files')
@task(clean, _copy_resources)
def html(target='.'):
'''Generate HTML.'''
print 'Generating HTML in directory "%s"' % target
@task(clean, _copy_resources, ignore=True)
def images():
'''Prepare images.'''
print 'Preparing images...'
@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 pynt tasks**
----------------------
The command line interface and help is automatically generated. Task
descriptions are extracted from function docstrings.
::
$ pynt -h
usage: pynt [-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'
::
$ pynt -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 pynt - A Lightweight Python Build Tool.
pynt takes care of dependencies between tasks. In the following case
start\_server depends on clean, html and image generation (image task is
ignored).
::
$ pynt #Runs the default task start_server. It does exactly what "pynt 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.
::
$ pynt 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.
pynt tasks can accept parameters from commandline.
::
$ pynt "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" ]
pynt can also accept keyword arguments.
::
$ pynt 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" ]
$ pynt 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.
::
from deploy_tasks import *
from test_tasks import functional_tests, report_coverage
Contributors/Contributing
-------------------------
- 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/rags/pynt.
You will need `pytest <http://www.pytest.org>`_ to run the tests
::
$ ./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/rags/pynt/issues>`_ of the github
repo.*
License
-------
pynt is licensed under a `MIT
license <http://opensource.org/licenses/MIT>`_
.. |Build
Status| image:: https://travis-ci.org/rags/pynt.png?branch=master
Changes
=======
0.8.2 - 23/06/2018
------------------
* private tasks. Any tasks that start with an underscore(_) are private by convention.
0.8.1 - 02/09/2013
------------------
* Enabling extensions
0.8.0 - 02/09/2013
------------------
* Support for specifying a default task with __DEFAULT__ variable
* pynt -v (--version) for displays version info
* pynt -l lists tasks in alphabetical order
0.7.1 - 17/03/2013
------------------
* Migrated pynt to work on python 3.x. pynt still works on 2.7.
* pynt version now displayed as part of help output.
0.7.0 - 16/02/2013
------------------
* New commandline interface. Distribution now includes 'pynt' executable.
* 'build.py' is the default build file.
* Build files no longer need "if main" construct.
* pynt no longer exposes build method. This is a backward incompatible change.
0.6.0 - 17/12/2012
------------------
* Simplified ignoring tasks. ignore a keyword param for task and not a separate decorator. [This change is NOT backward compatible!!!]
* Added support for listing tasks
* Improved help
0.5.0 - 01/12/2012
------------------
* Ability to pass params to tasks.
* Major rewrite and flattening the package hierarchy.
0.4.0 - 17/11/2012
------------------
* Support for running multiple tasks from commandline.
* Ability to run tasks by typing in just the first few unambigious charecters.
Changes before forking from microbuild
======================================
0.3.0 - 18/09/2012
------------------
* Fixed bug in logging. No longer modifies root logger.
* Added ignore functionality.
* Extended API documentation.
0.2.0 - 29/08/2012
------------------
* Added progress tracking output.
* Added handling of exceptions within tasks.
0.1.0 - 28/08/2012
------------------
* Initial release.
* Added management of dependancies between tasks.
* Added automatic generation of command line interface.
A pynt of Python build.
=======================
`Raghunandan Rao <https://github.com/rags>`_
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
Installation
------------
You can install pynt from the Python Package Index (PyPI) or from
source.
Using pip
::
$ pip install pynt
Using easy\_install
::
$ easy_install pynt
Example
-------
The build script is written in pure Python and pynt 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. Note that any task
whose name starts with an underscore(\ ``_``) will be considered
private. Private tasks are not listed in with ``pynt -l``, but they can
still be run with ``pynt _private_task_name``
**build.py**
------------
::
#!/usr/bin/python
import sys
from pynt 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()
def _copy_resources():
'''Copy resource files. This is a private task. "pynt -l" will not list this'''
print('Copying resource files')
@task(clean, _copy_resources)
def html(target='.'):
'''Generate HTML.'''
print 'Generating HTML in directory "%s"' % target
@task(clean, _copy_resources, ignore=True)
def images():
'''Prepare images.'''
print 'Preparing images...'
@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 pynt tasks**
----------------------
The command line interface and help is automatically generated. Task
descriptions are extracted from function docstrings.
::
$ pynt -h
usage: pynt [-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'
::
$ pynt -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 pynt - A Lightweight Python Build Tool.
pynt takes care of dependencies between tasks. In the following case
start\_server depends on clean, html and image generation (image task is
ignored).
::
$ pynt #Runs the default task start_server. It does exactly what "pynt 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.
::
$ pynt 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.
pynt tasks can accept parameters from commandline.
::
$ pynt "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" ]
pynt can also accept keyword arguments.
::
$ pynt 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" ]
$ pynt 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.
::
from deploy_tasks import *
from test_tasks import functional_tests, report_coverage
Contributors/Contributing
-------------------------
- 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/rags/pynt.
You will need `pytest <http://www.pytest.org>`_ to run the tests
::
$ ./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/rags/pynt/issues>`_ of the github
repo.*
License
-------
pynt is licensed under a `MIT
license <http://opensource.org/licenses/MIT>`_
.. |Build
Status| image:: https://travis-ci.org/rags/pynt.png?branch=master
Changes
=======
0.8.2 - 23/06/2018
------------------
* private tasks. Any tasks that start with an underscore(_) are private by convention.
0.8.1 - 02/09/2013
------------------
* Enabling extensions
0.8.0 - 02/09/2013
------------------
* Support for specifying a default task with __DEFAULT__ variable
* pynt -v (--version) for displays version info
* pynt -l lists tasks in alphabetical order
0.7.1 - 17/03/2013
------------------
* Migrated pynt to work on python 3.x. pynt still works on 2.7.
* pynt version now displayed as part of help output.
0.7.0 - 16/02/2013
------------------
* New commandline interface. Distribution now includes 'pynt' executable.
* 'build.py' is the default build file.
* Build files no longer need "if main" construct.
* pynt no longer exposes build method. This is a backward incompatible change.
0.6.0 - 17/12/2012
------------------
* Simplified ignoring tasks. ignore a keyword param for task and not a separate decorator. [This change is NOT backward compatible!!!]
* Added support for listing tasks
* Improved help
0.5.0 - 01/12/2012
------------------
* Ability to pass params to tasks.
* Major rewrite and flattening the package hierarchy.
0.4.0 - 17/11/2012
------------------
* Support for running multiple tasks from commandline.
* Ability to run tasks by typing in just the first few unambigious charecters.
Changes before forking from microbuild
======================================
0.3.0 - 18/09/2012
------------------
* Fixed bug in logging. No longer modifies root logger.
* Added ignore functionality.
* Extended API documentation.
0.2.0 - 29/08/2012
------------------
* Added progress tracking output.
* Added handling of exceptions within tasks.
0.1.0 - 28/08/2012
------------------
* Initial release.
* Added management of dependancies between tasks.
* Added automatic generation of command line interface.
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
pynt-0.8.2.tar.gz
(8.9 kB
view details)
Built Distribution
pynt-0.8.2-py3-none-any.whl
(7.9 kB
view details)
File details
Details for the file pynt-0.8.2.tar.gz
.
File metadata
- Download URL: pynt-0.8.2.tar.gz
- Upload date:
- Size: 8.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f38b9b775804eff6e291bd6894669954d94c680b196adee56c96d082a135483c |
|
MD5 | d8242af0c4a20354e25e132e5aa43825 |
|
BLAKE2b-256 | 6e7ab381cb0be91778e74253bb6d7af70bf1b8b62df31df65d7e8bf2531b4822 |
File details
Details for the file pynt-0.8.2-py3-none-any.whl
.
File metadata
- Download URL: pynt-0.8.2-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | be13be37f8237be4a6f6f3031aebcb0c2e61a1894a85a21b85a21e397961c7b3 |
|
MD5 | f4673628be1e575573ede61293beb476 |
|
BLAKE2b-256 | e2d1424f6254c54a42fd8616ce94891207e7c19b20bdb58c776e807bef19a030 |