Skip to content

Commit 2f088ac

Browse files
committed
Remove vendored implementation of search_packages_info in favour of internal pip implementation
1 parent d3daaed commit 2f088ac

File tree

5 files changed

+3
-54
lines changed

5 files changed

+3
-54
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ jobs:
3737
3838
- name: "Run tests"
3939
run: |
40-
# We currently require 99% test coverage and not 100% as this is the
41-
# level that coverage was at when the CI restriction was introduced.
42-
pytest -s -vvv --cov-fail-under 99 --cov=pip_check_reqs/ --cov=tests tests/ --cov-report=xml
40+
pytest -s -vvv --cov-fail-under 100 --cov=pip_check_reqs/ --cov=tests tests/ --cov-report=xml
4341
4442
- name: "Upload coverage to Codecov"
4543
uses: "codecov/codecov-action@v1"

pip_check_reqs/common.py

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -157,43 +157,3 @@ def f(candidate, ignore_cfg=ignore_cfg):
157157
return False
158158

159159
return f
160-
161-
162-
def search_packages_info(query):
163-
"""
164-
Gather details from installed distributions. Print distribution name,
165-
version, location, and installed files. Installed files requires a
166-
pip generated 'installed-files.txt' in the distributions '.egg-info'
167-
directory.
168-
"""
169-
installed = {}
170-
for p in pkg_resources.working_set:
171-
installed[canonicalize_name(p.project_name)] = p
172-
173-
query_names = [canonicalize_name(name) for name in query]
174-
175-
for dist in [installed[pkg] for pkg in query_names if pkg in installed]:
176-
package = {
177-
'name': dist.project_name,
178-
'version': dist.version,
179-
'location': dist.location,
180-
'requires': [dep.project_name for dep in dist.requires()],
181-
}
182-
file_list = None
183-
if isinstance(dist, pkg_resources.DistInfoDistribution):
184-
# RECORDs should be part of .dist-info metadatas
185-
if dist.has_metadata('RECORD'):
186-
lines = dist.get_metadata_lines('RECORD')
187-
paths = [line.split(',')[0] for line in lines]
188-
paths = [os.path.join(dist.location, p) for p in paths]
189-
file_list = [os.path.relpath(p, dist.location) for p in paths]
190-
else:
191-
# Otherwise use pip's log for .egg-info's
192-
if dist.has_metadata('installed-files.txt'):
193-
paths = dist.get_metadata_lines('installed-files.txt')
194-
paths = [os.path.join(dist.egg_info, p) for p in paths]
195-
file_list = [os.path.relpath(p, dist.location) for p in paths]
196-
197-
if file_list:
198-
package['files'] = sorted(file_list)
199-
yield package

pip_check_reqs/find_extra_reqs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
import sys
66

77
from packaging.utils import canonicalize_name
8+
from pip._internal.commands.show import search_packages_info
89
from pip._internal.utils.misc import get_installed_distributions
910
from pip_check_reqs import common
10-
from pip_check_reqs.common import search_packages_info
1111

1212
log = logging.getLogger(__name__)
1313

pip_check_reqs/find_missing_reqs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
import sys
66

77
from packaging.utils import canonicalize_name
8+
from pip._internal.commands.show import search_packages_info
89
from pip._internal.download import PipSession
910
from pip._internal.req.req_file import parse_requirements
1011
from pip._internal.utils.misc import get_installed_distributions
1112

1213
from pip_check_reqs import common
13-
from pip_check_reqs.common import search_packages_info
1414

1515
log = logging.getLogger(__name__)
1616

tests/test_common.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,3 @@ def ignore_reqs(req):
179179

180180
reqs = common.find_required_modules(options)
181181
assert reqs == set(['foobar'])
182-
183-
184-
def test_search_packages_info():
185-
# We know that 'packaging' will be installed because it is a requirement of
186-
# this package.
187-
installed_package = 'packaging'
188-
query = ('packaging', )
189-
[result] = [item for item in common.search_packages_info(query=query)]
190-
assert result['name'] == installed_package

0 commit comments

Comments
 (0)