Repository: conda-forge/conda-smithy

Issue:
Use mamba for determing latest versions
Use mamba to determine the latest version of `conda-smithy` and  `conda-forge-pinning` if `mamba` is available. In case of an error, we will always silently fall back to using `conda`.

This saves ~20s for me (12s with mamba, 32s with conda for me in `conda smithy rerender` in `arrow-cpp`).

Checklist
* [x] Added a ``news`` entry

<!--
Please note any issues this fixes using [closing keywords]( https://help.github.com/articles/closing-issues-using-keywords/ ):
-->

<!--
Please add any other relevant info below:
-->



Discussion:
How about just using the link https://api.anaconda.org/package/conda-forge/conda-smithy? Should be much faster.

Resolving patch:
diff --git a/conda_smithy/cli.py b/conda_smithy/cli.py
--- a/conda_smithy/cli.py
+++ b/conda_smithy/cli.py
@@ -1,4 +1,5 @@
 import os
+import logging
 import subprocess
 import sys
 import time
@@ -547,6 +548,7 @@ def __call__(self, args):
 
 
 def main():
+    logging.basicConfig(level=logging.INFO)
 
     parser = argparse.ArgumentParser(
         prog="conda smithy",
diff --git a/conda_smithy/configure_feedstock.py b/conda_smithy/configure_feedstock.py
--- a/conda_smithy/configure_feedstock.py
+++ b/conda_smithy/configure_feedstock.py
@@ -6,9 +6,10 @@
 import textwrap
 import yaml
 import warnings
-from collections import OrderedDict
+from collections import OrderedDict, namedtuple
 import copy
 import hashlib
+import requests
 import time
 
 import conda_build.api
@@ -1315,8 +1316,6 @@ def render_README(jinja_env, forge_config, forge_dir, render_info=None):
     if forge_config["azure"].get("build_id") is None:
         # Try to retrieve the build_id from the interwebs
         try:
-            import requests
-
             resp = requests.get(
                 "https://dev.azure.com/{org}/{project_name}/_apis/build/definitions?name={repo}".format(
                     org=forge_config["azure"]["user_or_org"],
@@ -1558,20 +1557,26 @@ def _load_forge_config(forge_dir, exclusive_config_file):
     return config
 
 
-def get_most_recent_version(resolve, name):
-    from conda_build.conda_interface import VersionOrder, MatchSpec
+def get_most_recent_version(name):
+    from conda_build.conda_interface import VersionOrder
+
+    request = requests.get(
+        "https://api.anaconda.org/package/conda-forge/" + name
+    )
+    request.raise_for_status()
 
-    available_versions = sorted(
-        resolve.get_pkgs(MatchSpec(name)),
-        key=lambda x: VersionOrder(x.version),
+    pkg = max(
+        request.json()["files"], key=lambda x: VersionOrder(x["version"])
     )
-    return available_versions[-1]
+
+    PackageRecord = namedtuple("PackageRecord", ["name", "version", "url"])
+    return PackageRecord(name, pkg["version"], "https:" + pkg["download_url"])
 
 
-def check_version_uptodate(resolve, name, installed_version, error_on_warn):
+def check_version_uptodate(name, installed_version, error_on_warn):
     from conda_build.conda_interface import VersionOrder
 
-    most_recent_version = get_most_recent_version(resolve, name).version
+    most_recent_version = get_most_recent_version(name).version
     if installed_version is None:
         msg = "{} is not installed in conda-smithy's environment.".format(name)
     elif VersionOrder(installed_version) < VersionOrder(most_recent_version):
@@ -1620,22 +1625,14 @@ def commit_changes(forge_file_directory, commit, cs_ver, cfp_ver, cb_ver):
             logger.info("No changes made. This feedstock is up-to-date.\n")
 
 
-def get_cfp_file_path(temporary_directory, resolve=None):
-    if resolve is None:
-        index = conda_build.conda_interface.get_index(
-            channel_urls=["conda-forge"]
-        )
-        resolve = conda_build.conda_interface.Resolve(index)
-
-    pkg = get_most_recent_version(resolve, "conda-forge-pinning")
+def get_cfp_file_path(temporary_directory):
+    pkg = get_most_recent_version("conda-forge-pinning")
     dest = os.path.join(
         temporary_directory, f"conda-forge-pinning-{ pkg.version }.tar.bz2"
     )
 
     logger.info(f"Downloading conda-forge-pinning-{ pkg.version }")
 
-    import requests
-
     response = requests.get(pkg.url)
     response.raise_for_status()
     with open(dest, "wb") as f:
@@ -1795,23 +1792,13 @@ def main(
     logger.setLevel(loglevel)
 
     if check:
-        index = conda_build.conda_interface.get_index(
-            channel_urls=["conda-forge"]
-        )
-        r = conda_build.conda_interface.Resolve(index)
-
         # Check that conda-smithy is up-to-date
-        check_version_uptodate(r, "conda-smithy", __version__, True)
+        check_version_uptodate("conda-smithy", __version__, True)
         return True
 
     error_on_warn = False if no_check_uptodate else True
-    index = conda_build.conda_interface.get_index(channel_urls=["conda-forge"])
-    logger.debug("Beginning Resolving Index")
-    r = conda_build.conda_interface.Resolve(index)
-    logger.debug("Index rendered")
-
     # Check that conda-smithy is up-to-date
-    check_version_uptodate(r, "conda-smithy", __version__, error_on_warn)
+    check_version_uptodate("conda-smithy", __version__, error_on_warn)
 
     forge_dir = os.path.abspath(forge_file_directory)
     if exclusive_config_file is not None:
@@ -1821,7 +1808,7 @@ def main(
         cf_pinning_ver = None
     else:
         exclusive_config_file, cf_pinning_ver = get_cfp_file_path(
-            temporary_directory, r
+            temporary_directory
         )
 
     config = _load_forge_config(forge_dir, exclusive_config_file)


Test patch: