Differences between revisions 11 and 12
Revision 11 as of 2008-03-14 23:06:39
Size: 6264
Editor: JeffRush
Comment:
Revision 12 as of 2008-03-15 05:11:03
Size: 7158
Editor: JeffRush
Comment:
Deletions are marked like this. Additions are marked like this.
Line 11: Line 11:
  + `An Introduction to the Virtualenv Sandbox`_ (.pdf, .txt)
  + `Distutils: Packaging, Metadata and Pushups`_ (.pdf, .txt)
  + `SetupTools: Python Eggs, Dependencies and Plugins`_ (.pdf, .txt)
  + `An Introduction to the Virtualenv Sandbox`_ (`.pdf`__, `.txt`__)

    .. _`An Introduction to the Virtualenv Sandbox`: http://dfwpython.org/static/pycon/0-python-virtualenv.pdf
    .. __: http://dfwpython.org/static/pycon/0-python-virtualenv.pdf
    .. __: http://dfwpython.org/static/pycon/0-python-virtualenv.txt

  + `Distutils: Packaging, Metadata and Pushups`_ (`.pdf`__, `.txt`__)

    .. _`Distutils: Packaging, Metadata and Pushups`: http://dfwpython.org/static/pycon/1-python-distutils.pdf
    .. __: http://dfwpython.org/static/pycon/1-python-distutils.pdf
    .. __: http://dfwpython.org/static/pycon/1-python-distutils.txt

  + `SetupTools: Python Eggs, Dependencies and Plugins`_ (`.pdf`__, `.txt`__)

    .. _`SetupTools: Python Eggs, Dependencies and Plugins`: http://dfwpython.org/static/pycon/2-python-setuptools.pdf
    .. __: http://dfwpython.org/static/pycon/2-python-setuptools.pdf
    .. __: http://dfwpython.org/static/pycon/2-python-setuptools.txt
Line 16: Line 31:
    .. _`Buildout: Precision Assembly, Repeatability, Islands`: http://dfwpython.org/static/pycon/3-python-buildout.pdf
    .. __: http://dfwpython.org/static/pycon/3-python-buildout.pdf
    .. __: http://dfwpython.org/static/pycon/3-python-buildout.txt
Line 18: Line 37:
  + `Eggs and Buildout Deployment in Python`_ (.pdf, .txt)
  + `BonusClassSlides`_ `Additional Topics of Tutorial`_ (.pdf, .txt)

.. _`An Introduction to the Virtualenv Sandbox`: http://dfwpython.org/static/pycon/0-python-virtualenv.pdf
.. _`An Introduction to the Virtualenv Sandbox`: http://dfwpython.org/static/pycon/1-python-distutils.pdf
.. _`SetupTools: Python Eggs, Dependencies and Plugins`: http://dfwpython.org/static/pycon/2-python-setuptools.pdf
.. _`Buildout: Precision Assembly, Repeatability, Islands`: http://dfwpython.org/static/pycon/3-python-buildout.pdf
.. _`Eggs and Buildout Deployment in Python`: http://dfwpython.org/static/pycon/class-slides.pdf
.. _`Additional Topics of Tutorial`: http://dfwpython.org/static/pycon/python-bonus.pdf

Exercises:
  + `Eggs and Buildout Deployment in Python`_ (`.pdf`__, `.txt`__)

.. _`Eggs and Buildout Deployment in Python`: http://dfwpython.org/static/pycon/eggs-n-buildout.pdf
.. __: http://dfwpython.org/static/pycon/eggs-n-buildout.pdf
.. __: http://dfwpython.org/static/pycon/eggs-n-buildout.txt

  + `Additional Topics of Tutorial`_ (`.pdf`__, `.txt`__)

.. _`Additional Topics of Tutorial`: http://dfwpython.org/static/pycon/eggs-n-buildout-bonus.pdf
.. __: http://dfwpython.org/static/pycon/eggs-n-buildout-bonus.pdf
.. __: http://dfwpython.org/static/pycon/eggs-n-buildout-bonus.txt

Exercises from Tutorial:

Eggs and Buildout Deployment in Python

Slides:

Four-Part In-Depth Presentation Sequence (not presented in class)

Condensed Slide Set Used in Actual Tutorial

Exercises from Tutorial:

  1. Installing Tools for the Class

    $ cd /tmp
    $ sudo python ez_setup.py
    $ sudo easy_install virtualenv
    $ sudo easy_install zc.buildout
  2. Instantiating a Sandbox or Two

    $ virtualenv pycon -or-
    $ virtualenv --no-site-packages pycon
    $ cd pycon
    $ bin/python
    $ source bin/activate -or- activate.bat
    $ deactivate
    • explore:
      • directory tree
      • sys.path
    • for each kind of sandbox
  3. Processing Distributions

    1. Grab a source distribution

      $ /sandbox/bin/easy_install --editable --build-directory . SQLObject==0.9.5
      $ /sandbox/bin/easy_install --editable --build-directory . SQLObject==dev

      Examine its directory structure and common files.

    2. Query the list of available distribution formats.

      $ cd sqlobject
      $ /sandbox/bin/python setup.py sdist --help-formats
      $ /sandbox/bin/python setup.py bdist --help-formats
    3. Build and package it as a binary distribution.

      $ /sandbox/bin/python setup.py build
      $ /sandbox/bin/python setup.py install
      $ /sandbox/bin/python setup.py bdist --formats=tar,egg,rpm

      Examine the run output and the table-of-contents of the distribution archive afterward. Note the way that metadata is stored.

    4. Repackage it as a source distribution

      $ /sandbox/bin/python setup.py sdist --formats=zip

      Examine the run output and the table-of-contents of the source archive. Note the different way that metadata is stored.

    5. Try to import it, then run the "develop" cmd and try again.

      $ cd /sandbox
      $ /sandbox/bin/python
      $ import sqlobject
      $ cd /sandbox/sqlobject
      $ /sandbox/bin/python setup.py develop
  4. Generating Scripts that Invokes Entrypoints

    1. Create a sandbox in which to work.

      $ virtualenv --no-site-packages pycon
      $ cd pycon
    2. Create a distribution for a new egg that has two scripts.

      # File: pycon/setup.py
      from setuptools import setup

      setup(name="myscript",
      version="1.0.0",
      py_module = ['myscript'],
      entry_points={
      "console_scripts": [
      "alpha = myscript:alpha_cmd",
      "beta = myscript:beta_cmd"]
      },
      )
      # File: pycon/myscript.py
      def alpha_cmd():
      print "Hello from Alpha Centauri"

      class beta_cmd(object):
      def __init__(self):
      print "Hello from Beta Centauri"
    3. Mark it a develop-egg and then add the egg as a 'myscript' part.

      # File: pycon/buildout.cfg
      [buildout]
      develop = .
      parts = myscript

      [myscript]
      recipe = zc.recipe.egg
      eggs = myscript
    4. Run buildout and look in the bin/ directory for scripts.
  5. Create a simple buildout around an egg and experiment with it.

    1. Create an empty buildout area.

      $ virtualenv --no-site-packages pycon
      $ cd pycon
      $ buildout init
    2. Put into it a simple egg by creating a "buildout.cfg" file:

      [buildout]
      parts = mypython
      prefer-final = true

      [mypython]
      recipe = zc.recipe.egg
      interpreter = dbpython
      eggs = SQLObject
    3. Invoke "bin/buildout" and examine the output messages, the directory structure and the dbpython script.

      Test for what version got installed and where it came from.

      $ bin/dbpython
      >>> import sqlobject
      >>> sqlobject.__file__
      '/var/tmp/buildout/eggs/SQLObject-0.10.0-py2.5.egg/sqlobject/__init__.py'
    4. Force it to use a specific version of SQLObject.

      eggs = SQLObject==0.9

      Test for what version got installed and where it came from.

      $ bin/dbpython
      >>> import sqlobject
      >>> sqlobject.__file__
      '/var/tmp/buildout/eggs/SQLObject-0.9.0-py2.5.egg/sqlobject/__init__.py'
    5. Remove that constraint and grab its source distribution.

      $ bin/easy_install --editable -b . SQLObject

      Alter "buildout.cfg" file to make it a development egg:

      develop = sqlobject

      Test for what version got installed and where it came from.

      $ bin/dbpython
      >>> import sqlobject
      >>> sqlobject.__file__
      '/tmp/kkk/sqlobject/sqlobject/__init__.py'

Docutils System Messages

System Message: ERROR/3 (<string>); backlinks: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10

Anonymous hyperlink mismatch: 10 references but 12 targets. See "backrefs" attribute for IDs.

buildout/pycon2008 tutorial (last edited 2013-02-27 12:02:22 by MichaelCarlsson)

Unable to edit the page? See the FrontPage for instructions.