Repository navigation
Closed
Labels
enhancementNew feature or request
Description
We have a private pypi repository, and so our requirements.txt file (per https://pip.pypa.io/en/stable/reference/requirements-file-format/) has a --index-url pointing to our private index.
This worked fine with older versions of cyclonedx-python, but newer versions (notably 3.0.0) now fails with a runtime exception.
long stack trace
Traceback (most recent call last):
File "/Users/rdlee/Documents/tivo-research/git/poetry_test_lib/build/poetry-test-lib-lx3mW_5N-py3.10/lib/python3.10/site-packages/pkg_resources/_vendor/packaging/requirements.py", line 102, in __init__
req = REQUIREMENT.parseString(requirement_string)
File "/Users/rdlee/Documents/tivo-research/git/poetry_test_lib/build/poetry-test-lib-lx3mW_5N-py3.10/lib/python3.10/site-packages/pkg_resources/_vendor/pyparsing.py", line 1654, in parseString
raise exc
File "/Users/rdlee/Documents/tivo-research/git/poetry_test_lib/build/poetry-test-lib-lx3mW_5N-py3.10/lib/python3.10/site-packages/pkg_resources/_vendor/pyparsing.py", line 1644, in parseString
loc, tokens = self._parse( instring, 0 )
File "/Users/rdlee/Documents/tivo-research/git/poetry_test_lib/build/poetry-test-lib-lx3mW_5N-py3.10/lib/python3.10/site-packages/pkg_resources/_vendor/pyparsing.py", line 1402, in _parseNoCache
loc,tokens = self.parseImpl( instring, preloc, doActions )
File "/Users/rdlee/Documents/tivo-research/git/poetry_test_lib/build/poetry-test-lib-lx3mW_5N-py3.10/lib/python3.10/site-packages/pkg_resources/_vendor/pyparsing.py", line 3417, in parseImpl
loc, exprtokens = e._parse( instring, loc, doActions )
File "/Users/rdlee/Documents/tivo-research/git/poetry_test_lib/build/poetry-test-lib-lx3mW_5N-py3.10/lib/python3.10/site-packages/pkg_resources/_vendor/pyparsing.py", line 1402, in _parseNoCache
loc,tokens = self.parseImpl( instring, preloc, doActions )
File "/Users/rdlee/Documents/tivo-research/git/poetry_test_lib/build/poetry-test-lib-lx3mW_5N-py3.10/lib/python3.10/site-packages/pkg_resources/_vendor/pyparsing.py", line 3739, in parseImpl
return self.expr._parse( instring, loc, doActions, callPreParse=False )
File "/Users/rdlee/Documents/tivo-research/git/poetry_test_lib/build/poetry-test-lib-lx3mW_5N-py3.10/lib/python3.10/site-packages/pkg_resources/_vendor/pyparsing.py", line 1402, in _parseNoCache
loc,tokens = self.parseImpl( instring, preloc, doActions )
File "/Users/rdlee/Documents/tivo-research/git/poetry_test_lib/build/poetry-test-lib-lx3mW_5N-py3.10/lib/python3.10/site-packages/pkg_resources/_vendor/pyparsing.py", line 3400, in parseImpl
loc, resultlist = self.exprs[0]._parse( instring, loc, doActions, callPreParse=False )
File "/Users/rdlee/Documents/tivo-research/git/poetry_test_lib/build/poetry-test-lib-lx3mW_5N-py3.10/lib/python3.10/site-packages/pkg_resources/_vendor/pyparsing.py", line 1406, in _parseNoCache
loc,tokens = self.parseImpl( instring, preloc, doActions )
File "/Users/rdlee/Documents/tivo-research/git/poetry_test_lib/build/poetry-test-lib-lx3mW_5N-py3.10/lib/python3.10/site-packages/pkg_resources/_vendor/pyparsing.py", line 2711, in parseImpl
raise ParseException(instring, loc, self.errmsg, self)
pkg_resources._vendor.pyparsing.ParseException: Expected W:(abcd...) (at char 0), (line:1, col:1)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/rdlee/Documents/tivo-research/git/poetry_test_lib/build/poetry-test-lib-lx3mW_5N-py3.10/bin/cyclonedx-py", line 8, in <module>
sys.exit(main())
File "/Users/rdlee/Documents/tivo-research/git/poetry_test_lib/build/poetry-test-lib-lx3mW_5N-py3.10/lib/python3.10/site-packages/cyclonedx_py/client.py", line 260, in main
CycloneDxCmd(args).execute()
File "/Users/rdlee/Documents/tivo-research/git/poetry_test_lib/build/poetry-test-lib-lx3mW_5N-py3.10/lib/python3.10/site-packages/cyclonedx_py/client.py", line 113, in execute
output = self.get_output()
File "/Users/rdlee/Documents/tivo-research/git/poetry_test_lib/build/poetry-test-lib-lx3mW_5N-py3.10/lib/python3.10/site-packages/cyclonedx_py/client.py", line 63, in get_output
parser = self._get_input_parser()
File "/Users/rdlee/Documents/tivo-research/git/poetry_test_lib/build/poetry-test-lib-lx3mW_5N-py3.10/lib/python3.10/site-packages/cyclonedx_py/client.py", line 252, in _get_input_parser
return RequirementsParser(requirements_content=input_data)
File "/Users/rdlee/Documents/tivo-research/git/poetry_test_lib/build/poetry-test-lib-lx3mW_5N-py3.10/lib/python3.10/site-packages/cyclonedx_py/parser/requirements.py", line 33, in __init__
for requirement in requirements:
File "/Users/rdlee/Documents/tivo-research/git/poetry_test_lib/build/poetry-test-lib-lx3mW_5N-py3.10/lib/python3.10/site-packages/pkg_resources/__init__.py", line 3159, in __init__
super(Requirement, self).__init__(requirement_string)
File "/Users/rdlee/Documents/tivo-research/git/poetry_test_lib/build/poetry-test-lib-lx3mW_5N-py3.10/lib/python3.10/site-packages/pkg_resources/_vendor/packaging/requirements.py", line 104, in __init__
raise InvalidRequirement(
pkg_resources.extern.packaging.requirements.InvalidRequirement: Parse error at "'--index-'": Expected W:(abcd...)
It appears that cyclonedx_bom is using pkg_resources to parse a requirement.txt file? I don't think that library is quite up to the task, as it doesn't appear to have support for the full syntax of pip, and is just implementing a subset of the support for PEP 508. Perhaps you should use the requirements-parser library instead?
Metadata
Metadata
Assignees
Labels
enhancementNew feature or request
Activity
jkowalleck commentedon Feb 23, 2022
@madpah i dont see an actual urge for this feature, and i dont see it as a bug.
relative pathsprivate repositories*are not to be expected to be output ofpip freezebut it is a convenient feature, no doubt.
*edited[-]passing a requirements.txt file to -r fails when using private pypi repository.[/-][+]passing a `requirements.txt` file with **private pypi repository**[/+][-]passing a `requirements.txt` file with **private pypi repository**[/-][+]feat: `requirements.txt` file with **private pypi repository**[/+][-]feat: `requirements.txt` file with **private pypi repository**[/-][+]feat: `requirements.txt` file with private pypi repository[/+][-]feat: `requirements.txt` file with private pypi repository[/-][+]feat: parse `requirements.txt` with private pypi repository[/+]llamahunter commentedon Feb 23, 2022
This is not about "relative paths", it is about private pypi repos.
jkowalleck commentedon Feb 23, 2022
re: #318 (comment)
you are right.
nevertheless:
i do not see an actual urge for this feature, and i do not see it as a bug.
private repositories are not to be expected to be output of
pip freeze.but it is a convenient feature, no doubt.
jkowalleck commentedon Feb 23, 2022
another discussion, that proposes to switch to another requirements-parser:
#315 (comment)
jkowalleck commentedon Feb 23, 2022
for discussions, feel free to switch to #319
llamahunter commentedon Mar 1, 2022
Note that the documentation for cyclone-dx doesn't say 'the output of pip freeze', it says a 'requirements.txt' file. The documentation for that is here:
https://pip.pypa.io/en/stable/reference/requirements-file-format/
Note that it does include
-ifor specifying private pypi repo indices.llamahunter commentedon Mar 1, 2022
This is a pretty urgent feature, as when we updated to the latest python cyclondx-bom version, our builds all broke.
jkowalleck commentedon Mar 1, 2022
see the original documentation: https://github.com/CycloneDX/cyclonedx-python/tree/v1.5.3#requirements
this is not the place for OT discussions
PS: the mentioned docus, that explain the usage with
pip freezecan be found here:llamahunter commentedon Mar 1, 2022
It's hardly off topic to discuss the tool having broken in recent updates for files it previously supported.