[Distutils] dependencies, pip and non-PyPI-hosted packages

Carl Meyer carl at oddbird.net
Tue Apr 19 23:18:20 CEST 2011

On 04/19/2011 04:07 PM, Ernesto Posse wrote:
> 1) using distribute and
>   setup(..., install_requires=['project1'],...,
> dependency_links=['http://my.host.org/repository/'],...)
> installs as expected both project1 and project2, but
>   pip uninstall project2
> does not uninstall project1. This is quite disappointing, as a user
> may be unaware of dependencies automatically installed, and thus, the
> uninstall leaves behind something that was installed with the bundle.
> I imagine that the idea is that the user may install some other
> package that depends on 'project1' and pip takes the conservative
> approach (is that the case?) but I would have expected for pip or
> distribute or setuptools or distutils to keep some dependency
> reference counter. Does any of these tools have something like that?
> or is it going to be addressed in distutils2?

No, there's no current Python packaging tool I know of that keeps a
dependency reference counter and automatically uninstalls orphaned
dependencies. The new standard installation format (defined in PEP 376
and implemented in distutils2) does record whether a package was
installed by explicit user request or as a dependency; combined with
checking dependencies of all other installed packages, this will make it
possible for an uninstaller to implement automatic (or prompted)
dependency uninstalls.

> 2) if install_requires is missing a dependency (project1), the package
> gets installed without that dependency, but if I add a dependency and
> the user attempts an install (project2) with the updated setup.py
> (listing the new dependency) pip will say that the package (project2)
> is already installed and won't attempt to install the dependencies. Is
> this correct? If so, is there a way to tell pip to install project2's
> dependencies?

With a real package release, the setup.py metadata should never change
without a version number change. In which case, if you specify the new
version explicitly or use --upgrade, the previous version will be
uninstalled and the new one installed in its place, with dependencies.
(Actually, if you specify --upgrade and you already have the most recent
version installed, it will still uninstall and reinstall it; but this is
actually considered a bug.)


More information about the Distutils-SIG mailing list