8000 dep_check: stop using unsupported internal pip functions by KhasMek · Pull Request #262 · DataSploit/datasploit · GitHub
[go: up one dir, main page]

Skip to content

dep_check: stop using unsupported internal pip functions #262

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
dep_check: stop using unsupported internal pip functions
  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
commit e0408a0076f4edb608285273117d5328797b07d9
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