Skip to content

Skip compiled conda packages instead of failing apply - #2183

Merged
Mikola Lysenko (mikolalysenko) merged 2 commits into
mainfrom
fix/conda-compiled-skip
Nov 20, 2026
Merged

Mikola Lysenko (mikolalysenko) merged 2 commits into
mainfrom
fix/conda-compiled-skip

Conversation

@mikolalysenko

@mikolalysenko Mikola Lysenko (mikolalysenko) commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

#2166 made apply refuse a compiled conda build of a Python package (pillow, numpy, pyyaml from conda-forge) with conda_build_not_pypi_release and exit 1. Such a build is never the PyPI wheel a patch was made from, so nothing may be written to it. But it is also something socket-patch does not support yet, and a run should not fail over it: a manifest recorded on a machine that installs PyPI wheels, then applied in a pixi or conda environment, failed CI for a package that cannot be patched there at all. scan --mode agent already treated the same case as a skip (the patch is left out with a warning, exit 0).

The owner's decision: compiled conda packages are skipped for now; they are not supported yet.

What changes

A compiled conda build is skipped, not failed. Nothing is written to it, whatever the record and whatever was passed (--force included).

  • apply prints Warning: <purl>: conda_build_not_pypi_release: … compiled conda packages are not supported yet, so it was skipped and is not patched once per copy, emits one skipped event per record (errorCode: conda_build_not_pypi_release), counts the records as N not supported in the summary, and leaves the exit status as it is. The same holds for --dry-run, and for the apply that scan --mode agent and get run.
  • apply --check does not call the copy drift: the same warning and events, and N not supported, skipped on its result line. It judges a compiled copy as apply does, per copy over every record of the release, so a copy that holds one record's patch is in sync and is not judged for a sibling record.
  • A compiled copy that already holds a patch (an earlier release wrote it) is still reported as already patched.
  • The skip is decided for every record of the release, whether or not the copy's files match it. Before, the usual compiled build (a recipe-patched source, no wheel extension modules) failed as no matching variant found.

Pure-Python conda builds are unchanged: patched when every replaced file is the release's, refused with exit 1 for a platform wheel's record on its own or a file that differs.

How a copy with no WHEEL is judged compiled (an .egg-info install, such as conda-forge's setuptools). It was read from the files of its top-level names, which is wrong in two ways now that the answer decides between a skip and a patch: a shared library another distribution put into a shared namespace package (google, zope) made a pure build look compiled, and a build with no top_level.txt whose import name differs from its distribution name (PyYAML, yaml) looked pure and was patched. The conda package's own file list, its record in the environment's conda-meta, now says which files are its own. The old reading remains only for a copy no record lists.

Verification

  • cargo clippy --locked --workspace --all-features -- -D warnings: clean. cargo test -p socket-patch-core --lib (8324), -p socket-patch-cli --lib (1026) and -p socket-patch-cli --lib --test apply --test get --test scan --test in_process_python_envs --test rollback --test remove --test mode_migration_pypi --test in_process_pypi_apply: all pass.
  • New and changed tests: a_compiled_conda_build_is_skipped_even_when_the_file_matches (three record kinds, with --force, --allow-patch-conflicts, --dry-run), a_compiled_conda_build_that_differs_from_the_wheel_is_skipped_and_checks_clean (also --check and --json), a_compiled_conda_build_holding_one_records_patch_is_in_sync, a_compiled_conda_build_beside_a_pip_installed_wheel_is_skipped_and_the_wheel_patched, the summary and event unit test, and an_egg_info_conda_build_is_judged_by_its_conda_record.
  • scripts/backtest-pixi.py on real pixi 0.84.2 (macOS arm64): 13 of 13 cells pass.
  • A real pixi environment from conda-forge with pyyaml (compiled), setuptools (.egg-info, no INSTALLER, no WHEEL) and certifi: apply --dry-run, with and without --force, skips pyyaml with one warning and exit 0, and reads setuptools as pure from its real conda record; apply --check reports only the two unpatched pure packages.

Code review

/code-review high ran twice on this diff, and every finding it confirmed is fixed here.

First round, three important:

  1. apply --check reported a compiled copy that holds one record's patch as out of sync. Fixed: the copy is settled once, over every record of its release.
  2. apply --check --json said every installed copy is patched while one was skipped. Fixed: the skip has its own event, and the reason reads every installed copy that can be patched is patched.
  3. A pure .egg-info build in a shared namespace package was now skipped quietly, and a compiled one without top_level.txt was written to. Fixed by reading the conda record, as above.

Second round, two important, both in code the first round added:

  1. The "already holds its patch" record of apply --check was keyed by the copy's path, which is the site-packages directory every package of the environment shares, so another package's unpatched copy there read as not installed. Fixed: it is kept per release. Test: a_compiled_conda_build_holding_its_patch_does_not_hide_another_packages_drift.
  2. The conda record was not found when site-packages was reached through a link (conda's lib/python3.1 -> python3.13). Fixed: both paths are resolved first, and apply --check treats two spellings of one directory as one copy, as apply does. Test: a_compiled_conda_build_under_two_spellings_of_its_directory_is_skipped_once.

Smaller points fixed: a file name that merely contains .so. is no longer a shared library; one skipped event per record and copy, so a second environment's copy is named; a scan / get --json run carries the skip of a record it did not select; the contract's --check row, the get <uuid> case, the already-patched rule and what vex does are stated as the code behaves.

Bugbot reported two findings on the first push, both fixed in a281846:

  1. A nested scan / get --json dropped the skip of a compiled copy when another copy of the record was patched, and named one of several skipped copies. Fixed: each skipped copy has its event, beside the applied copy's. Test: record_apply_outcome_says_each_copy_skipped_as_not_supported.
  2. A compiled copy that already holds one record's patch left a sibling record reported as not installed, while apply --check passes over it. Fixed: the copy accounts for every record of its release in apply too.

Not changed, all present before this PR:

  • apply --vex fails with no_applicable_patches when nothing in the project is attestable. A project whose only patches are for compiled conda packages reaches that.
  • A copy that matches no release variant fails the run with an Error: line and no failed event. Beside a skipped compiled copy of the same package, the envelope then carries only the skip events.
  • A record whose patch content cannot be staged (--offline with a missing blob) fails before any copy is looked at, including one that would be skipped.

🤖 Generated with Claude Code

A compiled conda build of a Python package (pillow, numpy, pyyaml from
conda-forge) is never the PyPI wheel a patch is made from, so nothing
may be written to it. `apply` refused such a copy with
`conda_build_not_pypi_release` and exit 1. That failed a run over a
package socket-patch does not support yet: a manifest recorded where
PyPI wheels are installed, then applied in a pixi or conda environment,
could not pass. `scan --mode agent` already left the same patch out
with a warning and exit 0.

Compiled conda packages are now skipped:

- `apply` writes nothing to the copy (also under `--force`), warns once
  per copy, emits a `skipped` event per record and copy, counts the
  records as `N not supported`, and leaves the exit status as it is. A
  copy that already holds a patch is still reported as already patched.
- The skip is the copy's, for every record of the release, whether or
  not its files match one. The usual compiled build (a recipe-patched
  source, no wheel extension modules) used to fail as "no matching
  variant found".
- `apply --check` does not call the copy drift. It settles a compiled
  copy as `apply` does, once over every record of its release and per
  release, so a copy that holds one record's patch is in sync, and
  another package in the same site-packages is judged on its own.
- Under `--json`, a `scan` / `get` whose apply skips a copy of a record
  the run did not select carries that skip.

Pure-Python conda builds are unchanged: patched when every replaced
file is the release's, refused for a platform wheel's record on its own
or a file that differs.

Whether a copy with no `WHEEL` (an `.egg-info` install) is compiled is
now read from the conda package's own file list, its record in the
environment's `conda-meta`. The files of its top-level names were the
only evidence before, which took a shared library another distribution
put into a shared namespace package for its own, and missed one in a
module the metadata does not name; with the answer now deciding between
a skip and a write, both matter. That reading remains for a copy no
record lists.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@cursor

cursor Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes patch-application and CI --check behavior for pixi/conda Python envs; mistakes in compiled-vs-pure detection could skip patchable packages or still mis-report sync state.

Overview
Compiled conda site-packages copies are treated as unsupported, not errors. apply, nested apply in scan/get, and apply --check emit warnings and skipped events (conda_build_not_pypi_release), count them in summary/not supported lines, and do not change exit status or mark drift when the only issue is a compiled conda env. Copies that already hold a patch still report already patched; apply --check settles conda copies per release (including symlinked python3.1 → python3.13 spellings).

Detection of “compiled” for .egg-info installs now prefers the package’s conda-meta file list (shared libs in namespace packages, PyYAML-style naming) instead of scanning top-level module trees alone.

scan/get JSON forwards compiled-copy skips from nested apply so they are not silently dropped under --json.

Reviewed by Cursor Bugbot for commit f823816. Configure here.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit f823816. Configure here.

@mikolalysenko Mikola Lysenko (mikolalysenko) added the Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review label Nov 20, 2026
Two Bugbot findings on the compiled-conda skip:

- The outcomes a nested apply hands to `scan` and `get` dropped the
  skip of a compiled conda copy when another copy of the same record
  was patched, and kept one skip per record however many environments
  hold a copy. A `--json` run then read as fully applied, or named one
  of several unpatched copies. Each skipped copy now has its event,
  beside the applied copy's, as `apply --json` reports it.
- A compiled conda copy that already holds one record's patch left a
  sibling record its files do not match reported as not installed,
  while `apply --check` passes over it. The copy now accounts for every
  record of its release in `apply` too.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Merged via the queue into main with commit e6c5f50 Nov 20, 2026
50 checks passed
@mikolalysenko
Mikola Lysenko (mikolalysenko) deleted the fix/conda-compiled-skip branch November 20, 2026 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants