Skip to content

Commit 18592ea

Browse files
committed
- corrected version of vendored search_packages_info() from pip
- handle relative imports
1 parent 0f3088e commit 18592ea

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

CHANGELOG.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
Release History
22
---------------
33

4+
1.1.2
5+
- corrected version of vendored search_packages_info() from pip
6+
- handle relative imports
7+
48
1.1.1
59
- fixed handling of import from __future__
610
- self-tested and added own requirements.txt

pip_missing_reqs/find_missing_reqs.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,13 @@ def search_packages_info(query): # pragma: no cover
4141
lines = dist.get_metadata_lines('RECORD')
4242
paths = [l.split(',')[0] for l in lines]
4343
paths = [os.path.join(dist.location, p) for p in paths]
44-
file_list = [os.path.relpath(p, dist.egg_info)
45-
for p in paths]
44+
file_list = [os.path.relpath(p, dist.location) for p in paths]
4645
else:
4746
# Otherwise use pip's log for .egg-info's
4847
if dist.has_metadata('installed-files.txt'):
49-
file_list = dist.get_metadata_lines('installed-files.txt')
48+
paths = dist.get_metadata_lines('installed-files.txt')
49+
paths = [os.path.join(dist.egg_info, p) for p in paths]
50+
file_list = [os.path.relpath(p, dist.location) for p in paths]
5051
# use and short-circuit to check for None
5152
package['files'] = file_list and sorted(file_list)
5253
yield package
@@ -81,6 +82,9 @@ def visit_ImportFrom(self, node):
8182
# not an actual module
8283
return
8384
for alias in node.names:
85+
if node.module is None:
86+
# relative import
87+
continue
8488
self.__addModule(node.module + '.' + alias.name, node.lineno)
8589

8690
def __addModule(self, modname, lineno):

pip_missing_reqs/test_find_missing_reqs.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ def test_find_imported_modules(monkeypatch, caplog, ignore_ham, ignore_hashlib,
104104
class FakeFile():
105105
contents = [
106106
'from os import path\nimport ast, hashlib',
107-
'from __future__ import braces\nimport ast, sys',
107+
'from __future__ import braces\nimport ast, sys\n'
108+
'from . import friend',
108109
]
109110

110111
def __init__(self, filename):

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
setup(
1414
name='pip_missing_reqs',
15-
version='1.1.1',
15+
version='1.1.2',
1616
description='Find packages that should be in requirements for a project',
1717
long_description=long_description,
1818
url='https://github.com/r1chardj0n3s/pip-missing-reqs',

0 commit comments

Comments
 (0)