SlideShare uma empresa Scribd logo
1 de 106
Baixar para ler offline
Smoothing Software Project Scripting




                       Kevin Dangoor
                       BlueSkyOnMars.com
                       php|works PyWorks 2008
Python is not
          compiled
(actually, it is, but that’s not important right now)
Python projects
certainly do not need
•   Redistributable files to move
    around
•   Deployment to other machines
•   Interaction with source control
    systems
•   Documentation that’s built from
    the source code
•   Documentation that’s built from a
    format other than its final display
    format
If only there was
  some scripting
language that we
  already knew.
Waitasec. Isn’t
Python a scripting
    language?
Project-related
      scripts need...
•   Command line argument handling
•   Configuration
•   Often work with files
•   Sometimes need to use distutils/
    setuptools, but wish they could do
    a little more
•   Need to work with other common
    tools (Sphinx, svn, virtualenv)
Command-line argument handling




 bin/start-server --port 8675309
Configuration



 [messages]
 greeting=Hello

 [thing1]
 who=World
 message=${messages.greeting}, ${who}
Lots of working with files



 import os

 if not os.path.exists(“foo”):
     os.mkdir(“foo”)
 if not os.path.exists(os.path.join(“foo, “bar”)):
     open(os.path.join(“foo”, “bar”), “w”).write(“Hi”)
Working with distutils/setuptools




 #!/bin/sh

 sphinx-build (blah blah blah)
 python setup.py sdist upload
Other common tools



 sphinx-build ...

 subprocess.Popen(“svn info”... # and do something with the
 output

 virtualenv.create_bootstrap_script(“# more code”)
Do you really want
     separate scripts for
         everything?
•   /usr/local/bin/git                         /usr/local/bin/git-merge-resolve    •   /usr/local/bin/git-fast-import             /usr/local/bin/git-runstatus
•   /usr/local/bin/git-add                     /usr/local/bin/git-merge-stupid     •   /usr/local/bin/git-fetch          /usr/local/bin/git-send-email
•   /usr/local/bin/git-add--interactive        /usr/local/bin/git-merge-subtree    •   /usr/local/bin/git-fetch--tool             /usr/local/bin/git-send-pack
•   /usr/local/bin/git-am                      /usr/local/bin/git-merge-tree       •   /usr/local/bin/git-fetch-pack              /usr/local/bin/git-sh-setup
•   /usr/local/bin/git-annotate                /usr/local/bin/git-mergetool        •   /usr/local/bin/git-filter-branch  /usr/local/bin/git-shell
•   /usr/local/bin/git-apply          /usr/local/bin/git-mktag                     •   /usr/local/bin/git-fmt-merge-msg /usr/local/bin/git-shortlog
•   /usr/local/bin/git-archimport              /usr/local/bin/git-mktree           •   /usr/local/bin/git-for-each-ref            /usr/local/bin/git-show
•   /usr/local/bin/git-archive                 /usr/local/bin/git-mv               •   /usr/local/bin/git-format-patch            /usr/local/bin/git-show-branch
•   /usr/local/bin/git-bisect         /usr/local/bin/git-name-rev                  •   /usr/local/bin/git-fsck                    /usr/local/bin/git-show-index
•   /usr/local/bin/git-blame          /usr/local/bin/git-pack-objects              •   /usr/local/bin/git-fsck-objects            /usr/local/bin/git-show-ref
•   /usr/local/bin/git-branch                  /usr/local/bin/git-pack-redundant   •   /usr/local/bin/git-gc                      /usr/local/bin/git-ssh-fetch
•   /usr/local/bin/git-bundle                  /usr/local/bin/git-pack-refs        •   /usr/local/bin/git-get-tar-commit-id       /usr/local/bin/git-ssh-pull
•   /usr/local/bin/git-cat-file                /usr/local/bin/git-parse-remote     •   /usr/local/bin/git-grep                    /usr/local/bin/git-ssh-push
•   /usr/local/bin/git-check-attr              /usr/local/bin/git-patch-id         •   /usr/local/bin/git-gui                     /usr/local/bin/git-ssh-upload
•   /usr/local/bin/git-check-ref-format        /usr/local/bin/git-peek-remote      •   /usr/local/bin/git-hash-object             /usr/local/bin/git-stash
•   /usr/local/bin/git-checkout                /usr/local/bin/git-prune            •   /usr/local/bin/git-http-fetch              /usr/local/bin/git-status
•   /usr/local/bin/git-checkout-index /usr/local/bin/git-prune-packed              •   /usr/local/bin/git-imap-send               /usr/local/bin/git-stripspace
•   /usr/local/bin/git-cherry                  /usr/local/bin/git-pull             •   /usr/local/bin/git-index-pack              /usr/local/bin/git-submodule
•   /usr/local/bin/git-cherry-pick             /usr/local/bin/git-push             •   /usr/local/bin/git-init                    /usr/local/bin/git-svn
•   /usr/local/bin/git-citool         /usr/local/bin/git-quiltimport               •   /usr/local/bin/git-init-db                 /usr/local/bin/git-svnimport
•   /usr/local/bin/git-clean          /usr/local/bin/git-read-tree                 •   /usr/local/bin/git-instaweb                /usr/local/bin/git-symbolic-ref
•   /usr/local/bin/git-clone          /usr/local/bin/git-rebase                    •   /usr/local/bin/git-local-fetch             /usr/local/bin/git-tag
•   /usr/local/bin/git-commit                  /usr/local/bin/git-rebase--         •   /usr/local/bin/git-log                     /usr/local/bin/git-tar-tree
    interactive                                                                    •   /usr/local/bin/git-lost-found              /usr/local/bin/git-unpack-file
•   /usr/local/bin/git-commit-tree             /usr/local/bin/git-receive-pack     •   /usr/local/bin/git-ls-files       /usr/local/bin/git-unpack-objects
•   /usr/local/bin/git-config         /usr/local/bin/git-reflog                    •   /usr/local/bin/git-ls-remote               /usr/local/bin/git-update-index
•   /usr/local/bin/git-convert-objects         /usr/local/bin/git-relink           •   /usr/local/bin/git-ls-tree                 /usr/local/bin/git-update-ref
•   /usr/local/bin/git-count-objects /usr/local/bin/git-remote                     •   /usr/local/bin/git-mailinfo                /usr/local/bin/git-update-server-info
•   /usr/local/bin/git-cvsexportcommit         /usr/local/bin/git-repack           •   /usr/local/bin/git-mailsplit               /usr/local/bin/git-upload-archive
•   /usr/local/bin/git-cvsimport               /usr/local/bin/git-repo-config      •   /usr/local/bin/git-merge          /usr/local/bin/git-upload-pack
•   /usr/local/bin/git-cvsserver               /usr/local/bin/git-request-pull     •   /usr/local/bin/git-merge-base              /usr/local/bin/git-var
•   /usr/local/bin/git-daemon                  /usr/local/bin/git-rerere           •   /usr/local/bin/git-merge-file              /usr/local/bin/git-verify-pack
•   /usr/local/bin/git-describe                /usr/local/bin/git-reset            •   /usr/local/bin/git-merge-index             /usr/local/bin/git-verify-tag
•   /usr/local/bin/git-diff                    /usr/local/bin/git-rev-list         •   /usr/local/bin/git-merge-octopus /usr/local/bin/git-whatchanged
•   /usr/local/bin/git-diff-files              /usr/local/bin/git-rev-parse        •   /usr/local/bin/git-merge-one-file /usr/local/bin/git-write-tree
•   /usr/local/bin/git-diff-index              /usr/local/bin/git-revert           •   /usr/local/bin/git-merge-ours              /usr/local/bin/gitk
•   /usr/local/bin/git-diff-tree               /usr/local/bin/git-rm               •   /usr/local/bin/git-merge-recursive
easy_install Paver
paver paverdocs
pavement.py
Why Python build
         files?
•   You already know Python
•   The language rules are well-defined
•   The language rules are well-
    documented
•   Python is powerful, so you’ll never
    be left hanging or need an escape
    hatch
Pavements are almost standard
Python




 from paver.defaults import *
Configuration
   options(
    setup = setup_meta,
    minilib=Bunch(
         extra_files=['doctools', 'virtual']
    ),
    sphinx=Bunch(
         builddir=quot;buildquot;,
         sourcedir=quot;sourcequot;
    ),
    virtualenv=Bunch(
         packages_to_install=[quot;nosequot;, quot;sphinxquot;, quot;docutilsquot;,
quot;virtualenvquot;],
         install_paver=False,
         script_name='bootstrap.py',
         paver_command_line=None
    )
)
Configuration
   options(
    setup = setup_meta,
    minilib=Bunch(
         extra_files=['doctools', 'virtual']
    ),
    sphinx=Bunch(
         builddir=quot;buildquot;,
         sourcedir=quot;sourcequot;
    ),
    virtualenv=Bunch(
         packages_to_install=[quot;nosequot;, quot;sphinxquot;, quot;docutilsquot;,
quot;virtualenvquot;],
         install_paver=False,
         script_name='bootstrap.py',
         paver_command_line=None
    )
)
Configuration
   options(
    setup = setup_meta,
    minilib=Bunch(
         extra_files=['doctools', 'virtual']
    ),
    sphinx=Bunch(
         builddir=quot;buildquot;,
         sourcedir=quot;sourcequot;
    ),
    virtualenv=Bunch(
         packages_to_install=[quot;nosequot;, quot;sphinxquot;, quot;docutilsquot;,
quot;virtualenvquot;],
         install_paver=False,
         script_name='bootstrap.py',
         paver_command_line=None
    )
)
Configuration
   options(
    setup = setup_meta,
    minilib=Bunch(
         extra_files=['doctools', 'virtual']
    ),
    sphinx=Bunch(
         builddir=quot;buildquot;,
         sourcedir=quot;sourcequot;
    ),
    virtualenv=Bunch(
         packages_to_install=[quot;nosequot;, quot;sphinxquot;, quot;docutilsquot;,
quot;virtualenvquot;],
         install_paver=False,
         script_name='bootstrap.py',
         paver_command_line=None
    )
)
Configuration
   options(
    setup = setup_meta,
    minilib=Bunch(
         extra_files=['doctools', 'virtual']
    ),
    sphinx=Bunch(
         builddir=quot;buildquot;,
         sourcedir=quot;sourcequot;
    ),
    virtualenv=Bunch(
         packages_to_install=[quot;nosequot;, quot;sphinxquot;, quot;docutilsquot;,
quot;virtualenvquot;],
         install_paver=False,
         script_name='bootstrap.py',
         paver_command_line=None
    )
)
Configuration
   options(
    setup = setup_meta,
    minilib=Bunch(
         extra_files=['doctools', 'virtual']
    ),
    sphinx=Bunch(
         builddir=quot;buildquot;,
         sourcedir=quot;sourcequot;
    ),
    virtualenv=Bunch(
         packages_to_install=[quot;nosequot;, quot;sphinxquot;, quot;docutilsquot;,
quot;virtualenvquot;],
         install_paver=False,
         script_name='bootstrap.py',
         paver_command_line=None
    )
)
Configuration
   options(
    setup = setup_meta,
    minilib=Bunch(
         extra_files=['doctools', 'virtual']
    ),
    sphinx=Bunch(
         builddir=quot;buildquot;,
         sourcedir=quot;sourcequot;
    ),
    virtualenv=Bunch(
         packages_to_install=[quot;nosequot;, quot;sphinxquot;, quot;docutilsquot;,
quot;virtualenvquot;],
         install_paver=False,
         script_name='bootstrap.py',
         paver_command_line=None
    )
)
Dynamic config values




 >>> from paver.defaults import *
 >>> import time
 >>> options(current=lambda: time.time())
 >>> options.current
 1216726815.0027969
Namespace searching



 >>> options(
 ...     setup=Bunch(version=quot;1.0quot;),
 ...     sphinx=Bunch(builddir=quot;docbuildquot;)
 ... )
 >>> options.version
 '1.0'
Namespace searching (continued)


 >>> options(
 ...     setup=Bunch(version=quot;1.0quot;),
 ...     sphinx=Bunch(builddir=quot;docbuildquot;)
 ... )
 >>> options.order('sphinx')
 >>> options.version
 Traceback (most recent call last):
   File quot;<stdin>quot;, line 1, in <module>
   File quot;/Users/admin/projects/paver/paver/runtime.pyquot;, line
 31, in __getattr__
     raise AttributeError(name)
 AttributeError: version
Namespace searching (continued)


 >>> options(
 ...     setup=Bunch(version=quot;1.0quot;),
 ...     sphinx=Bunch(builddir=quot;docbuildquot;)
 ... )
 >>> options.order('sphinx')
 >>> options.version
 Traceback (most recent call last):
   File quot;<stdin>quot;, line 1, in <module>
   File quot;/Users/admin/projects/paver/paver/runtime.pyquot;, line
 31, in __getattr__
     raise AttributeError(name)
 AttributeError: version
Namespace searching (continued)


 >>> options(
 ...     setup=Bunch(version=quot;1.0quot;),
 ...     sphinx=Bunch(builddir=quot;docbuildquot;)
 ... )
 >>> options.order('sphinx')
 >>> options.version
 Traceback (most recent call last):
   File quot;<stdin>quot;, line 1, in <module>
   File quot;/Users/admin/projects/paver/paver/runtime.pyquot;, line
 31, in __getattr__
     raise AttributeError(name)
 AttributeError: version
Configuration is
     still standard
         Python
•   You can treat options like a normal,
    nested dictionary
•   The only unusual thing would be
    that callables are called.
Tasks



 @task
 def clean():
     quot;quot;quot;Cleans up this paver directory. Removes the virtualenv
 traces and
     the build directory.quot;quot;quot;
     pass
Tasks



 @task
 def clean():
     quot;quot;quot;Cleans up this paver directory. Removes the virtualenv
 traces and
     the build directory.quot;quot;quot;
     pass
Tasks



 @task
 def clean():
     quot;quot;quot;Cleans up this paver directory. Removes the virtualenv
 traces and
     the build directory.quot;quot;quot;
     pass
Tasks



 @task
 def clean():
     quot;quot;quot;Cleans up this paver directory. Removes the virtualenv
 traces and
     the build directory.quot;quot;quot;
     pass
Tasks



 @task
 def clean():
     quot;quot;quot;Cleans up this paver directory. Removes the virtualenv
 traces and
     the build directory.quot;quot;quot;
     pass
paver help
 $ paver help
 ---> help
 Paver 0.8.1

 Usage: paver [global options] [option.name=value] task [task
 options] [task...]

 Run 'paver help [section]' to see the following sections of
 info:

 options    global command line options
 setup      available distutils/setuptools tasks
 tasks      all tasks that have been imported by your pavement

 'paver help taskname' will display details for a task.

 Tasks defined in your pavement:
   bootstrap - Build a virtualenv bootstrap for developing
paver help
 $ paver help
 ---> help
 Paver 0.8.1

 Usage: paver [global options] [option.name=value] task [task
 options] [task...]

 Run 'paver help [section]' to see the following sections of
 info:

 options    global command line options
 setup      available distutils/setuptools tasks
 tasks      all tasks that have been imported by your pavement

 'paver help taskname' will display details for a task.

 Tasks defined in your pavement:
   bootstrap - Build a virtualenv bootstrap for developing
paver help
 $ paver help
 ---> help
 Paver 0.8.1

 Usage: paver [global options] [option.name=value] task [task
 options] [task...]

 Run 'paver help [section]' to see the following sections of
 info:

 options    global command line options
 setup      available distutils/setuptools tasks
 tasks      all tasks that have been imported by your pavement

 'paver help taskname' will display details for a task.

 Tasks defined in your pavement:
   bootstrap - Build a virtualenv bootstrap for developing
paver help
 $ paver help
 ---> help
 Paver 0.8.1

 Usage: paver [global options] [option.name=value] task [task
 options] [task...]

 Run 'paver help [section]' to see the following sections of
 info:

 options    global command line options
 setup      available distutils/setuptools tasks
 tasks      all tasks that have been imported by your pavement

 'paver help taskname' will display details for a task.

 Tasks defined in your pavement:
   bootstrap - Build a virtualenv bootstrap for developing
paver help
 $ paver help
 ---> help
 Paver 0.8.1

 Usage: paver [global options] [option.name=value] task [task
 options] [task...]

 Run 'paver help [section]' to see the following sections of
 info:

 options    global command line options
 setup      available distutils/setuptools tasks
 tasks      all tasks that have been imported by your pavement

 'paver help taskname' will display details for a task.

 Tasks defined in your pavement:
   bootstrap - Build a virtualenv bootstrap for developing
paver help tasks
 Tasks defined in and imported by your pavement:
   bootstrap                - Build a virtualenv bootstrap for
 developing paver
   clean                    - Cleans up this paver directory
   cog                      - Runs the cog code generator
 against the files matching your
     specification
   commit                   - Removes the generated code from
 the docs and then commits to bzr
   deploy                   - Copy the Paver website up
   doc_clean                - Clean (delete) the built docs
   generate_setup           - Generates a setup
   help                     - Displays the list of commands and
 the details
   html                     - Build Paver's documentation and
 install it into paver/docs
   minilib                  - Create a Paver mini library that
 contains enough for a simple
paver help <taskname>

 Details for minilib:
 Create a Paver mini library that contains enough for a simple
      pavement.py to be installed using a generated setup.py.
 This
      is a good temporary measure until more people have
 deployed paver.
      The output file is 'paver-minilib.zip' in the current
 directory.

     Options:

     extra_files
         list of other paver modules to include (don't include
 the .py
         extension)
@needs



 @task
 @needs(quot;uncogquot;)
 def commit():
     quot;quot;quot;Removes the generated code from the docs and then
 commits to bzr.quot;quot;quot;
     pass
@needs



 @task
 @needs(quot;uncogquot;)
 def commit():
     quot;quot;quot;Removes the generated code from the docs and then
 commits to bzr.quot;quot;quot;
     pass
@needs



 @task
 @needs(quot;uncogquot;)
 def commit():
     quot;quot;quot;Removes the generated code from the docs and then
 commits to bzr.quot;quot;quot;
     pass
call_task




 call_task(‘commit’)
@cmdopts



 @task
 @cmdopts([(quot;username=quot;, quot;uquot;, quot;Username for remote serverquot;),
           (quot;server=quot;, quot;squot;, quot;Server to deploy toquot;)])
 def deploy():
     quot;quot;quot;Copy the Paver website up.quot;quot;quot;
      pass
paver <taskname>




 $ paver generate_setup minilib
 ---> generate_setup
 Write setup.py
 ---> minilib
 Generate paver-minilib.zip
Paver and Distutils/
    Setuptools
“Using the Distutils is quite
  simple, both for module
 developers and for users/
 administrators installing
    third-party modules.”
    – Distributing Python Modules, section 1.1
python setup.py
    install
Paver extends
  Distutils
paver install
setup.py example




   from distutils.core import setup
setup(name='foo',
       version='1.0',
       py_modules=['foo'],
       )
setup.py example




   from distutils.core import setup
setup(name='foo',
       version='1.0',
       py_modules=['foo'],
       )
setup.py example




   from distutils.core import setup
setup(name='foo',
       version='1.0',
       py_modules=['foo'],
       )
setup.py example




   from distutils.core import setup
setup(name='foo',
       version='1.0',
       py_modules=['foo'],
       )
setup.py example




   from distutils.core import setup
setup(name='foo',
       version='1.0',
       py_modules=['foo'],
       )
Upgrading to Paver



    options(
     setup = Bunch(name='foo',
        version='1.0',
        py_modules=['foo'],
        )
)
Keeping it simple for users




 $ paver generate_setup minilib
 ---> generate_setup
 Write setup.py
 ---> minilib
 Generate paver-minilib.zip
Generated setup.py



  import os
if os.path.exists(quot;paver-minilib.zipquot;):
    import sys
    sys.path.insert(0, quot;paver-minilib.zipquot;)

import paver.command
paver.command.main()
The Paver Standard Library
(is actually newer and less musty)
The Paver Standard
      Library
•   Runtime helpers (paver.runtime)
•   Distutils integration (paver.setuputils)
•   File handling (paver.path)
•   Documentation tools (paver.doctools)
•   Subversion (paver.svn)
•   SSH (paver.ssh)
•   Virtualenv (paver.virtual)
•   Miscellaneous Tasks (paver.misctasks)
paver.runtime



 # display text if verbose is set
 debug(“Hi there. Feeling chatty today?”)

 # display text if quiet is not set
 info(“Glad we don’t have to keep quiet”)

 # display text regardless of setting
 error(“HA! I’M SHOUTING AND YOU CAN’T STOP ME!”)
paver.runtime



 # display text if verbose is set
 debug(“Hi there. Feeling chatty today?”)

 # display text if quiet is not set
 info(“Glad we don’t have to keep quiet”)

 # display text regardless of setting
 error(“HA! I’M SHOUTING AND YOU CAN’T STOP ME!”)
paver.runtime



 # display text if verbose is set
 debug(“Hi there. Feeling chatty today?”)

 # display text if quiet is not set
 info(“Glad we don’t have to keep quiet”)

 # display text regardless of setting
 error(“HA! I’M SHOUTING AND YOU CAN’T STOP ME!”)
paver.runtime



 # display text if verbose is set
 debug(“Hi there. Feeling chatty today?”)

 # display text if quiet is not set
 info(“Glad we don’t have to keep quiet”)

 # display text regardless of setting
 error(“HA! I’M SHOUTING AND YOU CAN’T STOP ME!”)
paver.runtime



 # display text if verbose is set
 debug(“Hi there. Feeling chatty today?”)

 # display text if quiet is not set
 info(“Glad we don’t have to keep quiet”)

 # display text regardless of setting
 error(“HA! I’M SHOUTING AND YOU CAN’T STOP ME!”)
paver.runtime



 # display text if verbose is set
 debug(“Hi there. Feeling chatty today?”)

 # display text if quiet is not set
 info(“Glad we don’t have to keep quiet”)

 # display text regardless of setting
 error(“HA! I’M SHOUTING AND YOU CAN’T STOP ME!”)
paver.runtime



 # display text if verbose is set
 debug(“Hi there. Feeling chatty today?”)

 # display text if quiet is not set
 info(“Glad we don’t have to keep quiet”)

 # display text regardless of setting
 error(“HA! I’M SHOUTING AND YOU CAN’T STOP ME!”)
paver.runtime (continued)



 # run a command, as long as dry-run is off
 # capture the output into myval
 myval = sh(“cat /tmp/foo”, capture=True)

 # run a function (delete_all(‘/’) to be exact).
 # if dry-run is set, then
 # just print the message instead
 dry(“Delete everything”, delete_all, ‘/’)
paver.runtime (continued)



 # run a command, as long as dry-run is off
 # capture the output into myval
 myval = sh(“cat /tmp/foo”, capture=True)

 # run a function (delete_all(‘/’) to be exact).
 # if dry-run is set, then
 # just print the message instead
 dry(“Delete everything”, delete_all, ‘/’)
paver.runtime (continued)



 # run a command, as long as dry-run is off
 # capture the output into myval
 myval = sh(“cat /tmp/foo”, capture=True)

 # run a function (delete_all(‘/’) to be exact).
 # if dry-run is set, then
 # just print the message instead
 dry(“Delete everything”, delete_all, ‘/’)
paver.runtime (continued)



 # run a command, as long as dry-run is off
 # capture the output into myval
 myval = sh(“cat /tmp/foo”, capture=True)

 # run a function (delete_all(‘/’) to be exact).
 # if dry-run is set, then
 # just print the message instead
 dry(“Delete everything”, delete_all, ‘/’)
paver.runtime (continued)



 # run a command, as long as dry-run is off
 # capture the output into myval
 myval = sh(“cat /tmp/foo”, capture=True)

 # run a function (delete_all(‘/’) to be exact).
 # if dry-run is set, then
 # just print the message instead
 dry(“Delete everything”, delete_all, ‘/’)
paver.setuputils




 options.setup.package_data =
    setuputils.find_package_data(quot;paverquot;, package=quot;paverquot;,
                               only_in_packages=False)
paver.path
•   Jason Orendorff’s path.py module
    (also available separately)
•   It’s a subclass of string!
•   Fun use of operator overloading
•   Lots of great methods
•   Makes working with files/directories
    fun and easy
paver.path examples




   p = path(quot;docsquot;)
tmpdir = p / quot;tmpquot;
tmpdir.mkdir()
fn = tmpdir / quot;myfile.txtquot;
fn.write_text(quot;Hi there!quot;)
paver.path examples




   p = path(quot;docsquot;)
tmpdir = p / quot;tmpquot;
tmpdir.mkdir()
fn = tmpdir / quot;myfile.txtquot;
fn.write_text(quot;Hi there!quot;)
paver.path examples




   p = path(quot;docsquot;)
tmpdir = p / quot;tmpquot;
tmpdir.mkdir()
fn = tmpdir / quot;myfile.txtquot;
fn.write_text(quot;Hi there!quot;)
paver.path examples




   p = path(quot;docsquot;)
tmpdir = p / quot;tmpquot;
tmpdir.mkdir()
fn = tmpdir / quot;myfile.txtquot;
fn.write_text(quot;Hi there!quot;)
paver.path examples




   p = path(quot;docsquot;)
tmpdir = p / quot;tmpquot;
tmpdir.mkdir()
fn = tmpdir / quot;myfile.txtquot;
fn.write_text(quot;Hi there!quot;)
paver.path examples




   p = path(quot;docsquot;)
tmpdir = p / quot;tmpquot;
tmpdir.mkdir()
fn = tmpdir / quot;myfile.txtquot;
fn.write_text(quot;Hi there!quot;)
paver.path examples




   p = path(quot;docsquot;)
tmpdir = p / quot;tmpquot;
tmpdir.mkdir()
fn = tmpdir / quot;myfile.txtquot;
fn.write_text(quot;Hi there!quot;)
paver.doctools




 # add this to use
 import paver.doctools
paver.doctools – Sphinx

   paver.doctools.html()¶
Build HTML documentation using Sphinx. This uses the following options in a
“sphinx” section of the options.
docroot
the root under which Sphinx will be working. Default: docs
builddir
directory under the docroot where the resulting files are put. default: build
sourcedir
directory under the docroot for the source files default: (empty string)

paver.doctools.doc_clean()¶
Clean (delete) the built docs. Specifically, this deletes the build directory under the
docroot. See the html task for the options list.
paver.doctools –
Cog & SectionedFile
•   Solutions to common problems of
    creating high-quality docs
•   Ideally, your code samples will be in
    convenient runnable code files and
    have unit tests.
•   But you also want nice, minimal
    code samples in your text as you’re
    writing.
paver.doctools sample code



  # mysample.py

# [[[section mysample]]]
def sample_func():
    print quot;To sample, or not to sample?quot;
# [[[endsection]]]
paver.doctools in docs




 And then when you want to print the sample string, you just
 call::

     # [[[cog include(“code/mysample.py”, “mysample”)]]]
     # [[[end]]]
paver.doctools in docs (2)



 And then when you want to print the sample string, you just
 call::

     # [[[cog include(“code/mysample.py”, “mysample”)]]]
     def sample_func():
         print quot;To sample, or not to sample?quot;
     # [[[end]]]
paver.doctools uncog before
commit



 @task
 @needs(quot;uncogquot;)
 def commit():
     quot;quot;quot;Removes the generated code from the docs and then
 commits to bzr.quot;quot;quot;
     sh(quot;bzr commitquot;)
paver.svn

  paver.svn.checkout(url, dest, revision='')
Checks out the specified URL to the given destination.

paver.svn.checkup(url, dest, revision='')
Does a checkout or update, depending on whether the destination exists and is up
to date (if a revision is passed in). Returns true if a checkout or update was
performed. False otherwise.

paver.svn.info(path='')
Retrieves the svn info for the path and returns a dictionary of the values. Names
are normalized to lower case with spaces converted to underscores.

paver.svn.update(path='', revision='')
Run an svn update on the given path.



Example at: https://projects.sitepen.com/toolbox/svn/trunk/pavement.py
paver.ssh




 paver.ssh.scp(source, dest)
     Copy the source file to the destination.
paver.virtual

   paver.virtual.bootstrap()
Creates a virtualenv bootstrap script. The script will create a bootstrap script that
populates a virtualenv in the current directory. The environment will have paver,
the packages of your choosing and will run the paver command of your choice.
This task looks in the virtualenv options for:
script_name
name of the generated script

packages_to_install
packages to install with easy_install. The version of paver that you are using is
included automatically. This should be a list of strings.

paver_command_line
run this paver command line after installation (just the command line arguments,
not the paver command itself).
paver.misctasks


   paver.misctasks.generate_setup()

paver.misctasks.help()

paver.misctasks.minilib()
Options:
extra_files
list of other paver modules to include (donʼt include the .py extension)

paver.misctasks.paverdocs()
Pulling it all
         together
•   write functions with the @task
    decorator.
•   Just plain old Python with lots of
    conveniences
•   Paver’s pavement.py is a good
    example
•   Even better, take a look at
    “Getting Started with Paver”
    http://bit.ly/starting_paver
Remember this?




 #!/bin/sh

 sphinx-build (blah blah blah)
 python setup.py sdist upload
Paver needs to do that too



 @task
 @needs(['html', quot;minilibquot;, quot;generate_setupquot;,
 “setuptools.command.sdist”])
 def sdist():
     quot;quot;quot;Builds the documentation and the tarball.quot;quot;quot;
     pass
But wait, it does more!


 @task
 @needs(['cog', 'paver.doctools.html'])
 def html():
     quot;quot;quot;Build Paver's documentation and install it into paver/
 docsquot;quot;quot;
     builtdocs = path(quot;docsquot;) / options.sphinx.builddir /
 quot;htmlquot;
     destdir = path(quot;paverquot;) / quot;docsquot;
     destdir.rmtree()
     builtdocs.move(destdir)
Changes coming to
      Paver
•   The little bit of magic goes away
•   Support for CloudControl
•   Ability to run sub-builds easily
•   Virtualenv/pyinstall management
•   zc.buildout recipe running
Credits
•   Thanks to SitePen for supporting Paver
•   Bumpy road
    http://flickr.com/photos/ilya/442034/sizes/o/
•   Smooth road
    http://flickr.com/photos/nicholas_t/317528561/
•   Options (Anna’s hairdo)
    http://flickr.com/photos/alangley/2136034468/
•   Tasks
    http://flickr.com/photos/mpwillis/470557535/
http://
www.blueskyonmars.
  com/projects/
      paver/

Mais conteúdo relacionado

Mais procurados

First there was the command line
First there was the command lineFirst there was the command line
First there was the command lineAdrian Cardenas
 
Conquering the Command Line
Conquering the Command LineConquering the Command Line
Conquering the Command LineAdrian Cardenas
 
Learning the command line
Learning the command lineLearning the command line
Learning the command lineAdrian Cardenas
 
Go Web Development
Go Web DevelopmentGo Web Development
Go Web DevelopmentCheng-Yi Yu
 
What is suid, sgid and sticky bit
What is suid, sgid and sticky bit  What is suid, sgid and sticky bit
What is suid, sgid and sticky bit Meenu Chopra
 
Unix shell scripting basics
Unix shell scripting basicsUnix shell scripting basics
Unix shell scripting basicsAbhay Sapru
 
GIT rozproszony system kontroli wersji
GIT rozproszony system kontroli wersjiGIT rozproszony system kontroli wersji
GIT rozproszony system kontroli wersji3camp
 
2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Herokuronnywang_tw
 
Unix shell scripting basics
Unix shell scripting basicsUnix shell scripting basics
Unix shell scripting basicsManav Prasad
 
Phishing for Root (How I Got Access to Root on Your Computer With 8 Seconds o...
Phishing for Root (How I Got Access to Root on Your Computer With 8 Seconds o...Phishing for Root (How I Got Access to Root on Your Computer With 8 Seconds o...
Phishing for Root (How I Got Access to Root on Your Computer With 8 Seconds o...Vi Grey
 
コンテナ仮想、その裏側 〜user namespaceとrootlessコンテナ〜
コンテナ仮想、その裏側 〜user namespaceとrootlessコンテナ〜コンテナ仮想、その裏側 〜user namespaceとrootlessコンテナ〜
コンテナ仮想、その裏側 〜user namespaceとrootlessコンテナ〜Retrieva inc.
 
On secure application of PHP wrappers
On secure application  of PHP wrappersOn secure application  of PHP wrappers
On secure application of PHP wrappersPositive Hack Days
 

Mais procurados (18)

儲かるドキュメント
儲かるドキュメント儲かるドキュメント
儲かるドキュメント
 
Troubleshooting Puppet
Troubleshooting PuppetTroubleshooting Puppet
Troubleshooting Puppet
 
test
testtest
test
 
First there was the command line
First there was the command lineFirst there was the command line
First there was the command line
 
Conquering the Command Line
Conquering the Command LineConquering the Command Line
Conquering the Command Line
 
Learning the command line
Learning the command lineLearning the command line
Learning the command line
 
Backups
BackupsBackups
Backups
 
Unix shell scripting
Unix shell scriptingUnix shell scripting
Unix shell scripting
 
Go Web Development
Go Web DevelopmentGo Web Development
Go Web Development
 
What is suid, sgid and sticky bit
What is suid, sgid and sticky bit  What is suid, sgid and sticky bit
What is suid, sgid and sticky bit
 
Unix shell scripting basics
Unix shell scripting basicsUnix shell scripting basics
Unix shell scripting basics
 
GIT rozproszony system kontroli wersji
GIT rozproszony system kontroli wersjiGIT rozproszony system kontroli wersji
GIT rozproszony system kontroli wersji
 
2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku
 
Unix shell scripting basics
Unix shell scripting basicsUnix shell scripting basics
Unix shell scripting basics
 
Phishing for Root (How I Got Access to Root on Your Computer With 8 Seconds o...
Phishing for Root (How I Got Access to Root on Your Computer With 8 Seconds o...Phishing for Root (How I Got Access to Root on Your Computer With 8 Seconds o...
Phishing for Root (How I Got Access to Root on Your Computer With 8 Seconds o...
 
git internals
git internalsgit internals
git internals
 
コンテナ仮想、その裏側 〜user namespaceとrootlessコンテナ〜
コンテナ仮想、その裏側 〜user namespaceとrootlessコンテナ〜コンテナ仮想、その裏側 〜user namespaceとrootlessコンテナ〜
コンテナ仮想、その裏側 〜user namespaceとrootlessコンテナ〜
 
On secure application of PHP wrappers
On secure application  of PHP wrappersOn secure application  of PHP wrappers
On secure application of PHP wrappers
 

Destaque

Paver: the build tool you missed
Paver: the build tool you missedPaver: the build tool you missed
Paver: the build tool you missedalmadcz
 
Mechanical Briquetting Press System-Comaco
Mechanical Briquetting Press System-ComacoMechanical Briquetting Press System-Comaco
Mechanical Briquetting Press System-ComacoJaipreet Singh Bahra
 
Comaco strategic plan
Comaco strategic planComaco strategic plan
Comaco strategic planJan Sørensen
 
Shree Sai Pavers Presentation.pptx
Shree Sai Pavers Presentation.pptxShree Sai Pavers Presentation.pptx
Shree Sai Pavers Presentation.pptxshree sai pavers
 
Experimental behaviour and analysis of stress in rigid pavement
Experimental behaviour and analysis of stress in rigid pavementExperimental behaviour and analysis of stress in rigid pavement
Experimental behaviour and analysis of stress in rigid pavementVivek Loyola
 
Construction of rigid pavement
Construction of rigid pavementConstruction of rigid pavement
Construction of rigid pavementpradip dangar
 
Rigid pavement
Rigid pavementRigid pavement
Rigid pavementpjainrahul
 
Rigid pavement distress
Rigid pavement distress Rigid pavement distress
Rigid pavement distress Ankit Sarkar
 
Flexible and-rigid-pavements
Flexible and-rigid-pavementsFlexible and-rigid-pavements
Flexible and-rigid-pavementsHARITSEHRAWAT
 
Construction of roads presentations
Construction of roads presentationsConstruction of roads presentations
Construction of roads presentationsIjaz Hassan Khan
 
Lect 6 pavement design
Lect 6 pavement designLect 6 pavement design
Lect 6 pavement designM Firdaus
 

Destaque (16)

Odell permeable pavers-2of3
Odell permeable pavers-2of3Odell permeable pavers-2of3
Odell permeable pavers-2of3
 
Paver: the build tool you missed
Paver: the build tool you missedPaver: the build tool you missed
Paver: the build tool you missed
 
Asphalt paver
Asphalt  paverAsphalt  paver
Asphalt paver
 
Mechanical Briquetting Press System-Comaco
Mechanical Briquetting Press System-ComacoMechanical Briquetting Press System-Comaco
Mechanical Briquetting Press System-Comaco
 
Comaco strategic plan
Comaco strategic planComaco strategic plan
Comaco strategic plan
 
Shree Sai Pavers Presentation.pptx
Shree Sai Pavers Presentation.pptxShree Sai Pavers Presentation.pptx
Shree Sai Pavers Presentation.pptx
 
Perkerasan kaku
Perkerasan kakuPerkerasan kaku
Perkerasan kaku
 
Experimental behaviour and analysis of stress in rigid pavement
Experimental behaviour and analysis of stress in rigid pavementExperimental behaviour and analysis of stress in rigid pavement
Experimental behaviour and analysis of stress in rigid pavement
 
Rigid pavements
Rigid pavements Rigid pavements
Rigid pavements
 
design of rigid
design of rigiddesign of rigid
design of rigid
 
Construction of rigid pavement
Construction of rigid pavementConstruction of rigid pavement
Construction of rigid pavement
 
Rigid pavement
Rigid pavementRigid pavement
Rigid pavement
 
Rigid pavement distress
Rigid pavement distress Rigid pavement distress
Rigid pavement distress
 
Flexible and-rigid-pavements
Flexible and-rigid-pavementsFlexible and-rigid-pavements
Flexible and-rigid-pavements
 
Construction of roads presentations
Construction of roads presentationsConstruction of roads presentations
Construction of roads presentations
 
Lect 6 pavement design
Lect 6 pavement designLect 6 pavement design
Lect 6 pavement design
 

Semelhante a Paver For PyWorks 2008

GTFO: Git Theory For OpenSource
GTFO: Git Theory For OpenSourceGTFO: Git Theory For OpenSource
GTFO: Git Theory For OpenSourceForest Mars
 
Automate Yo'self -- SeaGL
Automate Yo'self -- SeaGL Automate Yo'self -- SeaGL
Automate Yo'self -- SeaGL John Anderson
 
Globus toolkit4installationguide
Globus toolkit4installationguideGlobus toolkit4installationguide
Globus toolkit4installationguideAdarsh Patil
 
Bundling Packages and Deploying Applications with RPM
Bundling Packages and Deploying Applications with RPMBundling Packages and Deploying Applications with RPM
Bundling Packages and Deploying Applications with RPMAlexander Shopov
 
mapserver_install_linux
mapserver_install_linuxmapserver_install_linux
mapserver_install_linuxtutorialsruby
 
mapserver_install_linux
mapserver_install_linuxmapserver_install_linux
mapserver_install_linuxtutorialsruby
 
mapserver_install_linux
mapserver_install_linuxmapserver_install_linux
mapserver_install_linuxtutorialsruby
 
Apache Hadoop Shell Rewrite
Apache Hadoop Shell RewriteApache Hadoop Shell Rewrite
Apache Hadoop Shell RewriteAllen Wittenauer
 
Dev ninja -> vagrant + virtualbox + chef-solo + git + ec2
Dev ninja  -> vagrant + virtualbox + chef-solo + git + ec2Dev ninja  -> vagrant + virtualbox + chef-solo + git + ec2
Dev ninja -> vagrant + virtualbox + chef-solo + git + ec2Yros
 
[MeetUp][2nd] 컭on턺
[MeetUp][2nd] 컭on턺[MeetUp][2nd] 컭on턺
[MeetUp][2nd] 컭on턺InfraEngineer
 
Bash is not a second zone citizen programming language
Bash is not a second zone citizen programming languageBash is not a second zone citizen programming language
Bash is not a second zone citizen programming languageRené Ribaud
 
Source Code Management systems
Source Code Management systemsSource Code Management systems
Source Code Management systemsxSawyer
 
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...Puppet
 
Virtualenv
VirtualenvVirtualenv
VirtualenvWEBdeBS
 
Ruby and Rails Packaging to Production
Ruby and Rails Packaging to ProductionRuby and Rails Packaging to Production
Ruby and Rails Packaging to ProductionFabio Kung
 
nouka inventry manager
nouka inventry managernouka inventry manager
nouka inventry managerToshiaki Baba
 

Semelhante a Paver For PyWorks 2008 (20)

Git::Hooks
Git::HooksGit::Hooks
Git::Hooks
 
GTFO: Git Theory For OpenSource
GTFO: Git Theory For OpenSourceGTFO: Git Theory For OpenSource
GTFO: Git Theory For OpenSource
 
Automate Yo'self -- SeaGL
Automate Yo'self -- SeaGL Automate Yo'self -- SeaGL
Automate Yo'self -- SeaGL
 
私の開発環境
私の開発環境私の開発環境
私の開発環境
 
Globus toolkit4installationguide
Globus toolkit4installationguideGlobus toolkit4installationguide
Globus toolkit4installationguide
 
Bundling Packages and Deploying Applications with RPM
Bundling Packages and Deploying Applications with RPMBundling Packages and Deploying Applications with RPM
Bundling Packages and Deploying Applications with RPM
 
mapserver_install_linux
mapserver_install_linuxmapserver_install_linux
mapserver_install_linux
 
mapserver_install_linux
mapserver_install_linuxmapserver_install_linux
mapserver_install_linux
 
mapserver_install_linux
mapserver_install_linuxmapserver_install_linux
mapserver_install_linux
 
Apache Hadoop Shell Rewrite
Apache Hadoop Shell RewriteApache Hadoop Shell Rewrite
Apache Hadoop Shell Rewrite
 
Dev ninja -> vagrant + virtualbox + chef-solo + git + ec2
Dev ninja  -> vagrant + virtualbox + chef-solo + git + ec2Dev ninja  -> vagrant + virtualbox + chef-solo + git + ec2
Dev ninja -> vagrant + virtualbox + chef-solo + git + ec2
 
[MeetUp][2nd] 컭on턺
[MeetUp][2nd] 컭on턺[MeetUp][2nd] 컭on턺
[MeetUp][2nd] 컭on턺
 
Bash is not a second zone citizen programming language
Bash is not a second zone citizen programming languageBash is not a second zone citizen programming language
Bash is not a second zone citizen programming language
 
Source Code Management systems
Source Code Management systemsSource Code Management systems
Source Code Management systems
 
Git avançado
Git avançadoGit avançado
Git avançado
 
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
 
Virtualenv
VirtualenvVirtualenv
Virtualenv
 
Loading...git
Loading...gitLoading...git
Loading...git
 
Ruby and Rails Packaging to Production
Ruby and Rails Packaging to ProductionRuby and Rails Packaging to Production
Ruby and Rails Packaging to Production
 
nouka inventry manager
nouka inventry managernouka inventry manager
nouka inventry manager
 

Último

DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...AliaaTarek5
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????blackmambaettijean
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate AgentsRyan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate AgentsRyan Mahoney
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 

Último (20)

DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate AgentsRyan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 

Paver For PyWorks 2008

  • 1. Smoothing Software Project Scripting Kevin Dangoor BlueSkyOnMars.com php|works PyWorks 2008
  • 2. Python is not compiled (actually, it is, but that’s not important right now)
  • 3. Python projects certainly do not need • Redistributable files to move around • Deployment to other machines • Interaction with source control systems • Documentation that’s built from the source code • Documentation that’s built from a format other than its final display format
  • 4.
  • 5. If only there was some scripting language that we already knew.
  • 6. Waitasec. Isn’t Python a scripting language?
  • 7. Project-related scripts need... • Command line argument handling • Configuration • Often work with files • Sometimes need to use distutils/ setuptools, but wish they could do a little more • Need to work with other common tools (Sphinx, svn, virtualenv)
  • 8. Command-line argument handling bin/start-server --port 8675309
  • 9. Configuration [messages] greeting=Hello [thing1] who=World message=${messages.greeting}, ${who}
  • 10. Lots of working with files import os if not os.path.exists(“foo”): os.mkdir(“foo”) if not os.path.exists(os.path.join(“foo, “bar”)): open(os.path.join(“foo”, “bar”), “w”).write(“Hi”)
  • 11. Working with distutils/setuptools #!/bin/sh sphinx-build (blah blah blah) python setup.py sdist upload
  • 12. Other common tools sphinx-build ... subprocess.Popen(“svn info”... # and do something with the output virtualenv.create_bootstrap_script(“# more code”)
  • 13. Do you really want separate scripts for everything? • /usr/local/bin/git /usr/local/bin/git-merge-resolve • /usr/local/bin/git-fast-import /usr/local/bin/git-runstatus • /usr/local/bin/git-add /usr/local/bin/git-merge-stupid • /usr/local/bin/git-fetch /usr/local/bin/git-send-email • /usr/local/bin/git-add--interactive /usr/local/bin/git-merge-subtree • /usr/local/bin/git-fetch--tool /usr/local/bin/git-send-pack • /usr/local/bin/git-am /usr/local/bin/git-merge-tree • /usr/local/bin/git-fetch-pack /usr/local/bin/git-sh-setup • /usr/local/bin/git-annotate /usr/local/bin/git-mergetool • /usr/local/bin/git-filter-branch /usr/local/bin/git-shell • /usr/local/bin/git-apply /usr/local/bin/git-mktag • /usr/local/bin/git-fmt-merge-msg /usr/local/bin/git-shortlog • /usr/local/bin/git-archimport /usr/local/bin/git-mktree • /usr/local/bin/git-for-each-ref /usr/local/bin/git-show • /usr/local/bin/git-archive /usr/local/bin/git-mv • /usr/local/bin/git-format-patch /usr/local/bin/git-show-branch • /usr/local/bin/git-bisect /usr/local/bin/git-name-rev • /usr/local/bin/git-fsck /usr/local/bin/git-show-index • /usr/local/bin/git-blame /usr/local/bin/git-pack-objects • /usr/local/bin/git-fsck-objects /usr/local/bin/git-show-ref • /usr/local/bin/git-branch /usr/local/bin/git-pack-redundant • /usr/local/bin/git-gc /usr/local/bin/git-ssh-fetch • /usr/local/bin/git-bundle /usr/local/bin/git-pack-refs • /usr/local/bin/git-get-tar-commit-id /usr/local/bin/git-ssh-pull • /usr/local/bin/git-cat-file /usr/local/bin/git-parse-remote • /usr/local/bin/git-grep /usr/local/bin/git-ssh-push • /usr/local/bin/git-check-attr /usr/local/bin/git-patch-id • /usr/local/bin/git-gui /usr/local/bin/git-ssh-upload • /usr/local/bin/git-check-ref-format /usr/local/bin/git-peek-remote • /usr/local/bin/git-hash-object /usr/local/bin/git-stash • /usr/local/bin/git-checkout /usr/local/bin/git-prune • /usr/local/bin/git-http-fetch /usr/local/bin/git-status • /usr/local/bin/git-checkout-index /usr/local/bin/git-prune-packed • /usr/local/bin/git-imap-send /usr/local/bin/git-stripspace • /usr/local/bin/git-cherry /usr/local/bin/git-pull • /usr/local/bin/git-index-pack /usr/local/bin/git-submodule • /usr/local/bin/git-cherry-pick /usr/local/bin/git-push • /usr/local/bin/git-init /usr/local/bin/git-svn • /usr/local/bin/git-citool /usr/local/bin/git-quiltimport • /usr/local/bin/git-init-db /usr/local/bin/git-svnimport • /usr/local/bin/git-clean /usr/local/bin/git-read-tree • /usr/local/bin/git-instaweb /usr/local/bin/git-symbolic-ref • /usr/local/bin/git-clone /usr/local/bin/git-rebase • /usr/local/bin/git-local-fetch /usr/local/bin/git-tag • /usr/local/bin/git-commit /usr/local/bin/git-rebase-- • /usr/local/bin/git-log /usr/local/bin/git-tar-tree interactive • /usr/local/bin/git-lost-found /usr/local/bin/git-unpack-file • /usr/local/bin/git-commit-tree /usr/local/bin/git-receive-pack • /usr/local/bin/git-ls-files /usr/local/bin/git-unpack-objects • /usr/local/bin/git-config /usr/local/bin/git-reflog • /usr/local/bin/git-ls-remote /usr/local/bin/git-update-index • /usr/local/bin/git-convert-objects /usr/local/bin/git-relink • /usr/local/bin/git-ls-tree /usr/local/bin/git-update-ref • /usr/local/bin/git-count-objects /usr/local/bin/git-remote • /usr/local/bin/git-mailinfo /usr/local/bin/git-update-server-info • /usr/local/bin/git-cvsexportcommit /usr/local/bin/git-repack • /usr/local/bin/git-mailsplit /usr/local/bin/git-upload-archive • /usr/local/bin/git-cvsimport /usr/local/bin/git-repo-config • /usr/local/bin/git-merge /usr/local/bin/git-upload-pack • /usr/local/bin/git-cvsserver /usr/local/bin/git-request-pull • /usr/local/bin/git-merge-base /usr/local/bin/git-var • /usr/local/bin/git-daemon /usr/local/bin/git-rerere • /usr/local/bin/git-merge-file /usr/local/bin/git-verify-pack • /usr/local/bin/git-describe /usr/local/bin/git-reset • /usr/local/bin/git-merge-index /usr/local/bin/git-verify-tag • /usr/local/bin/git-diff /usr/local/bin/git-rev-list • /usr/local/bin/git-merge-octopus /usr/local/bin/git-whatchanged • /usr/local/bin/git-diff-files /usr/local/bin/git-rev-parse • /usr/local/bin/git-merge-one-file /usr/local/bin/git-write-tree • /usr/local/bin/git-diff-index /usr/local/bin/git-revert • /usr/local/bin/git-merge-ours /usr/local/bin/gitk • /usr/local/bin/git-diff-tree /usr/local/bin/git-rm • /usr/local/bin/git-merge-recursive
  • 14.
  • 18. Why Python build files? • You already know Python • The language rules are well-defined • The language rules are well- documented • Python is powerful, so you’ll never be left hanging or need an escape hatch
  • 19. Pavements are almost standard Python from paver.defaults import *
  • 20.
  • 21. Configuration options( setup = setup_meta, minilib=Bunch( extra_files=['doctools', 'virtual'] ), sphinx=Bunch( builddir=quot;buildquot;, sourcedir=quot;sourcequot; ), virtualenv=Bunch( packages_to_install=[quot;nosequot;, quot;sphinxquot;, quot;docutilsquot;, quot;virtualenvquot;], install_paver=False, script_name='bootstrap.py', paver_command_line=None ) )
  • 22. Configuration options( setup = setup_meta, minilib=Bunch( extra_files=['doctools', 'virtual'] ), sphinx=Bunch( builddir=quot;buildquot;, sourcedir=quot;sourcequot; ), virtualenv=Bunch( packages_to_install=[quot;nosequot;, quot;sphinxquot;, quot;docutilsquot;, quot;virtualenvquot;], install_paver=False, script_name='bootstrap.py', paver_command_line=None ) )
  • 23. Configuration options( setup = setup_meta, minilib=Bunch( extra_files=['doctools', 'virtual'] ), sphinx=Bunch( builddir=quot;buildquot;, sourcedir=quot;sourcequot; ), virtualenv=Bunch( packages_to_install=[quot;nosequot;, quot;sphinxquot;, quot;docutilsquot;, quot;virtualenvquot;], install_paver=False, script_name='bootstrap.py', paver_command_line=None ) )
  • 24. Configuration options( setup = setup_meta, minilib=Bunch( extra_files=['doctools', 'virtual'] ), sphinx=Bunch( builddir=quot;buildquot;, sourcedir=quot;sourcequot; ), virtualenv=Bunch( packages_to_install=[quot;nosequot;, quot;sphinxquot;, quot;docutilsquot;, quot;virtualenvquot;], install_paver=False, script_name='bootstrap.py', paver_command_line=None ) )
  • 25. Configuration options( setup = setup_meta, minilib=Bunch( extra_files=['doctools', 'virtual'] ), sphinx=Bunch( builddir=quot;buildquot;, sourcedir=quot;sourcequot; ), virtualenv=Bunch( packages_to_install=[quot;nosequot;, quot;sphinxquot;, quot;docutilsquot;, quot;virtualenvquot;], install_paver=False, script_name='bootstrap.py', paver_command_line=None ) )
  • 26. Configuration options( setup = setup_meta, minilib=Bunch( extra_files=['doctools', 'virtual'] ), sphinx=Bunch( builddir=quot;buildquot;, sourcedir=quot;sourcequot; ), virtualenv=Bunch( packages_to_install=[quot;nosequot;, quot;sphinxquot;, quot;docutilsquot;, quot;virtualenvquot;], install_paver=False, script_name='bootstrap.py', paver_command_line=None ) )
  • 27. Configuration options( setup = setup_meta, minilib=Bunch( extra_files=['doctools', 'virtual'] ), sphinx=Bunch( builddir=quot;buildquot;, sourcedir=quot;sourcequot; ), virtualenv=Bunch( packages_to_install=[quot;nosequot;, quot;sphinxquot;, quot;docutilsquot;, quot;virtualenvquot;], install_paver=False, script_name='bootstrap.py', paver_command_line=None ) )
  • 28. Dynamic config values >>> from paver.defaults import * >>> import time >>> options(current=lambda: time.time()) >>> options.current 1216726815.0027969
  • 29. Namespace searching >>> options( ... setup=Bunch(version=quot;1.0quot;), ... sphinx=Bunch(builddir=quot;docbuildquot;) ... ) >>> options.version '1.0'
  • 30. Namespace searching (continued) >>> options( ... setup=Bunch(version=quot;1.0quot;), ... sphinx=Bunch(builddir=quot;docbuildquot;) ... ) >>> options.order('sphinx') >>> options.version Traceback (most recent call last): File quot;<stdin>quot;, line 1, in <module> File quot;/Users/admin/projects/paver/paver/runtime.pyquot;, line 31, in __getattr__ raise AttributeError(name) AttributeError: version
  • 31. Namespace searching (continued) >>> options( ... setup=Bunch(version=quot;1.0quot;), ... sphinx=Bunch(builddir=quot;docbuildquot;) ... ) >>> options.order('sphinx') >>> options.version Traceback (most recent call last): File quot;<stdin>quot;, line 1, in <module> File quot;/Users/admin/projects/paver/paver/runtime.pyquot;, line 31, in __getattr__ raise AttributeError(name) AttributeError: version
  • 32. Namespace searching (continued) >>> options( ... setup=Bunch(version=quot;1.0quot;), ... sphinx=Bunch(builddir=quot;docbuildquot;) ... ) >>> options.order('sphinx') >>> options.version Traceback (most recent call last): File quot;<stdin>quot;, line 1, in <module> File quot;/Users/admin/projects/paver/paver/runtime.pyquot;, line 31, in __getattr__ raise AttributeError(name) AttributeError: version
  • 33. Configuration is still standard Python • You can treat options like a normal, nested dictionary • The only unusual thing would be that callables are called.
  • 34.
  • 35. Tasks @task def clean(): quot;quot;quot;Cleans up this paver directory. Removes the virtualenv traces and the build directory.quot;quot;quot; pass
  • 36. Tasks @task def clean(): quot;quot;quot;Cleans up this paver directory. Removes the virtualenv traces and the build directory.quot;quot;quot; pass
  • 37. Tasks @task def clean(): quot;quot;quot;Cleans up this paver directory. Removes the virtualenv traces and the build directory.quot;quot;quot; pass
  • 38. Tasks @task def clean(): quot;quot;quot;Cleans up this paver directory. Removes the virtualenv traces and the build directory.quot;quot;quot; pass
  • 39. Tasks @task def clean(): quot;quot;quot;Cleans up this paver directory. Removes the virtualenv traces and the build directory.quot;quot;quot; pass
  • 40. paver help $ paver help ---> help Paver 0.8.1 Usage: paver [global options] [option.name=value] task [task options] [task...] Run 'paver help [section]' to see the following sections of info: options global command line options setup available distutils/setuptools tasks tasks all tasks that have been imported by your pavement 'paver help taskname' will display details for a task. Tasks defined in your pavement: bootstrap - Build a virtualenv bootstrap for developing
  • 41. paver help $ paver help ---> help Paver 0.8.1 Usage: paver [global options] [option.name=value] task [task options] [task...] Run 'paver help [section]' to see the following sections of info: options global command line options setup available distutils/setuptools tasks tasks all tasks that have been imported by your pavement 'paver help taskname' will display details for a task. Tasks defined in your pavement: bootstrap - Build a virtualenv bootstrap for developing
  • 42. paver help $ paver help ---> help Paver 0.8.1 Usage: paver [global options] [option.name=value] task [task options] [task...] Run 'paver help [section]' to see the following sections of info: options global command line options setup available distutils/setuptools tasks tasks all tasks that have been imported by your pavement 'paver help taskname' will display details for a task. Tasks defined in your pavement: bootstrap - Build a virtualenv bootstrap for developing
  • 43. paver help $ paver help ---> help Paver 0.8.1 Usage: paver [global options] [option.name=value] task [task options] [task...] Run 'paver help [section]' to see the following sections of info: options global command line options setup available distutils/setuptools tasks tasks all tasks that have been imported by your pavement 'paver help taskname' will display details for a task. Tasks defined in your pavement: bootstrap - Build a virtualenv bootstrap for developing
  • 44. paver help $ paver help ---> help Paver 0.8.1 Usage: paver [global options] [option.name=value] task [task options] [task...] Run 'paver help [section]' to see the following sections of info: options global command line options setup available distutils/setuptools tasks tasks all tasks that have been imported by your pavement 'paver help taskname' will display details for a task. Tasks defined in your pavement: bootstrap - Build a virtualenv bootstrap for developing
  • 45. paver help tasks Tasks defined in and imported by your pavement: bootstrap - Build a virtualenv bootstrap for developing paver clean - Cleans up this paver directory cog - Runs the cog code generator against the files matching your specification commit - Removes the generated code from the docs and then commits to bzr deploy - Copy the Paver website up doc_clean - Clean (delete) the built docs generate_setup - Generates a setup help - Displays the list of commands and the details html - Build Paver's documentation and install it into paver/docs minilib - Create a Paver mini library that contains enough for a simple
  • 46. paver help <taskname> Details for minilib: Create a Paver mini library that contains enough for a simple pavement.py to be installed using a generated setup.py. This is a good temporary measure until more people have deployed paver. The output file is 'paver-minilib.zip' in the current directory. Options: extra_files list of other paver modules to include (don't include the .py extension)
  • 47. @needs @task @needs(quot;uncogquot;) def commit(): quot;quot;quot;Removes the generated code from the docs and then commits to bzr.quot;quot;quot; pass
  • 48. @needs @task @needs(quot;uncogquot;) def commit(): quot;quot;quot;Removes the generated code from the docs and then commits to bzr.quot;quot;quot; pass
  • 49. @needs @task @needs(quot;uncogquot;) def commit(): quot;quot;quot;Removes the generated code from the docs and then commits to bzr.quot;quot;quot; pass
  • 51. @cmdopts @task @cmdopts([(quot;username=quot;, quot;uquot;, quot;Username for remote serverquot;), (quot;server=quot;, quot;squot;, quot;Server to deploy toquot;)]) def deploy(): quot;quot;quot;Copy the Paver website up.quot;quot;quot; pass
  • 52. paver <taskname> $ paver generate_setup minilib ---> generate_setup Write setup.py ---> minilib Generate paver-minilib.zip
  • 53. Paver and Distutils/ Setuptools
  • 54. “Using the Distutils is quite simple, both for module developers and for users/ administrators installing third-party modules.” – Distributing Python Modules, section 1.1
  • 55. python setup.py install
  • 56. Paver extends Distutils
  • 58. setup.py example from distutils.core import setup setup(name='foo', version='1.0', py_modules=['foo'], )
  • 59. setup.py example from distutils.core import setup setup(name='foo', version='1.0', py_modules=['foo'], )
  • 60. setup.py example from distutils.core import setup setup(name='foo', version='1.0', py_modules=['foo'], )
  • 61. setup.py example from distutils.core import setup setup(name='foo', version='1.0', py_modules=['foo'], )
  • 62. setup.py example from distutils.core import setup setup(name='foo', version='1.0', py_modules=['foo'], )
  • 63. Upgrading to Paver options( setup = Bunch(name='foo', version='1.0', py_modules=['foo'], ) )
  • 64. Keeping it simple for users $ paver generate_setup minilib ---> generate_setup Write setup.py ---> minilib Generate paver-minilib.zip
  • 65. Generated setup.py import os if os.path.exists(quot;paver-minilib.zipquot;): import sys sys.path.insert(0, quot;paver-minilib.zipquot;) import paver.command paver.command.main()
  • 66. The Paver Standard Library (is actually newer and less musty)
  • 67. The Paver Standard Library • Runtime helpers (paver.runtime) • Distutils integration (paver.setuputils) • File handling (paver.path) • Documentation tools (paver.doctools) • Subversion (paver.svn) • SSH (paver.ssh) • Virtualenv (paver.virtual) • Miscellaneous Tasks (paver.misctasks)
  • 68. paver.runtime # display text if verbose is set debug(“Hi there. Feeling chatty today?”) # display text if quiet is not set info(“Glad we don’t have to keep quiet”) # display text regardless of setting error(“HA! I’M SHOUTING AND YOU CAN’T STOP ME!”)
  • 69. paver.runtime # display text if verbose is set debug(“Hi there. Feeling chatty today?”) # display text if quiet is not set info(“Glad we don’t have to keep quiet”) # display text regardless of setting error(“HA! I’M SHOUTING AND YOU CAN’T STOP ME!”)
  • 70. paver.runtime # display text if verbose is set debug(“Hi there. Feeling chatty today?”) # display text if quiet is not set info(“Glad we don’t have to keep quiet”) # display text regardless of setting error(“HA! I’M SHOUTING AND YOU CAN’T STOP ME!”)
  • 71. paver.runtime # display text if verbose is set debug(“Hi there. Feeling chatty today?”) # display text if quiet is not set info(“Glad we don’t have to keep quiet”) # display text regardless of setting error(“HA! I’M SHOUTING AND YOU CAN’T STOP ME!”)
  • 72. paver.runtime # display text if verbose is set debug(“Hi there. Feeling chatty today?”) # display text if quiet is not set info(“Glad we don’t have to keep quiet”) # display text regardless of setting error(“HA! I’M SHOUTING AND YOU CAN’T STOP ME!”)
  • 73. paver.runtime # display text if verbose is set debug(“Hi there. Feeling chatty today?”) # display text if quiet is not set info(“Glad we don’t have to keep quiet”) # display text regardless of setting error(“HA! I’M SHOUTING AND YOU CAN’T STOP ME!”)
  • 74. paver.runtime # display text if verbose is set debug(“Hi there. Feeling chatty today?”) # display text if quiet is not set info(“Glad we don’t have to keep quiet”) # display text regardless of setting error(“HA! I’M SHOUTING AND YOU CAN’T STOP ME!”)
  • 75. paver.runtime (continued) # run a command, as long as dry-run is off # capture the output into myval myval = sh(“cat /tmp/foo”, capture=True) # run a function (delete_all(‘/’) to be exact). # if dry-run is set, then # just print the message instead dry(“Delete everything”, delete_all, ‘/’)
  • 76. paver.runtime (continued) # run a command, as long as dry-run is off # capture the output into myval myval = sh(“cat /tmp/foo”, capture=True) # run a function (delete_all(‘/’) to be exact). # if dry-run is set, then # just print the message instead dry(“Delete everything”, delete_all, ‘/’)
  • 77. paver.runtime (continued) # run a command, as long as dry-run is off # capture the output into myval myval = sh(“cat /tmp/foo”, capture=True) # run a function (delete_all(‘/’) to be exact). # if dry-run is set, then # just print the message instead dry(“Delete everything”, delete_all, ‘/’)
  • 78. paver.runtime (continued) # run a command, as long as dry-run is off # capture the output into myval myval = sh(“cat /tmp/foo”, capture=True) # run a function (delete_all(‘/’) to be exact). # if dry-run is set, then # just print the message instead dry(“Delete everything”, delete_all, ‘/’)
  • 79. paver.runtime (continued) # run a command, as long as dry-run is off # capture the output into myval myval = sh(“cat /tmp/foo”, capture=True) # run a function (delete_all(‘/’) to be exact). # if dry-run is set, then # just print the message instead dry(“Delete everything”, delete_all, ‘/’)
  • 80. paver.setuputils options.setup.package_data = setuputils.find_package_data(quot;paverquot;, package=quot;paverquot;, only_in_packages=False)
  • 81. paver.path • Jason Orendorff’s path.py module (also available separately) • It’s a subclass of string! • Fun use of operator overloading • Lots of great methods • Makes working with files/directories fun and easy
  • 82. paver.path examples p = path(quot;docsquot;) tmpdir = p / quot;tmpquot; tmpdir.mkdir() fn = tmpdir / quot;myfile.txtquot; fn.write_text(quot;Hi there!quot;)
  • 83. paver.path examples p = path(quot;docsquot;) tmpdir = p / quot;tmpquot; tmpdir.mkdir() fn = tmpdir / quot;myfile.txtquot; fn.write_text(quot;Hi there!quot;)
  • 84. paver.path examples p = path(quot;docsquot;) tmpdir = p / quot;tmpquot; tmpdir.mkdir() fn = tmpdir / quot;myfile.txtquot; fn.write_text(quot;Hi there!quot;)
  • 85. paver.path examples p = path(quot;docsquot;) tmpdir = p / quot;tmpquot; tmpdir.mkdir() fn = tmpdir / quot;myfile.txtquot; fn.write_text(quot;Hi there!quot;)
  • 86. paver.path examples p = path(quot;docsquot;) tmpdir = p / quot;tmpquot; tmpdir.mkdir() fn = tmpdir / quot;myfile.txtquot; fn.write_text(quot;Hi there!quot;)
  • 87. paver.path examples p = path(quot;docsquot;) tmpdir = p / quot;tmpquot; tmpdir.mkdir() fn = tmpdir / quot;myfile.txtquot; fn.write_text(quot;Hi there!quot;)
  • 88. paver.path examples p = path(quot;docsquot;) tmpdir = p / quot;tmpquot; tmpdir.mkdir() fn = tmpdir / quot;myfile.txtquot; fn.write_text(quot;Hi there!quot;)
  • 89. paver.doctools # add this to use import paver.doctools
  • 90. paver.doctools – Sphinx paver.doctools.html()¶ Build HTML documentation using Sphinx. This uses the following options in a “sphinx” section of the options. docroot the root under which Sphinx will be working. Default: docs builddir directory under the docroot where the resulting files are put. default: build sourcedir directory under the docroot for the source files default: (empty string) paver.doctools.doc_clean()¶ Clean (delete) the built docs. Specifically, this deletes the build directory under the docroot. See the html task for the options list.
  • 91. paver.doctools – Cog & SectionedFile • Solutions to common problems of creating high-quality docs • Ideally, your code samples will be in convenient runnable code files and have unit tests. • But you also want nice, minimal code samples in your text as you’re writing.
  • 92. paver.doctools sample code # mysample.py # [[[section mysample]]] def sample_func(): print quot;To sample, or not to sample?quot; # [[[endsection]]]
  • 93. paver.doctools in docs And then when you want to print the sample string, you just call:: # [[[cog include(“code/mysample.py”, “mysample”)]]] # [[[end]]]
  • 94. paver.doctools in docs (2) And then when you want to print the sample string, you just call:: # [[[cog include(“code/mysample.py”, “mysample”)]]] def sample_func(): print quot;To sample, or not to sample?quot; # [[[end]]]
  • 95. paver.doctools uncog before commit @task @needs(quot;uncogquot;) def commit(): quot;quot;quot;Removes the generated code from the docs and then commits to bzr.quot;quot;quot; sh(quot;bzr commitquot;)
  • 96. paver.svn paver.svn.checkout(url, dest, revision='') Checks out the specified URL to the given destination. paver.svn.checkup(url, dest, revision='') Does a checkout or update, depending on whether the destination exists and is up to date (if a revision is passed in). Returns true if a checkout or update was performed. False otherwise. paver.svn.info(path='') Retrieves the svn info for the path and returns a dictionary of the values. Names are normalized to lower case with spaces converted to underscores. paver.svn.update(path='', revision='') Run an svn update on the given path. Example at: https://projects.sitepen.com/toolbox/svn/trunk/pavement.py
  • 97. paver.ssh paver.ssh.scp(source, dest) Copy the source file to the destination.
  • 98. paver.virtual paver.virtual.bootstrap() Creates a virtualenv bootstrap script. The script will create a bootstrap script that populates a virtualenv in the current directory. The environment will have paver, the packages of your choosing and will run the paver command of your choice. This task looks in the virtualenv options for: script_name name of the generated script packages_to_install packages to install with easy_install. The version of paver that you are using is included automatically. This should be a list of strings. paver_command_line run this paver command line after installation (just the command line arguments, not the paver command itself).
  • 99. paver.misctasks paver.misctasks.generate_setup() paver.misctasks.help() paver.misctasks.minilib() Options: extra_files list of other paver modules to include (donʼt include the .py extension) paver.misctasks.paverdocs()
  • 100. Pulling it all together • write functions with the @task decorator. • Just plain old Python with lots of conveniences • Paver’s pavement.py is a good example • Even better, take a look at “Getting Started with Paver” http://bit.ly/starting_paver
  • 101. Remember this? #!/bin/sh sphinx-build (blah blah blah) python setup.py sdist upload
  • 102. Paver needs to do that too @task @needs(['html', quot;minilibquot;, quot;generate_setupquot;, “setuptools.command.sdist”]) def sdist(): quot;quot;quot;Builds the documentation and the tarball.quot;quot;quot; pass
  • 103. But wait, it does more! @task @needs(['cog', 'paver.doctools.html']) def html(): quot;quot;quot;Build Paver's documentation and install it into paver/ docsquot;quot;quot; builtdocs = path(quot;docsquot;) / options.sphinx.builddir / quot;htmlquot; destdir = path(quot;paverquot;) / quot;docsquot; destdir.rmtree() builtdocs.move(destdir)
  • 104. Changes coming to Paver • The little bit of magic goes away • Support for CloudControl • Ability to run sub-builds easily • Virtualenv/pyinstall management • zc.buildout recipe running
  • 105. Credits • Thanks to SitePen for supporting Paver • Bumpy road http://flickr.com/photos/ilya/442034/sizes/o/ • Smooth road http://flickr.com/photos/nicholas_t/317528561/ • Options (Anna’s hairdo) http://flickr.com/photos/alangley/2136034468/ • Tasks http://flickr.com/photos/mpwillis/470557535/