A pynt of Python build.

Related tags

Build Toolspynt
Overview

Build Status

A pynt of Python build.

Raghunandan Rao

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()
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(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 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

pynt-contrib

pynt-contrib contains a set of extra tasks/utilities. The idea is to keep this package simple and bloat-free.

Contributors/Contributing

If you want to make changes the repo is at https://github.com/rags/pynt. You will need pytest to run the tests

$ ./b t

It will be great if you can raise a pull request once you are done.

If you find any bugs or need new features please raise a ticket in the issues section of the github repo.

License

pynt is licensed under a MIT license

SCons - a software construction tool

SCons - a software construction tool Welcome to the SCons development tree. The real purpose of this tree is to package SCons for production distribut

SCons Project 1.6k Jan 03, 2023
Utilities for interacting with PyPI

twine Twine is a utility for publishing Python packages on PyPI. It provides build system independent uploads of source and binary distribution artifa

Python Packaging Authority 1.4k Jan 05, 2023
A small clone of GNU Make based on file checksums

Pyke This weekend project is a small clone (most of the code is in a single file of just about 200LoC) of GNU Make with the twist that it rebuilds a t

Antonio De Lucreziis 3 Nov 24, 2021
A pynt of Python build.

A pynt of Python build. Raghunandan Rao Features Easy to learn. Build tasks are just python funtions. Manages dependencies between tasks. Automaticall

Raghunandan Rao 154 Jan 04, 2023
This is a python helper package for Telebirr H5 Web payment integration helper.

Project Glow Greetings, I see you have stumbled upon project glow. Project glow is an open source bot worked on by many people to create a good and sa

24 Dec 13, 2022
Program for convert py & js file to exe

Converter JS & PY to Exe Converter Coded by Lamp Requirements : Node.js Python How to Use : Install latest python Dont forget to add path Install node

5 Oct 04, 2021
Python program for installing many tools automatically

Tool Installer is a script made with python which help user in installing tools automatically

Spider Anongreyhat 6 Mar 13, 2022
Python package used on Hardfight projects to make building, testing and deploying easy.

Hardfight Devtools Build, test and deploy Hardfight projects easly 💡 What is it Devtools is a Python tool to make building, testing and deploying int

Hardfight 1 Dec 05, 2021
PlatformIO is a professional collaborative platform for embedded development :alien: A place where Developers and Teams have true Freedom! No more vendor lock-in!

PlatformIO Quick Links: Web | PlatformIO IDE | Project Examples | Docs | Donate | Contact Us Social: LinkedIn | Twitter | Facebook | Community Forums

PlatformIO 6.5k Jan 08, 2023
Python-based project scripting.

Paver - Easy Scripting for Software Projects Web: https://pythonhosted.org/Paver/ Download: https://pypi.python.org/pypi/Paver/ Source: https://github

Paver community 452 Dec 09, 2022
Dev is a Makefile replacement for modern development environments

Dev Dev is a Makefile replacement for modern development environments. Dev let's

Mason Data 9 Dec 09, 2022
Python-based continuous integration testing framework; your pull requests are more than welcome!

Buildbot The Continuous Integration Framework Buildbot is based on original work from Brian Warner, and currently maintained by the Botherders. Visit

Buildbot 5k Jan 05, 2023
Buildout is a deployment automation tool written in and extended with Python

Buildout Buildout is a project designed to solve 2 problems: Application-centric assembly and deployment Assembly runs the gamut from stitching togeth

buildout 552 Nov 26, 2022
Simplified packaging of Python modules

Flit is a simple way to put Python packages and modules on PyPI. It tries to require less thought about packaging and help you avoid common mistakes.

Thomas Kluyver 1.9k Jan 05, 2023
Package, distribute, and update any app for Linux and IoT.

Snapcraft Package, distribute, and update any app for Linux and IoT. Snaps are containerised software packages that are simple to create and install.

1.1k Jan 02, 2023
The Meson Build System

Meson® is a project to create the best possible next-generation build system. Status Dependencies Python (version 3.6 or newer) Ninja (version 1.8.2 o

The Meson Build System 4.4k Jan 02, 2023
Software build automation tool for Python.

PyBuilder — an easy-to-use build automation tool for Python PyBuilder is a software build tool written in 100% pure Python, mainly targeting Python ap

PyBuilder 1.5k Jan 04, 2023
The official binary distribution format for Python

wheel This library is the reference implementation of the Python wheel packaging standard, as defined in PEP 427. It has two different roles: A setupt

Python Packaging Authority 368 Dec 23, 2022
Pythonic task management & command execution.

Welcome to Invoke! Invoke is a Python (2.7 and 3.4+) library for managing shell-oriented subprocesses and organizing executable Python code into CLI-i

3.8k Jan 06, 2023
task management & automation tool

README doit - automation tool doit comes from the idea of bringing the power of build-tools to execute any kind of task Sample Code Define functions r

doit 1.5k Dec 30, 2022