[Distutils] Dependencies conditional on specific installed versions of other dependencies?

Nick Coghlan ncoghlan at gmail.com
Thu Jan 22 06:29:41 CET 2015

On 21 January 2015 at 16:13, Alexander Hill <alex at hill.net.au> wrote:
> Hi all,
> I have run into a bit of a head-scratcher.
> Prior to the upcoming version 1.8, Django included a comments app at
> django.contrib.comments. As of 1.8, the app has been broken out into an
> independent package, django-contrib-comments [1]. django-contrib-comments
> requires Django >= 1.5.
> The project I'm working on (Mezzanine) requires Django comments. I want
> Mezzanine to support Django 1.4 through to 1.8, so I need
> django-contrib-comments. But because it requires Django >= 1.5, when it's in
> my dependencies Django gets automatically upgraded if version 1.4 is
> installed, so the Mezzanine test suite isn't actually run under 1.4 [2].
> Is there some way to only depend on django-contrib-comments if a minimum
> version of Django is installed? Or any other way around this problem? Any
> advice greatly appreciated!

The closest I can think of is to make the comments support an extra,
so you'd need to specify "mezzanine[comments]" to get
django-contrib-comments on 1.5+. That's unlikely to be acceptable in
this case though, since existing dependencies on mezzanine would fail
to install the comments support.

While it won't help you right now, I did have an idea for a possible
way to deal with this in PEP 426: provide a way to specify a set of
"default extras" for a project. Those dependencies would still be
installed by default, but you'd have an easy way to turn them off if
you didn't want them.

Then, in this case, you'd be able to run the Django 1.4 tests using
"mezzanine[-comments]" rather than a default install to avoid
attempting to install django-contrib-comments.

Filed as: https://github.com/pypa/interoperability-peps/issues/18


Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia

More information about the Distutils-SIG mailing list