Skip to content

Commit

Permalink
dep_check: stop using unsupported internal pip functions
Browse files Browse the repository at this point in the history
  pip.get_installed_distributions() is in internal function
  that was never meant to be externally called and has since
  been locked out by external functions.

  Lets switch over to the supported function in setuptools
  pkg_resources.get_distribution() to search the installed
  packages.

  See: pypa/pip#5243
  Fixes: 255
  • Loading branch information
KhasMek committed Jul 29, 2018
1 parent c7c9ef4 commit 1d4d622
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions dep_check.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
import pip
import pkg_resources
import sys

def check_dependency():
list_deps = []
missing_deps = []

with open('requirements.txt') as f:
list_deps = f.read().splitlines()

pip_list = sorted([(i.key) for i in pip.get_installed_distributions()])

for req_dep in list_deps:
if req_dep not in pip_list:
missing_deps.append(req_dep)
with open('requirements.txt', 'r') as reqs_file:
for req_dep in reqs_file.read().splitlines():
try:
pkg_resources.get_distribution(req_dep)
except pkg_resources.DistributionNotFound:
missing_deps.append(req_dep)

if missing_deps:
print "You are missing a module for Datasploit. Please install them using: "
print "pip install -r requirements.txt"
print "You are missing the following module(s) needed to run DataSploit:"
print ", ".join(missing_deps)
print "Please install them using: `pip install -r requirements.txt`"
sys.exit()

0 comments on commit 1d4d622

Please sign in to comment.