Skip to content

Commit 92b7dae

Browse files
Address feedback from reviews
Signed-off-by: Ayan Sinha Mahapatra <ayansmahapatra@gmail.com>
1 parent 3d3eebe commit 92b7dae

File tree

17 files changed

+740
-8523
lines changed

17 files changed

+740
-8523
lines changed

src/packagedcode/pypi.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import json
1414
import logging
1515
import os
16+
import posixpath
1617
import re
1718
import sys
1819
import tempfile
@@ -394,9 +395,11 @@ def assign_package_to_resources(cls, package, resource, codebase, package_adder)
394395
if not dist_info_dir:
395396
return
396397

398+
# This could be a regular directory too which is not `site-packages`
397399
site_packages = dist_info_dir.parent(codebase)
398400
if not site_packages:
399401
return
402+
400403
package_data = resource.package_data
401404
assert len(resource.package_data) == 1, (
402405
f'Unsupported Pypi METADATA wheel structure: {resource.path!r} '
@@ -417,6 +420,7 @@ def assign_package_to_resources(cls, package, resource, codebase, package_adder)
417420
# most of thense are references to bin ../../../bin/wheel
418421
cannot_resolve = False
419422
ref_resource = site_packages
423+
# note that resolving leading ".." always stays in the codebase
420424
while path_ref.startswith('..'):
421425
_, _, path_ref = path_ref.partition('../')
422426
ref_resource = ref_resource.parent(codebase)
@@ -429,14 +433,14 @@ def assign_package_to_resources(cls, package, resource, codebase, package_adder)
429433
continue
430434
else:
431435
ref_resource = codebase.get_resource(
432-
path=os.path.join(ref_resource.path, path_ref)
436+
path=posixpath.join(ref_resource.path, path_ref)
433437
)
434438
if ref_resource and package_uid:
435439
package_adder(package_uid, ref_resource, codebase)
436440
else:
437441
# These are absolute paths from the site-packages directory
438442
ref_resource = codebase.get_resource(
439-
path=os.path.join(site_packages.path, path_ref)
443+
path=posixpath.join(site_packages.path, path_ref)
440444
)
441445
if ref_resource and package_uid:
442446
package_adder(package_uid, ref_resource, codebase)

tests/packagedcode/data/pypi/site-packages/codebase/bin/pip-3.8

Whitespace-only changes.

tests/packagedcode/data/pypi/site-packages/codebase/bin/pip3

Whitespace-only changes.

tests/packagedcode/data/pypi/site-packages/codebase/lib/python3.9/site-packages/click-8.0.4.dist-info/RECORD

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,38 +5,4 @@ click-8.0.4.dist-info/RECORD,,
55
click-8.0.4.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
66
click-8.0.4.dist-info/top_level.txt,sha256=J1ZQogalYS4pphY_lPECoNMfw0HzTSrZglC4Yfwo4xA,6
77
click/__init__.py,sha256=bOKrvMqmR9rN07vN_ycyrdF-EcTCl-EmuAjq-Fp4yPM,3243
8-
click/__pycache__/__init__.cpython-36.pyc,,
9-
click/__pycache__/_compat.cpython-36.pyc,,
10-
click/__pycache__/_termui_impl.cpython-36.pyc,,
11-
click/__pycache__/_textwrap.cpython-36.pyc,,
12-
click/__pycache__/_unicodefun.cpython-36.pyc,,
13-
click/__pycache__/_winconsole.cpython-36.pyc,,
14-
click/__pycache__/core.cpython-36.pyc,,
15-
click/__pycache__/decorators.cpython-36.pyc,,
16-
click/__pycache__/exceptions.cpython-36.pyc,,
17-
click/__pycache__/formatting.cpython-36.pyc,,
18-
click/__pycache__/globals.cpython-36.pyc,,
19-
click/__pycache__/parser.cpython-36.pyc,,
20-
click/__pycache__/shell_completion.cpython-36.pyc,,
21-
click/__pycache__/termui.cpython-36.pyc,,
22-
click/__pycache__/testing.cpython-36.pyc,,
23-
click/__pycache__/types.cpython-36.pyc,,
24-
click/__pycache__/utils.cpython-36.pyc,,
25-
click/_compat.py,sha256=JIHLYs7Jzz4KT9t-ds4o4jBzLjnwCiJQKqur-5iwCKI,18810
26-
click/_termui_impl.py,sha256=qK6Cfy4mRFxvxE8dya8RBhLpSC8HjF-lvBc6aNrPdwg,23451
27-
click/_textwrap.py,sha256=10fQ64OcBUMuK7mFvh8363_uoOxPlRItZBmKzRJDgoY,1353
28-
click/_unicodefun.py,sha256=JKSh1oSwG_zbjAu4TBCa9tQde2P9FiYcf4MBfy5NdT8,3201
29-
click/_winconsole.py,sha256=5ju3jQkcZD0W27WEMGqmEP4y_crUVzPCqsX_FYb7BO0,7860
30-
click/core.py,sha256=MYYmvqVa_dh4x4f-mr7VyNi6197ucYbJ0fsWW5EnCrA,111432
31-
click/decorators.py,sha256=5ZngOD72Flo8VLN29iarI0A5u_F-dxmqtUqx4KN8hOg,14879
32-
click/exceptions.py,sha256=7gDaLGuFZBeCNwY9ERMsF2-Z3R9Fvq09Zc6IZSKjseo,9167
33-
click/formatting.py,sha256=Frf0-5W33-loyY_i9qrwXR8-STnW3m5gvyxLVUdyxyk,9706
34-
click/globals.py,sha256=TP-qM88STzc7f127h35TD_v920FgfOD2EwzqA0oE8XU,1961
35-
click/parser.py,sha256=cAEt1uQR8gq3-S9ysqbVU-fdAZNvilxw4ReJ_T1OQMk,19044
36-
click/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
37-
click/shell_completion.py,sha256=HHH0wMwlDW4WQhs8rRcS9M8MAo9gltGBN6V2PEbsTp0,18003
38-
click/termui.py,sha256=mZ12uc3-loFaV__vr8buxn9uIjAhy7QwVuZOQ8jDdjc,28873
39-
click/testing.py,sha256=ptpMYgRY7dVfE3UDgkgwayu9ePw98sQI3D7zZXiCpj4,16063
40-
click/types.py,sha256=rj2g3biAXKkNKV8vlwbIKSUlixhXybH84N84fwCYqUU,35092
41-
click/utils.py,sha256=M8tuplcFFHROha3vQ60ZRSakSB_ng6w9e8Uc1AugPZ0,18934
42-
../../../bin/pip,,
8+
click/core.py,sha256=MYYmvqVa_dh4x4f-mr7VyNi6197ucYbJ0fsWW5EnCrA,111432
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
Metadata-Version: 2.1
2+
Name: pip
3+
Version: 20.2.2
4+
Summary: The PyPA recommended tool for installing Python packages.
5+
Home-page: https://pip.pypa.io/
6+
Author: The pip developers
7+
Author-email: distutils-sig@python.org
8+
License: MIT
9+
Project-URL: Documentation, https://pip.pypa.io
10+
Project-URL: Source, https://github.com/pypa/pip
11+
Project-URL: Changelog, https://pip.pypa.io/en/stable/news/
12+
Keywords: distutils easy_install egg setuptools wheel virtualenv
13+
Platform: UNKNOWN
14+
Classifier: Development Status :: 5 - Production/Stable
15+
Classifier: Intended Audience :: Developers
16+
Classifier: License :: OSI Approved :: MIT License
17+
Classifier: Topic :: Software Development :: Build Tools
18+
Classifier: Programming Language :: Python
19+
Classifier: Programming Language :: Python :: 2
20+
Classifier: Programming Language :: Python :: 2.7
21+
Classifier: Programming Language :: Python :: 3
22+
Classifier: Programming Language :: Python :: 3.5
23+
Classifier: Programming Language :: Python :: 3.6
24+
Classifier: Programming Language :: Python :: 3.7
25+
Classifier: Programming Language :: Python :: 3.8
26+
Classifier: Programming Language :: Python :: Implementation :: CPython
27+
Classifier: Programming Language :: Python :: Implementation :: PyPy
28+
Requires-Python: >=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*
29+
30+
pip - The Python Package Installer
31+
==================================
32+
33+
pip is the `package installer`_ for Python. You can use pip to install packages from the `Python Package Index`_ and other indexes.
34+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
pip/__init__.py,sha256=fZ401OZGdv55YGsuCEhsvdNa4YCZLmK457SN3qrstJk,455
2+
pip/__main__.py,sha256=bqCAM1cj1HwHCDx3WJa-LJxOBXimGxE8OjBqAvnhVg0,911
3+
pip/_internal/__init__.py,sha256=2si23JBW1erg19xIJ8CD6tfGknz0ijtXmzuXjGfGMGE,495
4+
pip/_internal/main.py,sha256=IVBnUQ-FG7DK6617uEXRB5_QJqspAsBFmTmTesYkbdQ,437
5+
pip/_internal/cli/main.py,sha256=Hxc9dZyW3xiDsYZX-_J2cGXT5DWNLNn_Y7o9oUme-Ec,2616
6+
pip-20.2.2.dist-info/LICENSE.txt,sha256=W6Ifuwlk-TatfRU2LR7W1JMcyMj5_y1NkRkOEJvnRDE,1090
7+
pip-20.2.2.dist-info/METADATA,sha256=ZMrQjU30hfRVRViE4qoVrwZzDSRyGCT8OdkDkkTMBv8,3708
8+
pip-20.2.2.dist-info/WHEEL,sha256=kGT74LWyRUZrL4VgLh6_g12IeVl_9u9ZVhadrgXZUEY,110
9+
pip-20.2.2.dist-info/entry_points.txt,sha256=HtfDOwpUlr9s73jqLQ6wF9V0_0qvUXJwCBz7Vwx0Ue0,125
10+
pip-20.2.2.dist-info/top_level.txt,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
11+
pip-20.2.2.dist-info/RECORD,,
12+
../../../bin/pip-3.8,,
13+
../../../bin/pip3,,
14+
pip-20.2.2.dist-info/__pycache__,,
15+
../../../bin/pip,,
16+
pip-20.2.2.virtualenv,,
17+
../../../bin/pip3.8,,

0 commit comments

Comments
 (0)