Thanks to visit codestin.com
Credit goes to docs.rs

Skip to main content

Crate uv_requirements_txt

Crate uv_requirements_txt 

Source
Expand description

Parses a subset of requirement.txt syntax

https://pip.pypa.io/en/stable/reference/requirements-file-format/

Supported:

Unsupported:

  • <path>. TBD
  • <archive_url>. TBD
  • Options without a requirement, such as --find-links or --index-url

Grammar as implemented:

file = (statement | empty ('#' any*)? '\n')*
empty = whitespace*
statement = constraint_include | requirements_include | editable_requirement | requirement
constraint_include = '-c' ('=' | wrappable_whitespaces) filepath
requirements_include = '-r' ('=' | wrappable_whitespaces) filepath
editable_requirement = '-e' ('=' | wrappable_whitespaces) requirement
# We check whether the line starts with a letter or a number, in that case we assume it's a
# PEP 508 requirement
# https://packaging.python.org/en/latest/specifications/name-normalization/#valid-non-normalized-names
# This does not (yet?) support plain files or urls, we use a letter or a number as first
# character to assume a PEP 508 requirement
requirement = [a-zA-Z0-9] pep508_grammar_tail wrappable_whitespaces hashes
hashes = ('--hash' ('=' | wrappable_whitespaces) [a-zA-Z0-9-_]+ ':' [a-zA-Z0-9-_] wrappable_whitespaces+)*
# This should indicate a single backslash before a newline
wrappable_whitespaces = whitespace ('\\\n' | whitespace)*

Structs§

RequirementEntry
A Requirement with additional metadata from the requirements.txt, currently only hashes but in the future also editable and similar information.
RequirementsTxt
Parsed and flattened requirements.txt with requirements and constraints
RequirementsTxtFileError
Error parsing requirements.txt, wrapper with filename

Enums§

RequirementsTxtParserError
Error parsing requirements.txt, error disambiguation
RequirementsTxtRequirement
A requirement specifier in a requirements.txt file.

Type Aliases§

SourceCache
A cache of file contents, keyed by path, to avoid re-reading files from disk.