pypa / pypa/packaging

Allow requirement.Marker.evaluate() with arbitrary environment

Open
#431 1 comment 1 reaction 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

One of the use case of the packaging library is to support tooling that may run in a different environment than the processed packages are intended for. For instance, I may want to process a Requirement.marker and evaluate() it on a different platform environment that is not the environment of the current Python interpreter. However, the evaluate() method environment arg can only update the environment and can never override/replace it entirely.
https://github.com/pypa/packaging/blob/8c78c35bc20fc7b4aacb7a71ad5f5db9817630c1/packaging/markers.py#L302

It would be useful for tools to be able to entirely override the environment rather than just updating it.

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 in packaging/markers.py around the evaluate() method at the linked line, and inspect how the supplied environment is combined with the interpreter environment. Trace the existing marker evaluation coverage, then define and test behavior where a caller-provided environment fully replaces the default environment.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.