AnacondaRecipes / repodata-hotfixes

Changes to package metadata to fix behavior
BSD 3-Clause "New" or "Revised" License
14 stars 20 forks source link

hotfixes don't work for .conda packages if channel doesn't contain an equivalent .tar.bz2 package #96

Open lorenjanwilson opened 4 years ago

lorenjanwilson commented 4 years ago

The current main.py code, and potentially other scripts in this repo as well, won't properly patch a channel that only contains .conda packages. More specifically, it won't properly patch a .conda file's entry in the repodata unless a .tar.bz2 version of the same package is also present.

Here's an example of attempting to patch a small channel which only contains .conda packages and no .tar.bz2 packages. This uses the latest version of main.py here.

$ channel="/c/conda-build-repo/channel2"
$ arch="${channel}/linux-64"
$ ls $arch | grep '.conda$' | wc -l
58
$ ls $arch | grep '.tar.bz2$' | wc -l
0
$ conda index  --verbose --patch-generator repodata-hotfixes/main.py "${channel}"
DEBUG:conda_build.index:found subdirs {'linux-64', 'noarch'}
Building repodata for /c/conda-build-repo/channel2/linux-64
INFO:conda_build.index:Building repodata for /c/conda-build-repo/channel2/linux-64
DEBUG:conda_build.index:using patch generator repodata-hotfixes/main.py for linux-64
Building repodata for /c/conda-build-repo/channel2/noarch
INFO:conda_build.index:Building repodata for /c/conda-build-repo/channel2/noarch
DEBUG:conda_build.index:using patch generator repodata-hotfixes/main.py for noarch
$ cat $arch/patch_instructions.json
{
  "packages": {},
  "patch_instructions_version": 1,
  "remove": [],
  "revoke": []
}
$ grep "zstd >=1.4.4" $arch/repodata.json
        "zstd >=1.4.4,<1.4.5.0a0"

As you can see, the libarchive package, which should have been patched, was not.

If I copy a tar.bz2 version of this package into the channel, it works correctly for both the .conda and .tar.bz2 versions:

$ cp libarchive-3.4.2-h62408e4_0.tar.bz2 "$arch"
$ conda index  --verbose --patch-generator repodata-hotfixes/main.py "${channel}"
DEBUG:conda_build.index:found subdirs {'linux-64', 'noarch'}
Building repodata for /c/conda-build-repo/channel2/linux-64
INFO:conda_build.index:Building repodata for /c/conda-build-repo/channel2/linux-64
DEBUG:conda_build.index:hashing, extracting, and caching libarchive-3.4.2-h62408e4_0.tar.bz2
DEBUG:conda_build.index:using patch generator repodata-hotfixes/main.py for linux-64
Building repodata for /c/conda-build-repo/channel2/noarch
INFO:conda_build.index:Building repodata for /c/conda-build-repo/channel2/noarch
DEBUG:conda_build.index:using patch generator repodata-hotfixes/main.py for noarch
$ cat $arch/patch_instructions.json
{
  "packages": {
    "libarchive-3.4.2-h62408e4_0.tar.bz2": {
      "depends": [
        "bzip2 >=1.0.8,<2.0a0",
        "libgcc-ng >=7.3.0",
        "libxml2 >=2.9.9,<2.10.0a0",
        "lz4-c >=1.9.2,<1.10.0a0",
        "openssl >=1.1.1f,<1.1.2a",
        "xz >=5.2.5,<6.0a0",
        "zlib >=1.2.11,<1.3.0a0",
        "zstd >=1.4.4,<1.5.0a0"
      ]
    }
  },
  "patch_instructions_version": 1,
  "remove": [],
  "revoke": []
}
$ grep "zstd >=1.4.4" $arch/repodata.json
        "zstd >=1.4.4,<1.5.0a0"
        "zstd >=1.4.4,<1.5.0a0"

However, if I copy any other .tar.bz2 package into the channel which also needs to have the same dependency patched, it will patch that .tar.bz2 package, but won't patch the .conda package... a .tar.bz2 file matching each .conda package to be patched needs to be present in order for the script to function properly.

(base) loren@US-00009832:~/extract$ cp blosc-1.19.0-hd408876_0.tar.bz2 $arch
(base) loren@US-00009832:~/extract$ conda index  --verbose --patch-generator repodata-hotfixes/main.py "${channel}"
DEBUG:conda_build.index:found subdirs {'linux-64', 'noarch'}
Building repodata for /c/conda-build-repo/channel2/linux-64
INFO:conda_build.index:Building repodata for /c/conda-build-repo/channel2/linux-64
DEBUG:conda_build.index:hashing, extracting, and caching blosc-1.19.0-hd408876_0.tar.bz2
DEBUG:conda_build.index:using patch generator repodata-hotfixes/main.py for linux-64
Building repodata for /c/conda-build-repo/channel2/noarch
INFO:conda_build.index:Building repodata for /c/conda-build-repo/channel2/noarch
DEBUG:conda_build.index:using patch generator repodata-hotfixes/main.py for noarch
(base) loren@US-00009832:~/extract$ cat $arch/patch_instructions.json
{
  "packages": {
    "blosc-1.19.0-hd408876_0.tar.bz2": {
      "depends": [
        "libgcc-ng >=7.3.0",
        "libstdcxx-ng >=7.3.0",
        "lz4-c >=1.9.2,<1.10.0a0",
        "snappy >=1.1.7,<2.0a0",
        "zlib >=1.2.11,<1.3.0a0",
        "zstd >=1.4.4,<1.5.0a0"
      ]
    }
  },
  "patch_instructions_version": 1,
  "remove": [],
  "revoke": []
}
(base) loren@US-00009832:~/extract$ grep "zstd >=1.4.4" $arch/repodata.json
        "zstd >=1.4.4,<1.5.0a0"
        "zstd >=1.4.4,<1.4.5.0a0"

This seems like it's possibly a bug in the way that the hotfixing scripts handle .conda packages.