 |
 |
 |
Distributing Python Modules |
 |
 |
 |
A distribution may relate to packages in three specific ways:
- It can require packages or modules.
- It can provide packages or modules.
- It can obsolete packages or modules.
These relationships can be specified using keyword arguments to the
distutils.core.setup() function.
Dependencies on other Python modules and packages can be specified by
supplying the requires keyword argument to setup().
The value must be a list of strings. Each string specifies a package
that is required, and optionally what versions are sufficient.
To specify that any version of a module or package is required, the
string should consist entirely of the module or package name.
Examples include 'mymodule' and 'xml.parsers.expat'.
If specific versions are required, a sequence of qualifiers can be
supplied in parentheses. Each qualifier may consist of a comparison
operator and a version number. The accepted comparison operators are:
These can be combined by using multiple qualifiers separated by commas
(and optional whitespace). In this case, all of the qualifiers must
be matched; a logical AND is used to combine the evaluations.
Let's look at a bunch of examples:
| Requires Expression |
Explanation |
==1.0 |
Only version 1.0 is compatible |
>1.0, !=1.5.1, <2.0 |
Any version after 1.0 and before
2.0 is compatible, except
1.5.1 |
Now that we can specify dependencies, we also need to be able to
specify what we provide that other distributions can require. This is
done using the provides keyword argument to setup().
The value for this keyword is a list of strings, each of which names a
Python module or package, and optionally identifies the version. If
the version is not specified, it is assumed to match that of the
distribution.
Some examples:
| Provides Expression |
Explanation |
mypkg |
Provide mypkg, using the distribution version |
mypkg (1.1) |
Provide mypkg version 1.1, regardless of the
distribution version |
A package can declare that it obsoletes other packages using the
obsoletes keyword argument. The value for this is similar to
that of the requires keyword: a list of strings giving module or
package specifiers. Each specifier consists of a module or package
name optionally followed by one or more version qualifiers. Version
qualifiers are given in parentheses after the module or package name.
The versions identified by the qualifiers are those that are obsoleted
by the distribution being described. If no qualifiers are given, all
versions of the named module or package are understood to be
obsoleted.
Release 2.5.2, documentation updated on 21th February, 2008.
See About this document... for information on suggesting changes.
|