Packaging

  • Distribute is a fork of the Setuptools project.

    • Distribute is intended to replace Setuptools as the standard method for working with Python module distributions.
  • Setuptools: download, build, install, upgrade, and uninstall Python packages -- easily!

    • The main feature is the setup.py scripts calling 'setuptools.setup' function
  • There is an initiative to create a standard packaging and distribution tool integrated in the core in Python 3.4 ( http://www.python.org/dev/peps/pep-0426/ )


In [ ]:
# EXERCISE:
# Download and decompress pep8 and requests eggs:
!mkdir -p tmp_eggs
#git clone git@github.com:PyCQA/pycodestyle.git
#git clone git@github.com:kennethreitz/requests.git

# - Check their setup.py and how it calls the setup function:
#
# - Check...
#    - All the '*_requires' arguments
#    - The 'entry_points' argument in pep8
#    - The auxiliary functions used

# - Create pep8 egg and RPM
#    $ python setup.py  bdist_egg
#    $ python setup.py  bdist_rpm  # Requires rpm-build
#

Debugging

  • pdb is Python's interactive debugger
  • It provides command line and programmatic interfaces

In [ ]:
# EXERCISE:
# - Execute mod_debugging.py with pdb from command line:
#    $ python -m pdb mod_debugging.py
#
# - Type 'h' or 'help' to check available debugger commands
# - Type 'next' several times and check the backtrace

In [ ]:
# EXERCISE:
# - Execute mod_debugging.caller_func with pdb from a Python interpreter:
#    $ python
#     >>> import pdb
#     >>> import mod_debugging
#     >>> pdb.run('mod_debugging.caller_func()')
#     > <string>(1)<module>()
#     (Pdb)
#
# - Type 'h' or 'help' to check available debugger commands
# - Type 'next' and check the backtrace

In [ ]:
import ipdb  # Much better than standard library debugger

In [ ]:
# EXERCISE:
# - Execute this file with Python
#    $ python mod_debugging_2.py
#
# - Type 'h' or 'help' to check available debugger commands
#    - Besides debugger commands you can execute Python code, check variables...
# - Try to call another_func(123, 456)
# - Check the backtrace

In [ ]: