Skip to content

PEP 508 parenthesized requirements include opening parenthesis in package names #52

Description

@andrew

Running git-pkgs list --format json on python-poetry/poetry parses parenthesized PEP 508 requirements with ( included in the package name and ) included in the requirement.

Poetry's pyproject.toml at commit 92b74dcfe348d0e01e14d40d6c1fa47a4ee04a54 includes entries such as:

"requests (>=2.26,<3.0)"

With git-pkgs 0.18.2, this can be reproduced with:

git clone https://github.com/python-poetry/poetry.git
cd poetry
GIT_PKGS_DB=/tmp/git-pkgs-pep508.sqlite git-pkgs list --format json \
  | jq -c '.[] | select(.manifest_path == "pyproject.toml") | select(.name == "requests (")'

The result contains:

{"name":"requests (","requirement":">=2.26,<3.0)","purl":"pkg:pypi/requests%20(","dependency_type":"runtime","manifest_path":"pyproject.toml"}

I expected the name to be requests, the requirement to be >=2.26,<3.0, and the purl to be pkg:pypi/requests.

The same problem affects the other parenthesized entries in that file, including packaging (>=24.2) and platformdirs (>=3.0.0,<5). It appears to come from parsePEP508, which starts the version at an operator but does not account for optional parentheses around the version specifier.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions