Create Python package with dependencies using setuptools

I have not worked with packaging Python module for so long. It seems distutils was deprecated since Python 2.4. The recommendation is to use setuptools instead. It offers lots of useful functionalities, e.g., easy install with automatic dependencies resolver.

To create a package with setuptools, the package should have ez_setup.py in the root directory with setup.py.

wget http://peak.telecommunity.com/dist/ez_setup.py

Then insert below snippet before importing anything from setuptools.

import ez_setup
ez_setup.use_setuptools()

As a result, your setup.py should look like this.

import ez_setup
ez_setup.use_setuptools()
from setuptools import setup,find_packages

Now you are able to add dependencies in setup() under install_requires keyword.

setup(name='pyedxl',
      version=__version__,
      packages=find_packages(exclude=['*.tests','*.tests.*','tests.*','tests']),

      install_requires=['lxml>=1.0.3',
                        'python-dateutil'],

      author='Sugree Phatanapherom',
      author_email='',
      description='Python library for handling OASIS EDXL',
      license='LGPL',
      keywords='edxl',
      url='http://code.google.com/p/py-edxl',
      long_description='''\
Python library for handling OASIS Emergency Data Exchange Language (EDXL)
Distribution Element that provides a collection of modules for manipulating
OASIS Emergency Data Exchange Language (EDXL) Distribution Element''',

      maintainer='Sugree Phatanapherom',
      maintainer_email='',
      platforms=['any'],
      classifiers=filter(None,classifiers.split('\n')),
     )

Note that I don't know why I have dateutil in my laptop.

Tags: , ,

Post new comment