Skip to content

Failure to apply patch regression in rattler-build 0.42.1 #1701

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
traversaro opened this issue May 30, 2025 · 2 comments
Open

Failure to apply patch regression in rattler-build 0.42.1 #1701

traversaro opened this issue May 30, 2025 · 2 comments

Comments

@traversaro
Copy link
Contributor

In conda-forge/torchcodec-feedstock#15 I experienced a regression in a patch that used to apply cleanly in 0.41.0, probably due to the change in the patching implementation.

To reproduce:

git clone https://github.com/conda-forge/torchcodec-feedstock
cd torchcodec-feedstock
git checkout d23287ce540e074ee6a5d4db3f50912abc261c27
# this fails
pixi global install rattler-build==0.42.1
rattler-build build --recipe-dir ./recipe/ -m ./.ci_support/linux_64_cuda_compiler_versionNonepython3.12.____cpython.yaml
# this works
pixi global install rattler-build==0.41.0
rattler-build build --recipe-dir ./recipe/ -m ./.ci_support/linux_64_cuda_compiler_versionNonepython3.12.____cpython.yaml

Example log:

traversaro@IITBMP014LW012:~/torchcodec-feedstock$ pixi global install rattler-build==0.42.1
Global environments as specified in '/home/traversaro/.pixi/manifests/pixi-global.toml'
└── rattler-build: 0.42.1 (already installed)
    └─ exposes: rattler-build
traversaro@IITBMP014LW012:~/torchcodec-feedstock$ rattler-build build --recipe-dir ./recipe/ -m ./.ci_support/linux_64_cuda_compiler_versionNonepython3.12.____cpython.yaml

 ╭─ Finding outputs from recipe
 │ Loading variant config file: "./.ci_support/linux_64_cuda_compiler_versionNonepython3.12.____cpython.yaml"
 │ Found 2 variants
 │
 │ Build variant: torchcodec-0.3.0-cpu_py312_h1c85667_0
 │
 │ ╭───────────────────────┬────────────────────╮
 │ │ Variant               ┆ Version            │
 │ ╞═══════════════════════╪════════════════════╡
 │ │ build_platform        ┆ "linux-64"         │
 │ │ c_compiler            ┆ "gcc"              │
 │ │ c_compiler_version    ┆ "13"               │
 │ │ c_stdlib              ┆ "sysroot"          │
 │ │ c_stdlib_version      ┆ "2.17"             │
 │ │ channel_sources       ┆ "conda-forge"      │
 │ │ channel_targets       ┆ "conda-forge main" │
 │ │ cuda_compiler         ┆ "None"             │
 │ │ cuda_compiler_version ┆ "None"             │
 │ │ cxx_compiler          ┆ "gxx"              │
 │ │ cxx_compiler_version  ┆ "13"               │
 │ │ ffmpeg                ┆ "7"                │
 │ │ libtorch              ┆ "2.6"              │
 │ │ python                ┆ "3.12.* *_cpython" │
 │ │ pytorch               ┆ "2.6"              │
 │ │ target_platform       ┆ "linux-64"         │
 │ ╰───────────────────────┴────────────────────╯
 │
 │ Build variant: torchcodec-tests-0.3.0-cpu_py312_h31c50d3_0
 │
 │ ╭───────────────────────┬──────────────────────────────╮
 │ │ Variant               ┆ Version                      │
 │ ╞═══════════════════════╪══════════════════════════════╡
 │ │ channel_sources       ┆ "conda-forge"                │
 │ │ channel_targets       ┆ "conda-forge main"           │
 │ │ cuda_compiler_version ┆ "None"                       │
 │ │ python                ┆ "3.12.* *_cpython"           │
 │ │ target_platform       ┆ "linux-64"                   │
 │ │ torchcodec            ┆ "0.3.0 cpu_py312_h1c85667_0" │
 │ ╰───────────────────────┴──────────────────────────────╯
 │
 ╰─────────────────── (took 0 seconds)

 ╭─ Running build for recipe: torchcodec-0.3.0-cpu_py312_h1c85667_0
 │
 │ ╭─ Fetching source code
 │ │ Fetching source from url: https://github.com/pytorch/torchcodec/archive/refs/tags/v0.3.0.tar.gz
 │ │ Downloaded file from https://github.com/pytorch/torchcodec/archive/refs/tags/v0.3.0.tar.gz
 │ │ Validated SHA256 values of the downloaded file!
 │ │ Extracting tar file to cache: /home/traversaro/torchcodec-feedstock/output/src_cache/v0_3_0_f535f184.tar.gz
 │ │ Copying source from url: /home/traversaro/torchcodec-feedstock/output/src_cache/v0_3_0_f535f184 to /home/traversaro/torchcodec-feedstock/output/bld/rattler-build_torchcodec_1748607064/work
 │ │ Applying patch: /home/traversaro/torchcodec-feedstock/recipe/use_strict_threshold_only_for_linux_x86_64.patch
 │ │
 │ ╰─────────────────── (took 4 seconds)
 │
 ╰─────────────────── (took 4 seconds)
Error:   × Failed to apply patch: use_strict_threshold_only_for_linux_x86_64.patch
  │ `git apply` failed with a combination of flags.
  │
  │ With the che command:
  │
  │     /usr/bin/git apply -p1 --verbose --ignore-space-change --ignore-whitespace /home/traversaro/torchcodec-feedstock/recipe/use_strict_threshold_only_for_linux_x86_64.patchThe output was:
  │
  │     Checking patch test/utils.py...
  │     error: while searching for:
  │     import json
  │     import os
  │     import pathlib
  │     import sys
  │
  │     from dataclasses import dataclass
  │
  │     error: patch failed: test/utils.py:2
  │     error: test/utils.py: patch does not apply
  │
  │
  │
  │ With the che command:
  │
  │     /usr/bin/git apply -p1 --verbose --ignore-space-change --ignore-whitespace --recount /home/traversaro/torchcodec-feedstock/recipe/use_strict_threshold_only_for_linux_x86_64.patchThe output was:
  │
  │     Checking patch test/utils.py...
  │     error: while searching for:
  │     import json
  │     import os
  │     import pathlib
  │     import sys
  │
  │     from dataclasses import dataclass
  │
  │     error: patch failed: test/utils.py:2
  │     error: test/utils.py: patch does not apply
  │
  │

traversaro@IITBMP014LW012:~/torchcodec-feedstock$ rm -rf output/
traversaro@IITBMP014LW012:~/torchcodec-feedstock$ pixi global install rattler-build==0.42.0
Error:   × Couldn't install rattler-build
  ├─▶ Failed to determine virtual packages for environment rattler-build
  ╰─▶ Cannot solve the request because of: No candidates were found for rattler-build ==0.42.0.


traversaro@IITBMP014LW012:~/torchcodec-feedstock$ pixi global install rattler-build==0.41.0
Global environments as specified in '/home/traversaro/.pixi/manifests/pixi-global.toml'
└── rattler-build: 0.41.0 (installed)
    └─ exposes: rattler-build
traversaro@IITBMP014LW012:~/torchcodec-feedstock$ rm -rf output/
traversaro@IITBMP014LW012:~/torchcodec-feedstock$ pixi global install rattler-build==0.41.0
Global environments as specified in '/home/traversaro/.pixi/manifests/pixi-global.toml'
└── rattler-build: 0.41.0 (already installed)
    └─ exposes: rattler-build
traversaro@IITBMP014LW012:~/torchcodec-feedstock$ rattler-build build --recipe-dir ./recipe/ -m ./.ci_support/linux_64_cuda_compiler_versionNonepython3.12.____cpython.yaml

 ╭─ Finding outputs from recipe
 │ Loading variant config file: "./.ci_support/linux_64_cuda_compiler_versionNonepython3.12.____cpython.yaml"
 │ Found 2 variants
 │
 │ Build variant: torchcodec-0.3.0-cpu_py312_h1c85667_0
 │
 │ ╭───────────────────────┬────────────────────╮
 │ │ Variant               ┆ Version            │
 │ ╞═══════════════════════╪════════════════════╡
 │ │ build_platform        ┆ "linux-64"         │
 │ │ c_compiler            ┆ "gcc"              │
 │ │ c_compiler_version    ┆ "13"               │
 │ │ c_stdlib              ┆ "sysroot"          │
 │ │ c_stdlib_version      ┆ "2.17"             │
 │ │ channel_sources       ┆ "conda-forge"      │
 │ │ channel_targets       ┆ "conda-forge main" │
 │ │ cuda_compiler         ┆ "None"             │
 │ │ cuda_compiler_version ┆ "None"             │
 │ │ cxx_compiler          ┆ "gxx"              │
 │ │ cxx_compiler_version  ┆ "13"               │
 │ │ ffmpeg                ┆ "7"                │
 │ │ libtorch              ┆ "2.6"              │
 │ │ python                ┆ "3.12.* *_cpython" │
 │ │ pytorch               ┆ "2.6"              │
 │ │ target_platform       ┆ "linux-64"         │
 │ ╰───────────────────────┴────────────────────╯
 │
 │ Build variant: torchcodec-tests-0.3.0-cpu_py312_h31c50d3_0
 │
 │ ╭───────────────────────┬──────────────────────────────╮
 │ │ Variant               ┆ Version                      │
 │ ╞═══════════════════════╪══════════════════════════════╡
 │ │ channel_sources       ┆ "conda-forge"                │
 │ │ channel_targets       ┆ "conda-forge main"           │
 │ │ cuda_compiler_version ┆ "None"                       │
 │ │ python                ┆ "3.12.* *_cpython"           │
 │ │ target_platform       ┆ "linux-64"                   │
 │ │ torchcodec            ┆ "0.3.0 cpu_py312_h1c85667_0" │
 │ ╰───────────────────────┴──────────────────────────────╯
 │
 ╰─────────────────── (took 0 seconds)

 ╭─ Running build for recipe: torchcodec-0.3.0-cpu_py312_h1c85667_0
 │
 │ ╭─ Fetching source code
 │ │ Fetching source from url: https://github.com/pytorch/torchcodec/archive/refs/tags/v0.3.0.tar.gz
 │ │ Downloaded file from https://github.com/pytorch/torchcodec/archive/refs/tags/v0.3.0.tar.gz
 │ │ Validated SHA256 values of the downloaded file!
 │ │ Extracting tar file to cache: /home/traversaro/torchcodec-feedstock/output/src_cache/v0_3_0_f535f184.tar.gz
 │ │ Copying source from url: /home/traversaro/torchcodec-feedstock/output/src_cache/v0_3_0_f535f184 to /home/traversaro/torchcodec-feedstock/output/bld/rattler-build_torchcodec_1748607090/work
 │ │ Applying patch: /home/traversaro/torchcodec-feedstock/recipe/use_strict_threshold_only_for_linux_x86_64.patch
 │ │ Applying patch: /home/traversaro/torchcodec-feedstock/recipe/657.patch
 │ │ Applying patch: /home/traversaro/torchcodec-feedstock/recipe/remove_werror.patch
 │ │
 │ ╰─────────────────── (took 3 seconds)
@wolfv
Copy link
Member

wolfv commented Jun 1, 2025

I had a look and the problem is that the context in the patch says:

from dataclasses import dataclass

while in the code it now says:

from dataclasses import dataclass, foobar

Apparently, git does not deal with "fuzzy" context when applying patches, which is definitely a bummer.

I have locally extended diffy to also deal with fuzzy patches which we could use in #1676

We could also go back to use patch, and try to deal with CLRF issues by convertign files on the fly so that patch doesn't complain.

@traversaro
Copy link
Contributor Author

Another reference to a patch that works fine with conda-build and fails with rattler-build 0.42.1 (and also with 0.41.0 in this case) can be found in conda-forge/mujoco-feedstock#85 :

 ╰─────────────────── (took 0 seconds)

 ╭─ Running build for recipe: libmujoco-3.3.2-hdb71998_2
 │
 │ ╭─ Fetching source code
 │ │ Fetching source from url: https://github.com/deepmind/mujoco/archive/refs/tags/3.3.2.tar.gz
 │ │ Downloaded file from https://github.com/deepmind/mujoco/archive/refs/tags/3.3.2.tar.gz
 │ │ Validated SHA256 values of the downloaded file!
 │ │ Extracting tar file to cache: /home/conda/feedstock_root/build_artifacts/src_cache/3_3_2_6ab615ad.tar.gz
 │ │ Copying source from url: /home/conda/feedstock_root/build_artifacts/src_cache/3_3_2_6ab615ad to /home/conda/feedstock_root/build_artifacts/bld/rattler-build_libmujoco_1749296266/work
 │ │ Applying patch: /home/conda/recipe_root/python_remove_avx.patch
 │ │
 │ ╰─────────────────── (took 5 seconds)
 │
 ╰─────────────────── (took 5 seconds)
Error:   × Failed to apply patch: python_remove_avx.patch
  │ `git apply` failed with a combination of flags.
  │ 
  │ With the che command:
  │ 	error: python/mujoco/CMakeLists.txt: patch does not apply
  │ 
  │ 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants