Python Language Introduction


Example

Every package requires a setup.py file which describes the package.

Consider the following directory structure for a simple package:

+-- package_name
|       |
|       +-- __init__.py
|       
+-- setup.py

The __init__.py contains only the line def foo(): return 100.

The following setup.py will define the package:

from setuptools import setup


setup(
    name='package_name',                    # package name
    version='0.1',                          # version
    description='Package Description',      # short description
    url='http://example.com',               # package URL
    install_requires=[],                    # list of packages this package depends
                                            # on.
    packages=['package_name'],              # List of module names that installing
                                            # this package will provide.
)

virtualenv is great to test package installs without modifying your other Python environments:

$ virtualenv .virtualenv
...
$ source .virtualenv/bin/activate
$ python setup.py install
running install
...
Installed .../package_name-0.1-....egg
...
$ python
>>> import package_name
>>> package_name.foo() 
100