Skip to content

Commit d70e46d

Browse files
committed
Fixed how installed packages are detected (#175)
1 parent 03f3c0d commit d70e46d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

mbed/mbed.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,11 +1164,12 @@ def post_action(self):
11641164
missing = []
11651165
fname = 'requirements.txt'
11661166
try:
1167-
import pkgutil
1167+
import pip
1168+
installed_packages = [package.project_name for package in pip.get_installed_distributions()]
11681169
with open(os.path.join(mbed_os_path, fname), 'r') as f:
11691170
for line in f.read().splitlines():
1170-
pkg = re.sub(r'^([\w-]+).*$', r'\1', line)
1171-
if pkgutil.find_loader(pkg) is None:
1171+
pkg = re.sub(r'^([\w-]+).*$', r'\1', line).lower()
1172+
if not pkg in installed_packages:
11721173
missing.append(pkg)
11731174
except IOError:
11741175
pass

0 commit comments

Comments
 (0)