License Public Domain
Lines 13
Keywords
conflict check (1) distribution (3) python (33) setup.py (4) setuptools (4)
Permissions
Viewable by Everyone
Editable by All Siafoo Users
Hide
Easily highlight source code for your blog with our Syntax Highlighter. Join Siafoo Now or Learn More

Check if a Conflicting Distribution is Installed Atom Feed 0

In Brief A quick and dirty way to check if another distribution is installed, and to error if it is. This works well at the top of a setup.py file.... more
# 's
 1import sys
2from pkg_resources import require, DistributionNotFound, VersionConflict
3
4try:
5 require('ConflictingDistribution')
6 print
7 print 'You have ConflictingDistribution installed.'
8 print 'You need to remove ConflictingDistribution from your site-packages'
9 print 'before installing this software, or conflicts may result.'
10 print
11 sys.exit()
12
13except (DistributionNotFound, VersionConflict):
14 pass

A quick and dirty way to check if another distribution is installed, and to error if it is. This works well at the top of a setup.py file.

Replace 'ConflictingDistribution' with your own conflicting distribution.

You can also only error on certain versions of the conflicting distrubtion by requiring those: require('ConflictingDistribution<1.0'). Of course you'll probably want a better error message then :).