condaconda-forgemamba

print all unmet dependencies in conda


I'm trying to install a package via conda on an M1 mac. This package has a lot of dependencies, some of which seem to be un-satisfiable due to lack of pre-built packages in conda-forge.

I know I can trigger building of packages in conda-forge by issuing a PR like shown here, but I'd prefer sending one big PR with all the packages I need built, rather than trigger building of package A, trying to install, running into dependency B, trigger building of package B, ...

Can I somehow list all unmet dependencies of a conda package?


Solution

  • Trivial case: directly missing package

    First, let's note that this question only has a non-trivial answer when the package in question is noarch. A noarch designation means the package itself is already compatible with osx-arm64. But if it cannot be installed with a plain mamba install, then some non-noarch (compiled) dependency(s) must be missing.

    Otherwise, if the package were not noarch and does not itself have osx-arm64 builds, then requesting migration for that package would trigger both the package and all its (recursive) dependencies to be made available for osx-arm64. (Conda Forge bot is smart like that!)

    I'm not assuming OP has any confusion about this, but I want to get ahead of this situation for the future visitors. Now that that's out of the way let's address OP's question proper...

    Available package, but missing dependencies

    We can absolutely do this with Mamba's amazing subcommand repoquery. Let's find ourselves a concrete example!

    Finding an example

    To illustrate, I know that Conda Forge doesn't have r-terra building for osx-arm64 right now1. We can use the mamba repoquery whoneeds command to list every noarch package that needs r-terra:

    ## search `conda-forge` and only consider `noarch`
    $ mamba repoquery whoneeds -c conda-forge -p noarch r-terra
    
    ## abridged output, only showing r-base=4.2 packages
    
     Name         Version Build         Depends          Channel
    ────────────────────────────────────────────────────────────────────────
     r-rasterdiv  0.2_5.2 r42hc72bb7e_1 r-terra          conda-forge/noarch
     r-rastervis  0.51.2  r42hc72bb7e_1 r-terra          conda-forge/noarch
     r-biomod2    4.2_2   r42hc72bb7e_0 r-terra >=1.6_33 conda-forge/noarch
     r-biomod2    4.2_3   r42hc72bb7e_0 r-terra >=1.6_33 conda-forge/noarch
     r-rasterdiv  0.3.1   r42hc72bb7e_0 r-terra          conda-forge/noarch
     r-rastervis  0.51.4  r42hc72bb7e_0 r-terra          conda-forge/noarch
     r-rastervis  0.51.5  r42hc72bb7e_0 r-terra          conda-forge/noarch
     r-spatialeco 2.0_0   r42hc72bb7e_0 r-terra          conda-forge/noarch
     r-rasterdiv  0.2_5.2 r42hc72bb7e_1 r-terra          conda-forge/noarch
     r-rastervis  0.51.2  r42hc72bb7e_1 r-terra          conda-forge/noarch
     r-biomod2    4.2_2   r42hc72bb7e_0 r-terra >=1.6_33 conda-forge/noarch
     r-biomod2    4.2_3   r42hc72bb7e_0 r-terra >=1.6_33 conda-forge/noarch
     r-rasterdiv  0.3.1   r42hc72bb7e_0 r-terra          conda-forge/noarch
     r-rastervis  0.51.4  r42hc72bb7e_0 r-terra          conda-forge/noarch
     r-rastervis  0.51.5  r42hc72bb7e_0 r-terra          conda-forge/noarch
     r-spatialeco 2.0_0   r42hc72bb7e_0 r-terra          conda-forge/noarch
    

    So, all of these are theoretically compatible with osx-arm64, but they depend on the package r-terra that isn't available yet.

    Let's use for our example, r-spatialeco.

    Missing dependencies of r-spatialeco

    Above we used the whoneeds subcommand for a reverse dependency search; now we'll use the depends command for (forward) dependency search:

    $ mamba repoquery depends -c conda-forge -p osx-arm64 r-spatialeco
    
    Executing the query r-spatialeco
    
    conda-forge/osx-arm64                                       Using cache
    conda-forge/noarch                                          Using cache
    
    
     Name                            Version Build         Channel
    ─────────────────────────────────────────────────────────────────────────────
     r-spatialeco                    2.0_0   r41hc72bb7e_0 conda-forge/noarch
     r-mass                          7.3_53  r40h4d528fc_0 conda-forge/osx-arm64
     r-cluster                       2.1.0   r40h09a9d6b_4 conda-forge/osx-arm64
     r-rcurl >>> NOT FOUND <<<
     r-readr                         2.0.2   r40h8ea1354_0 conda-forge/osx-arm64
     r-sf >>> NOT FOUND <<<
     r-mgcv                          1.8_33  r40hdd02fd4_0 conda-forge/osx-arm64
     r-rann                          2.6.1   r40h39468a4_2 conda-forge/osx-arm64
     r-envstats                      2.3.1   r351_1000     conda-forge/noarch
     r-yaimpute >>> NOT FOUND <<<
     r-spdep >>> NOT FOUND <<<
     r-rms >>> NOT FOUND <<<
     r-terra >>> NOT FOUND <<<
     r-ks                            1.14.0  r41h5d63f41_0 conda-forge/osx-arm64
     r-spatstat.explore              3.0_5   r41h5d63f41_0 conda-forge/osx-arm64
     r-base                          4.1.3   hc39b4fc_7    conda-forge/osx-arm64
     r-spatialpack >>> NOT FOUND <<<
     r-spatstat.geom                 3.2_1   r42h21dc0da_0 conda-forge/osx-arm64
    

    And there you have it: the r-spatialeco package is missing seven packages that need to be migrated to osx-arm64, as indicated by the >>> NOT FOUND <<< string.


    [1]: I know this because I've taken a stab at getting it migrated multiple times and have yet to succeed. :/