Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Bento presentation for CAMPUG

Bento presentation for CAMPUG

A quick presentation I made at CAMPUG to highlight a few points around my python packaging solution, bento.

cournape

July 27, 2012
Tweet

More Decks by cournape

Other Decks in Programming

Transcript

  1. ห౰(BENTO)
    A Python solution for packaging
    Tuesday, 3 July 12

    View Slide

  2. WHO AM I ?
    Tuesday, 3 July 12

    View Slide

  3. NUMPY/SCIPY DEVELOPER
    Tuesday, 3 July 12

    View Slide

  4. IN PARTICULAR: PACKAGING
    Tuesday, 3 July 12

    View Slide

  5. NUMPY USES DISTUTILS
    Tuesday, 3 July 12

    View Slide

  6. WHY WE DON’T LIKE IT
    • Hard to customize
    • Extensions based on monkey-
    patching
    • pip, setuptools, etc... a nightmare to
    manage
    Tuesday, 3 July 12

    View Slide

  7. BENTO
    # bento.info file
    Name: foo
    Version: 0.1
    Description:
    Package description.
    Library:
    Packages: foo, foo.core
    Tuesday, 3 July 12

    View Slide

  8. BENTOMAKER
    $ bentomaker configure
    $ bentomaker build
    $ bentomaker install
    # Or more simply (automatically
    # runs configure and build)
    $ bentomaker install
    Tuesday, 3 July 12

    View Slide

  9. FROM DISTUTILS TO BENTO
    # convert setup.py to bento.info
    $ bentomaker convert
    Tuesday, 3 July 12

    View Slide

  10. PIP SUPPORT
    # setup.py
    from bento.distutils import setup
    setup()
    Tuesday, 3 July 12

    View Slide

  11. ADDING NEW COMMAND
    $ bentomaker hello
    hello
    # bscript file
    from bento.commands import hooks
    @hooks.command
    def hello(context):
    print "Hello"
    # bento.info file
    HookFile: bscript
    Tuesday, 3 July 12

    View Slide

  12. ADDING DATA-FILES
    Datafiles: pdf_documentation
    TargetDir: $pdfdir
    Files: main.pdf
    $ bentomaker configure --pdfdir=/usr/pdfdoc
    # ant-like glob format supported
    Datafiles: pdf_documentation
    TargetDir: $pdfdoc
    Files: doc/**/*.pdf
    Tuesday, 3 July 12

    View Slide

  13. ADVANCED USAGE
    Tuesday, 3 July 12

    View Slide

  14. HOOKS FILES (2)
    from bento.commands import hooks
    @hooks.command
    def hello(context):
    print "hello nice world"
    @hooks.command
    def goodbye(context):
    print "goodbye cruel world !"
    @hooks.startup
    def startup(context):
    context.set_before("goodbye", "hello")
    Dependencies defined outside classes for lower
    coupling between commands
    Tuesday, 3 July 12

    View Slide

  15. PACKAGE METADATA (1)
    # bento.info content
    Version: 0.2
    Author: John Doe
    MetaTemplateFile: foo/__info.py.in
    # foo/__info.py.in template content
    version = $VERSION
    author = $AUTHOR
    Allow for a package to know its own metadata:
    Tuesday, 3 July 12

    View Slide

  16. PACKAGE METADATA (2)
    New metadata can be defined in the hook file:
    # foo/__info.py.in template content
    version = $VERSION
    git_revision = $GIT_REVISION
    author = $AUTHOR
    @hooks.pre_build
    def pre_build(context):
    context.register_metadata("git_revision",
    compute_git_revision())
    Tuesday, 3 July 12

    View Slide

  17. OUT-OF-TREE BUILDS
    source_tree$ ls
    bento.info
    foo/__init__.py
    ...
    build_tree$ bentomaker \
    --bento-info=.../bento.info
    Tuesday, 3 July 12

    View Slide

  18. NUMPY AND BENTO
    • Build scripts 50 % smaller
    • parallel and reliable partial build support
    Tuesday, 3 July 12

    View Slide

  19. WHERE TO GET IT
    • On github: http://github.com/cournape/Bento.git
    • Documentation: http://cournape.github.com/Bento
    • Mailing List: [email protected]
    Tuesday, 3 July 12

    View Slide