Check if a Conflicting Distribution is Installed
| 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 |
| Language | Python |
# '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 :).
Add a Comment