Repository navigation
Closed
Labels
enhancementNew feature or request
Description
Version
cyclonedx-bom==1.5.3
Executed command
cyclonedx-py -r -o bom.xml
Use case
Our requirements.txt file references other local python packages. Example of requirements file:
../local-python-package1
../local-python-package2
../local-python-package3
package1==0.0.0
package2==0.0.0
package3==0.0.0
Exception
Traceback (most recent call last):
File "/home/jvdb/repos/venv-tmp/lib/python3.6/site-packages/pkg_resources/_vendor/packaging/requirements.py", line 98, in __init__
req = REQUIREMENT.parseString(requirement_string)
File "/home/jvdb/repos/venv-tmp/lib/python3.6/site-packages/pkg_resources/_vendor/pyparsing.py", line 1654, in parseString
raise exc
File "/home/jvdb/repos/venv-tmp/lib/python3.6/site-packages/pkg_resources/_vendor/pyparsing.py", line 1644, in parseString
loc, tokens = self._parse( instring, 0 )
File "/home/jvdb/repos/venv-tmp/lib/python3.6/site-packages/pkg_resources/_vendor/pyparsing.py", line 1402, in _parseNoCache
loc,tokens = self.parseImpl( instring, preloc, doActions )
File "/home/jvdb/repos/venv-tmp/lib/python3.6/site-packages/pkg_resources/_vendor/pyparsing.py", line 3417, in parseImpl
loc, exprtokens = e._parse( instring, loc, doActions )
File "/home/jvdb/repos/venv-tmp/lib/python3.6/site-packages/pkg_resources/_vendor/pyparsing.py", line 1402, in _parseNoCache
loc,tokens = self.parseImpl( instring, preloc, doActions )
File "/home/jvdb/repos/venv-tmp/lib/python3.6/site-packages/pkg_resources/_vendor/pyparsing.py", line 3739, in parseImpl
return self.expr._parse( instring, loc, doActions, callPreParse=False )
File "/home/jvdb/repos/venv-tmp/lib/python3.6/site-packages/pkg_resources/_vendor/pyparsing.py", line 1402, in _parseNoCache
loc,tokens = self.parseImpl( instring, preloc, doActions )
File "/home/jvdb/repos/venv-tmp/lib/python3.6/site-packages/pkg_resources/_vendor/pyparsing.py", line 3400, in parseImpl
loc, resultlist = self.exprs[0]._parse( instring, loc, doActions, callPreParse=False )
File "/home/jvdb/repos/venv-tmp/lib/python3.6/site-packages/pkg_resources/_vendor/pyparsing.py", line 1406, in _parseNoCache
loc,tokens = self.parseImpl( instring, preloc, doActions )
File "/home/jvdb/repos/venv-tmp/lib/python3.6/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)
Metadata
Metadata
Assignees
Labels
enhancementNew feature or request
Activity
madpah commentedon Dec 15, 2021
Thanks for the report @Jonas-vdb - we'll look into addressing this in the child library
cyclonedx-python-lib.madpah commentedon Dec 15, 2021
@Jonas-vdb - after a quick review, it appears that the root cause is an internal package/method in Python that does not support parsing
requirements.txtfile lines that reference local packages.We see two options, and we are keen to get your views based on your use case:
requirements.txtfiles. This would be valid in once sense as we would not know the package version (given your example above), andversionis a mandatory field for defining aComponentin a CyloneDX BOMEnvironmentParserfunctionality which would:Appreciate your feedback, thanks.
FYI: @jkowalleck
Jonas-vdb commentedon Dec 15, 2021
Thank you for your quick review.
Our current workaround is to remove those packages programmatically and append the content of the requirement files of the linked packages.
I do agree that generating the CycloneDX BOM file from the installed application is the better option. Even though the workaround works at this point, we will probably update our implementation to use the EnvironmentParser.
jkowalleck commentedon Dec 20, 2021
the requirements-parser in use in this project is not the same
pip install -ruses.For a simple reason: this project is not pip. but it supports the output of
pip freeze- see https://github.com/CycloneDX/cyclonedx-python/#requirements👍 I welcome your remark very much, @Jonas-vdb : #284 (comment)
Just as the README of this project states:
--environmentwill find all installed/shipped packages and is most likely the best solution for most users.and regarding requirements-file it clearly described to use
pip freezethat being said, you could help understand your environment better:
Does the
--environmentswitch work for you, @Jonas-vdb ? Does it find your local packages properly and add them to the SBoM ?AnalogJ commentedon Jan 29, 2022
fyi, this is the same error that occurs when the requirements.txt file contains
-e .[-]Requirements file referencing local packages[/-][+]feat: parse `requirements.txt` with locally referenced packages[/+]jkowalleck commentedon Feb 23, 2022
for discussions, feel free to switch to #319