Doesn't support local paths to wheels

Open
#26 3 comments 0 reactions 0 assignees View on GitHub

@Anurag-S1ngh is already working on this.

Since Oct 31, 2026.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
tooling

Research direction

Reproduce the failure with the req.txt and test.py example using requirements.parse, then trace the parser entry point that passes each line to requirement parsing. The work is done when a local wheel path such as ./humanize-4.14.0-py3-none-any.whl parses without raising, while existing requirement parsing continues to work.

Written by the indexing model from the issue text.

Description

If a requirements.txt file contains a local path with "/", requirements.parse throws rather than parsing it as a local path. Here's a complete example showing that this is a valid file that works with pip:

$ python3.11 -m venv test-venv
$ ./test-venv/bin/pip download humanize
Collecting humanize
  Using cached humanize-4.14.0-py3-none-any.whl.metadata (7.8 kB)
Using cached humanize-4.14.0-py3-none-any.whl (132 kB)
Saved ./humanize-4.14.0-py3-none-any.whl
Successfully downloaded humanize
$ echo ./humanize-4.14.0-py3-none-any.whl > req.txt
$ ./test-venv/bin/pip install -r req.txt
Processing ./humanize-4.14.0-py3-none-any.whl (from -r req.txt (line 1))
Installing collected packages: humanize
Successfully installed humanize-4.14.0
$ ./test-venv/bin/python -c 'import humanize'
$ ./test-venv/bin/pip install requirements-parser==0.13.0
Collecting requirements-parser==0.13.0
  Using cached requirements_parser-0.13.0-py3-none-any.whl.metadata (4.7 kB)
Collecting packaging>=23.2 (from requirements-parser==0.13.0)
  Using cached packaging-25.0-py3-none-any.whl.metadata (3.3 kB)
Using cached requirements_parser-0.13.0-py3-none-any.whl (14 kB)
Using cached packaging-25.0-py3-none-any.whl (66 kB)
Installing collected packages: packaging, requirements-parser
Successfully installed packaging-25.0 requirements-parser-0.13.0
$ cat <<EOF > test.py
import sys
import requirements

with open(sys.argv[1]) as f:
    for r in requirements.parse(f):
        print(r)
EOF
$ ./test-venv/bin/python test.py req.txt
Traceback (most recent call last):
  File "/Users/dborowitz/w/test-venv/lib/python3.11/site-packages/packaging/requirements.py", line 36, in __init__
    parsed = _parse_requirement(requirement_string)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/dborowitz/w/test-venv/lib/python3.11/site-packages/packaging/_parser.py", line 62, in parse_requirement
    return _parse_requirement(Tokenizer(source, rules=DEFAULT_RULES))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/dborowitz/w/test-venv/lib/python3.11/site-packages/packaging/_parser.py", line 71, in _parse_requirement
    name_token = tokenizer.expect(
                 ^^^^^^^^^^^^^^^^^
  File "/Users/dborowitz/w/test-venv/lib/python3.11/site-packages/packaging/_tokenizer.py", line 143, in expect
    raise self.raise_syntax_error(f"Expected {expected}")
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/dborowitz/w/test-venv/lib/python3.11/site-packages/packaging/_tokenizer.py", line 168, in raise_syntax_error
    raise ParserSyntaxError(
packaging._tokenizer.ParserSyntaxError: Expected package name at the start of dependency specifier
    ./humanize-4.14.0-py3-none-any.whl
    ^

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/dborowitz/w/test.py", line 5, in <module>
    for r in requirements.parse(f):
  File "/Users/dborowitz/w/test-venv/lib/python3.11/site-packages/requirements/parser.py", line 90, in parse
    yield Requirement.parse(line)
          ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/dborowitz/w/test-venv/lib/python3.11/site-packages/requirements/requirement.py", line 274, in parse
    return cls.parse_line(line)
           ^^^^^^^^^^^^^^^^^^^^
  File "/Users/dborowitz/w/test-venv/lib/python3.11/site-packages/requirements/requirement.py", line 240, in parse_line
    pkg_req = Req(line_without_comment)
              ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/dborowitz/w/test-venv/lib/python3.11/site-packages/packaging/requirements.py", line 38, in __init__
    raise InvalidRequirement(str(e)) from e
packaging.requirements.InvalidRequirement: Expected package name at the start of dependency specifier
    ./humanize-4.14.0-py3-none-any.whl
    ^
  • requirements-parser version: 0.13.0
  • OS: macOS 26
  • Python: 3.11.14 (Homebrew)
Dominant language
Python
Stars
20
Forks
17
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from aboutcode-org/pip-requirements-parser

All issues in aboutcode-org/pip-requirements-parser

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.