Project:Python/Dependencies

This article aims to shed some light on which Python packages should be listed as runtime dependencies, build-time dependencies or both.

Build-time dependencies
Build-time dependencies need to include all packages that are required for the package to build correctly and reliably. That is, a package needs to be included in build dependencies if at least one of the following conditions hold:
 * a script or a Python module from this package is used (run, loaded) at build time,
 * the setup script aborts if the package is not detected to be installed (setuptools),
 * the setup script installs incomplete package if the package is not installed.

If the missing package results only in a harmless warning, it can be omitted. However, when in doubt, include all runtime dependencies of the packages in DEPEND to avoid trouble.

Tests usually require all (or most) of the runtime dependencies, so if you do not include them normally in DEPEND, you probably want to use a construct like:

If tests have optional dependencies, all of them should be included (preferably unconditionally) in the test dependencies to ensure the best test coverage.

Runtime dependencies
Runtime dependencies need to include all packages that are required for the package to be useful when installed. A package needs to be included in runtime dependencies if the installed Python scripts and/or modules use the package.

If a runtime dependency is optional, common sense should be used to determine the best solution (in order of preference):
 * 1) for small and/or commonly used dependencies, the dependency may just be included unconditionally;
 * 2) a pkg_postinst message can be printed about missing optional runtime dependencies;
 * 3) if rebuilding package does not require a significant effort, USE flags might be used to control dependencies.

If the package in question installs its test files, it is not strictly required to include the test dependencies in the runtime dependencies. The tests are not considered commonly used components of the package, and therefore their dependencies can be treated as optional.