Repository: conda-forge/conda-smithy

Issue:
conda update being run after the ci install version is set on osx
The osx env is updated after the ci setup script package is installed so the 2.* is not respected. 


Discussion:
This problem is likely general. I think ci setup package should inject its version into the pinned file.
or we need to patch the smithy recipe with the correct pin
or we can put the pinning injection into the ci scripts by hand
cc @isuruf 
We could use https://github.com/conda-forge/conda-smithy/blob/master/conda_smithy/templates/run_osx_build.sh.tmpl on azure too and switch to miniforge.
Is that robust enough? I am wondering if we want to directly pin the 2.* requirement in smithy's recipe.
> We could use https://github.com/conda-forge/conda-smithy/blob/master/conda_smithy/templates/run_osx_build.sh.tmpl on azure too and switch to miniforge.

I 100% agree with this change for the record. Right now the build scripts are pretty annoying to keep in sync. Having one per platform except windows is a big win.
That script is osx specific. I think the conda update is because the root environment is already there with `defaults`. If we use conda-forge as the root environment, we don't need to update.
> That script is osx specific. I think the conda update is because the root environment is already there with defaults. If we use conda-forge as the root environment, we don't need to update.

Yup. We'd have build_script.sh (or w/e it is called) on linux, and the one above for osx, which is one per platform except for windows.
I suspect that everyone participating in this thread realizes this, but this is breaking at least some CI processing, e.g. conda-forge/rust-feedstock#51.
I pulled the offending package, so try again it should work. 

Resolving patch:
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
@@ -817,7 +817,7 @@ def _circle_specific_setup(jinja_env, forge_config, forge_dir, platform):
         template_files.append(".scripts/run_docker_build.sh")
         template_files.append(".scripts/build_steps.sh")
     else:
-        template_files.append(".circleci/run_osx_build.sh")
+        template_files.append(".scripts/run_osx_build.sh")
 
     _render_template_exe_files(
         forge_config=forge_config,
@@ -919,11 +919,6 @@ def render_circle(jinja_env, forge_config, forge_dir, return_metadata=False):
             os.path.join(forge_dir, ".circleci", "checkout_merge_commit.sh"),
             os.path.join(forge_dir, ".circleci", "fast_finish_ci_pr_build.sh"),
         ],
-        "linux": [
-            os.path.join(forge_dir, ".scripts", "run_docker_build.sh"),
-            os.path.join(forge_dir, ".scripts", "build_steps.sh"),
-        ],
-        "osx": [os.path.join(forge_dir, ".circleci", "run_osx_build.sh")],
     }
 
     (
@@ -956,7 +951,7 @@ def _travis_specific_setup(jinja_env, forge_config, forge_dir, platform):
 
     platform_templates = {
         "linux": [".scripts/run_docker_build.sh", ".scripts/build_steps.sh"],
-        "osx": [".travis/run_osx_build.sh"],
+        "osx": [".scripts/run_osx_build.sh"],
         "win": [],
     }
     template_files = platform_templates.get(platform, [])
@@ -966,9 +961,6 @@ def _travis_specific_setup(jinja_env, forge_config, forge_dir, platform):
         if yum_build_setup:
             forge_config["yum_build_setup"] = yum_build_setup
 
-    if platform == "osx":
-        build_setup = build_setup.strip()
-        build_setup = build_setup.replace("\n", "\n      ")
     forge_config["build_setup"] = build_setup
 
     _render_template_exe_files(
@@ -994,6 +986,21 @@ def _render_template_exe_files(
             with open(target_fname, "r") as fh:
                 old_file_contents = fh.read()
                 if old_file_contents != new_file_contents:
+                    import difflib
+
+                    logger.debug(
+                        "diff:\n%s"
+                        % (
+                            "\n".join(
+                                difflib.unified_diff(
+                                    old_file_contents.splitlines(),
+                                    new_file_contents.splitlines(),
+                                    fromfile=target_fname,
+                                    tofile=target_fname,
+                                )
+                            )
+                        )
+                    )
                     raise RuntimeError(
                         "Same file {} is rendered twice with different contents".format(
                             target_fname
@@ -1017,14 +1024,6 @@ def render_travis(jinja_env, forge_config, forge_dir, return_metadata=False):
         upload_packages,
     ) = _get_platforms_of_provider("travis", forge_config)
 
-    extra_platform_files = {
-        "linux": [
-            os.path.join(forge_dir, ".scripts", "run_docker_build.sh"),
-            os.path.join(forge_dir, ".scripts", "build_steps.sh"),
-        ],
-        "osx": [os.path.join(forge_dir, ".scripts", "run_osx_build.sh")],
-    }
-
     return _render_ci_provider(
         "travis",
         jinja_env=jinja_env,
@@ -1038,7 +1037,6 @@ def render_travis(jinja_env, forge_config, forge_dir, return_metadata=False):
         keep_noarchs=keep_noarchs,
         platform_specific_setup=_travis_specific_setup,
         upload_packages=upload_packages,
-        extra_platform_files=extra_platform_files,
         return_metadata=return_metadata,
     )
 
@@ -1108,7 +1106,10 @@ def _azure_specific_setup(jinja_env, forge_config, forge_dir, platform):
             ".scripts/build_steps.sh",
             ".azure-pipelines/azure-pipelines-linux.yml",
         ],
-        "osx": [".azure-pipelines/azure-pipelines-osx.yml"],
+        "osx": [
+            ".azure-pipelines/azure-pipelines-osx.yml",
+            ".scripts/run_osx_build.sh",
+        ],
         "win": [".azure-pipelines/azure-pipelines-win.yml"],
     }
     template_files = platform_templates.get(platform, [])
@@ -1581,13 +1582,27 @@ def clear_variants(forge_dir):
 
 
 def get_common_scripts(forge_dir):
-    for old_file in ["run_docker_build.sh", "build_steps.sh"]:
+    for old_file in [
+        "run_docker_build.sh",
+        "build_steps.sh",
+        "run_osx_build.sh",
+    ]:
         yield os.path.join(forge_dir, ".scripts", old_file)
 
 
 def clear_scripts(forge_dir):
-    for folder in [".azure-pipelines", ".circleci", ".drone", ".travis"]:
-        for old_file in ["run_docker_build.sh", "build_steps.sh"]:
+    for folder in [
+        ".azure-pipelines",
+        ".circleci",
+        ".drone",
+        ".travis",
+        ".scripts",
+    ]:
+        for old_file in [
+            "run_docker_build.sh",
+            "build_steps.sh",
+            "run_osx_build.sh",
+        ]:
             remove_file(os.path.join(forge_dir, folder, old_file))
 
 


Test patch:
diff --git a/tests/test_configure_feedstock.py b/tests/test_configure_feedstock.py
--- a/tests/test_configure_feedstock.py
+++ b/tests/test_configure_feedstock.py
@@ -319,12 +319,13 @@ def test_circle_osx(py_recipe, jinja_env):
 
     forge_dir = py_recipe.recipe
     travis_yml_file = os.path.join(forge_dir, ".travis.yml")
-    circle_osx_file = os.path.join(forge_dir, ".circleci", "run_osx_build.sh")
+    circle_osx_file = os.path.join(forge_dir, ".scripts", "run_osx_build.sh")
     circle_linux_file = os.path.join(
         forge_dir, ".scripts", "run_docker_build.sh"
     )
     circle_config_file = os.path.join(forge_dir, ".circleci", "config.yml")
 
+    cnfgr_fdstk.clear_scripts(forge_dir)
     cnfgr_fdstk.render_circle(
         jinja_env=jinja_env, forge_config=py_recipe.config, forge_dir=forge_dir
     )
@@ -336,6 +337,7 @@ def test_circle_osx(py_recipe, jinja_env):
     )
     assert os.path.exists(travis_yml_file)
 
+    cnfgr_fdstk.clear_scripts(forge_dir)
     config = copy.deepcopy(py_recipe.config)
     config["provider"]["osx"] = "circle"
     cnfgr_fdstk.render_circle(
@@ -349,6 +351,7 @@ def test_circle_osx(py_recipe, jinja_env):
     )
     assert not os.path.exists(travis_yml_file)
 
+    cnfgr_fdstk.clear_scripts(forge_dir)
     config = copy.deepcopy(py_recipe.config)
     config["provider"]["linux"] = "dummy"
     config["provider"]["osx"] = "circle"
@@ -362,7 +365,7 @@ def test_circle_osx(py_recipe, jinja_env):
 
 def test_circle_skipped(linux_skipped_recipe, jinja_env):
     forge_dir = linux_skipped_recipe.recipe
-    circle_osx_file = os.path.join(forge_dir, ".circleci", "run_osx_build.sh")
+    circle_osx_file = os.path.join(forge_dir, ".scripts", "run_osx_build.sh")
     circle_linux_file = os.path.join(
         forge_dir, ".scripts", "run_docker_build.sh"
     )