I have a program that uses dateutil from the package index. I would like to have setup.py check for for its presence and try to get it using easy_install if it is not there.
The documentation for distutils seems to indicate that this can be done using the requires keyword in setup(), but when I try, it installs on a system without dateutil without giving a warning or installing the required package.
The only thing I could find on google was this blog post about the same issue which did not have any answer either.
Am I using distutils wrong? Do I need to subclass distutils.command.install and do the checking/installing myself?
Automatic downloading of dependencies is a feature introduced by setuptools which is a third-party add-on to
distutils, in particular, theinstall_requiresargument it adds. See the setuptools documentation for more information.Another option is to use
requirements.txtfile with pip rather than usingeasy_installas a package installer.piphas now become the recommended installer; see the Python Packaging User Guide for more information.Update [2015-01]: The previous version of this answer referred to the
distributefork ofsetuptools. Thedistributefork has since been merged back into a newer activesetuptoolsproject.distributeis now dead and should no longer be used.setuptoolsandpipare now very actively maintained and support Python 3.