[PYTHON] Paver Application-Incorporate into the project

The order may change, but it is an advanced version.

You can use the command minilib, which is built into Paver itself, to create a library that zips the frequently used parts of Paver. It's less than 30KB, so if you leave it in your project, you can make it a script that you can use if you have Python installed, even if you don't have Paver installed. This is useful for build / deploy scripts.

Make a minilib

$ paver minilib
---> paver.misctasks.minilib
Generate paver-minilib.zip
$ ls -lh
total 56
-rw-r--r--  1 inada-n  staff    26K  8 27 21:15 paver-minilib.zip

If you include the resulting paver-minilib.zip in your source distribution or put it in version control, it will be available to anyone who does not have Paver installed.

Write a script using minilib

If you do not have Paver installed, the paver command will not be available and you will need to be able to run pavement.py on your own. Anyway, let's give it a shorter name. This time I'll name it pave.

pave


#!/usr/bin/env python
# coding: utf-8
import sys
import os

#Pass the path to minilib.
sys.path.append(os.path.join(os.path.dirname(__file__), 'paver-minilib.zip'))

from paver.easy import *

@task
def hello():
    print "hello"

if __name__ == '__main__':
    # -pavement with f filename.You can specify a file other than py, and
    # sys.argv[0]Use the name of the script file executed by.
    tasks.main(['-f'] + sys.argv)
$ chmod +x pave
$ ./pave hello
---> pavement.hello
hello

Recommended Posts

Paver Application-Incorporate into the project
[Django] Rename the project
Dive into the Django Custom command [1]
Step into the darkness of msync