Skip to content

🐛 fix(pylock): use target marker values - #4331

Merged
gaborbernat merged 7 commits into
tox-dev:mainfrom
rahuldevikar:radevika-microsoft-fix-pylock-markers-host-interpreter
Oct 31, 2026
Merged

gaborbernat merged 7 commits into
tox-dev:mainfrom
rahuldevikar:radevika-microsoft-fix-pylock-markers-host-interpreter

Conversation

@rahuldevikar

@rahuldevikar rahuldevikar commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

PythonRun._install_pylock at the merge base supplied five marker values from the target interpreter. packaging supplied missing values from the tox interpreter, so a Python 3.11 environment could install the package locked for Python 3.15. tox now evaluates lock markers with all 11 standard values from the target interpreter. Fixes #4246.

Missing target marker values

The old marker mapping omitted implementation_version, among other values. Issue #4246 shows the wrong package selection when the tox and environment interpreters differ. python-discovery PR #178 adds the complete target marker mapping to the interpreter record that virtualenv obtains during discovery. The 1.9.0 release exports its 11-key MarkerEnvironment type, which tox now requires. Virtualenv discovery passes that mapping through tox's interpreter record to lock evaluation. The built-in path needs no separate marker subprocess.

Runners without discovery metadata

tox-uv constructs tox's interpreter record without a marker field. The new field is optional so that constructor remains valid. A runner with a pylock-capable installer and no discovery metadata asks python-discovery to query its selected interpreter with tox's target environment variables and keeps the environment record. An unavailable or incomplete result stops installation.

Lock file cutoff

The project lock at the merge base pinned python-discovery 1.6.4, which cannot satisfy the new minimum. The default seven-day upload cutoff excludes the 1.9.0 files. A cutoff for python-discovery admits those files, and the lock entry now pins 1.9.0.

Behavior changes

pylock.toml markers now select packages for the target interpreter on built-in virtualenv paths. Built-in virtualenv creation reuses discovery data; runners without that data query their selected interpreter through python-discovery. If either result is incomplete, tox reports a marker environment error and does not install from the lock. tox-uv's installer at f9e1241 rejects pylock files. This PR leaves dependency installation without pylock.toml unchanged.

Reported by Anthropic OSS Scanner: ANT-2026-O73ECNS8.

@rahuldevikar
rahuldevikar force-pushed the radevika-microsoft-fix-pylock-markers-host-interpreter branch 3 times, most recently from 41c3546 to 0b0b893 Compare October 30, 2026 18:00
@gaborbernat gaborbernat added the bug A confirmed defect label Oct 30, 2026
@gaborbernat gaborbernat changed the title fix(pylock): evaluate markers against the target interpreter 🐛 fix(pylock): use target marker values Oct 30, 2026
@gaborbernat
gaborbernat marked this pull request as draft October 30, 2026 19:08
@gaborbernat
gaborbernat force-pushed the radevika-microsoft-fix-pylock-markers-host-interpreter branch from d3a7fc9 to 89a3ff3 Compare October 30, 2026 23:32
@gaborbernat
gaborbernat marked this pull request as ready for review October 30, 2026 23:33
@gaborbernat
gaborbernat marked this pull request as draft October 30, 2026 23:33
@gaborbernat
gaborbernat marked this pull request as ready for review October 30, 2026 23:38
@gaborbernat
gaborbernat marked this pull request as draft October 30, 2026 23:45
@gaborbernat
gaborbernat force-pushed the radevika-microsoft-fix-pylock-markers-host-interpreter branch from 98914c7 to b36cf91 Compare October 30, 2026 23:49
@gaborbernat
gaborbernat marked this pull request as ready for review October 30, 2026 23:49
@gaborbernat
gaborbernat marked this pull request as draft October 30, 2026 23:56
rahuldevikar and others added 7 commits October 30, 2026 17:52
A partial probe lets packaging fill missing marker keys from the tox
host, which can select the wrong lock entry for a target interpreter.

Reject incomplete output and exercise marker selection through tox runs.

Refs tox-dev#4246
virtualenv already queries the target interpreter while selecting a creator.
Use that result for lock markers without a separate marker subprocess.

Keep existing constructor and probe calls valid for plugins.
Probe the target when discovery metadata is absent.
The project lock excludes releases newer than seven days, while tox now
requires python-discovery 1.9. Admit its published files and refresh the
single affected lock entry.
The plugin path still ran a marker script inside tox. Query the selected
interpreter through python-discovery using its tox environment.

Keep the virtualenv record instead of resolving to the base interpreter;
the base can produce different marker values.
@gaborbernat
gaborbernat force-pushed the radevika-microsoft-fix-pylock-markers-host-interpreter branch from b36cf91 to 4dc8db1 Compare October 31, 2026 00:55
@gaborbernat
gaborbernat marked this pull request as ready for review October 31, 2026 00:55
@gaborbernat
gaborbernat merged commit b9e7a31 into tox-dev:main Oct 31, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug A confirmed defect

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pylock markers partly use the host interpreter

2 participants