Skip to content

Commit b97c3b9

Browse files
Remove hash_options from requirement to avoid packvers parsing issues
The compatibility check is already ignoring the `hash_options` [1], while a `Requirement` is still constructed in [2] and [3]. This causes the application to crash and fail to create a result. Remove the `hash_options` for now until `packvers.requirements.Requirement` supports this option. [1]: https://github.com/aboutcode-org/python-inspector/blob/3ad3925840e8dad16ad12b3917f04ec3172590ad/src/_packagedcode/pypi.py#L999 [2]: https://github.com/aboutcode-org/python-inspector/blob/3ad3925840e8dad16ad12b3917f04ec3172590ad/src/python_inspector/api.py#L484 [3]: https://github.com/aboutcode-org/python-inspector/blob/3ad3925840e8dad16ad12b3917f04ec3172590ad/src/python_inspector/resolution.py#L259 Related to #243. Signed-off-by: Marcel Bochtler <[email protected]>
1 parent ff07d0e commit b97c3b9

File tree

5 files changed

+564
-2
lines changed

5 files changed

+564
-2
lines changed

src/_packagedcode/pypi.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ def parse(cls, location):
534534
for metapath in path.iterdir():
535535
if not metapath.name.endswith('METADATA'):
536536
continue
537-
537+
538538
yield parse_metadata(
539539
location=metapath,
540540
datasource_id=cls.datasource_id,
@@ -945,6 +945,8 @@ def get_requirements_txt_dependencies(location, include_nested=False):
945945

946946
purl = purl and purl.to_string() or None
947947

948+
hash_options = req.hash_options or []
949+
req.hash_options = []
948950
requirement = req.dumps()
949951

950952
if location.endswith(
@@ -973,7 +975,7 @@ def get_requirements_txt_dependencies(location, include_nested=False):
973975
extra_data=dict(
974976
is_editable=req.is_editable,
975977
link=req.link and req.link.url or None,
976-
hash_options=req.hash_options or [],
978+
hash_options=hash_options,
977979
is_constraint=req.is_constraint,
978980
is_archive=req.is_archive,
979981
is_wheel=req.is_wheel,

tests/data/hash-requirements.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
addict==2.4.0 \
2+
--hash=sha256:249bb56bbfd3cdc2a004ea0ff4c2b6ddc84d53bc2194761636eb314d5cfa5dfc \
3+
--hash=sha256:b3b2210e0e067a281f5646c8c5db92e99b7231ea8b0eb5f74dbdf9e259d4e494
4+
5+
requests==2.25.1 \
6+
--hash=sha256:c210084e36a42ae6b9219e00e48287def368a26d03a048ddad7bfee44f75871e \
7+
--hash=sha256:27973dd4a904a4f13b263a19c866c13b92a39ed1c964655f025f3f8d3d75b804

0 commit comments

Comments
 (0)