[FEATURE] Better and more complete parsing for `requirements.txt` files
See original GitHub issueWe currently utilise pkg_resources.parse_requirements
to parse lines from requirements.txt
files.
This seemingly has a number of short comings that it does not support. See:
This feature will look at alternatives to the above method to attempt to support these other formats. CycloneDX/cyclonedx-python-lib#97 may have identified a candidate in requirements-parser
- TBC.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Create Your requirements.txt Using This Technique
The most common technique to create a requirements.txt file is to run pip freeze > requirements.txt when all packages are already installed.
Read more >likely error parsing requirements.txt · Issue #381 ... - GitHub
Obtaining file:///tmp/dftimewolf ERROR: Command errored out with exit status 1: command: /tmp/venv/bin/python3 -c 'import sys, setuptools, ...
Read more >The Python Requirements File and How to Create it
It is a simple text file that saves a list of the modules and packages required by your project. By creating a Python...
Read more >A Better Practice for Managing Many extras_require ...
This allows one to later cherry-pick the feature via pip install ... a package-to-feature map in a separate plain text file, then parse...
Read more >Proper way to parse requirements file after pip upgrade to pip ...
First, I believe parsing requirements.txt from within setup.py is not a good idea. It should be the other way around, install_requires in ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
we might need to see what
pip install -r
uses as a parser. this is the parser most people know and the reason why people expect the same features here, too.unfortunately the parser is internal:
pip._internal.req.parse_requirements
- see https://github.com/pypa/pip/blob/main/src/pip/_internal/req/__init__.py see further: https://github.com/pypa/pip/blob/main/src/pip/_internal/req/req_file.pyThe whole topic seams to be an issue, because people dont read properly and confuse our
requirements.txt
capabilities with the one they know from some project they use without knowing what they are actually doing. We should have cyclonedx-python-lib’srequirements
-parser comply to PEP508 - as the readme tells - and that is it. everything else can be implemented by volunteer contributors, if they need additional features.@jkowalleck thanks for quick return!
It’s my understanding - which may be incorrect - that PEP508 allows for
requirements.txt
to only supply the name of the dependency, that’s at least what I gather from the abstract: “… The job of a dependency is to enable tools like pip [1] to find the right package to install. Sometimes this is very loose - just specifying a name, and sometimes very specific - referring to a specific file to install…”.My goal is to cover all use cases for the SBOM generation and hence I’d need to be able to support all variations of dependencies and formats for describing these. I did test out the above change in
requirements.py
:Which yields the below bom
Would this still be considered breaking changes?