pypa / pypa/packaging

Expose Marker tree structure in the API

Open
#496 4 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement packaging.markers
Dominant language
Python
Stars
751
Forks
324
Avg merge
12h 58m
Merged PRs (30d)
3

Description

I'd like to be able to use a library like packaging in Debian's dh-python, to parse environment markers, rather than having to maintain our own hacky parser.

The use-case is parsing .dist-info metadata from a built package, during the build, to generate Debian package dependencies based on the Python module's declared dependencies.

Similarly to #448, this means we're evaluating the markers for all supported environments, not just the current environment. So instead of a boolean evaluate(), we need to:

  1. Determine whether this dependency is required at all (boolean).
  2. Determine what python_version constraints are applied to the module, and emit appropriate Debian dependencies, as possible.

Examples:

  1. Requires-Dist: foo; (os_name == 'posix') should result in a dependency on python3-foo.
  2. Requires-Dist: bar; python_version < '3.5' should result in a dependency on python3-bar | python3 (>= 3.5)

This means evaluate() is insufficient, for our needs. I really need to be able to walk the tree.

Can we make more of the tree structure public API?

Contributor guide

Open the contributing guide

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.

Research direction

Start by reviewing the existing evaluate() API and the marker-tree behavior referenced by issue #448. Determine which tree structure must become public so callers can inspect all supported environments and derive dependency constraints; done means the public API supports traversal beyond a boolean evaluation, with coverage for the requested use cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.