ant-python

Setup

Description

Create a setup.py file. All properties of the setup can be defined by attributes. The task automatically finds the Python packages and package data in the source directory. This is equivalent to the method find_packages() of the Python utility setuptools.

Note

Note that this task only creates the setup.py file. Use the task Build to create a Python distribution from a setup.py file.

Parameters

Attribute Description Required
dir Directory containing the distribution source code and where the setup.py will be saved. yes
name Name of the package. yes
version Version of this release. yes
url Home page for the package. yes
author Package author’s name. or maintainer
authorEmail Email address of the package author. yes if author
maintainer Package maintainer’s name. or author
maintainerEmail Email address of the package maintainer. yes if maintainer
shortDescription Short, summary description of the package. no
longDescription Longer description of the package. no
downloadUrl Location where the package may be downloaded. no
license License for the package. no
manifest Whether to create a Manifest.in along the setup.py. no, defaults to false

Parameters specified as nested elements

fileset or any other resource collection

Specify which files to include or exclude from the setup.py file. This can be useful to exclude a package that should not be part of the Python distribution.

classifier

Specify classifiers for PyPI. This list of possible classifiers can be viewed here. The <classifier> element takes only one attribute name:

<classifier name="Development Status :: 4 - Beta" />

require

Specify dependencies of this package. The dependencies will be installed along the package by the Python installer.

The <require> element takes three attributes:

Attribute Description Required
name Name of the dependency (as specified in PyPI). yes
op Comparison operator for the version. It can be either >, <, ==, <=, >= or !=. yes, if version is specified
version Required version of the dependency. no

Examples

Here is an example of the <setup> task for the package foo.bar containing one Python module hello.py and one data file hello.txt:

<setup
        name="Foo"
        dir="${path.to.package}"
        manifest="true"
        version="1.0"
        url="http://foobar.com"
        author="John Doe"
        authorEmail="john@foobar.com"
        shortDescription="Test package"
        longDescription="Example for the ant task setup"
        license="GPL">
    <classifier name="Development Status :: 4 - Beta" />
    <classifier name="Programming Language :: Python" />

    <require name="numpy" op=">=" version="1.6" />
</setup>

Running this task will generate the following setup.py:

#!/usr/bin/env python
# Created by antpython

from setuptools import setup

setup(
   name='Foo',
   version='1.0',
   url='http://foobar.com',
   author='John Doe',
   author_email='john@foobar.com',
   packages=['foo', 'foo.bar'],
   package_data={'foo.bar': ['hello.txt']},
   description='Test package',
   long_description='Example for the ant task setup',
   classifiers=['Development Status :: 4 - Beta', 'Programming Language :: Python'],
   license='GPL',
   install_requires=['numpy>=1.6'],
)