internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: conda-forge/conda-smithy

Issue:
Improve lint messages on whitespace
The message about the spacing for selectors isn't clear to see the problem in the number of spaces:

`Selectors are suggested to take a " # []" form.`

It would be clearer to have a message like: `<two spaces> # <one space> [selector]`



Discussion:
I agree. I've tried to get some way of rendering it in github appropriately to no avail:

`"  # []"`

form doesn't do what is expected, though it looks like

```
  # []
```

does. Trying various attempts:

`# []`

`&nbsp;&nbsp;#&nbsp;[]`

"&nbsp;&nbsp;#&nbsp;[]"

No matter what, having (`<two spaces>#<one space>[<expression>]`) also helps.

If you are interested in doing it @dopplershift, the line is https://github.com/conda-forge/conda-smithy/blob/master/conda_smithy/lint_recipe.py#L75.


Resolving patch:
diff --git a/conda_smithy/lint_recipe.py b/conda_smithy/lint_recipe.py
--- a/conda_smithy/lint_recipe.py
+++ b/conda_smithy/lint_recipe.py
@@ -85,7 +85,7 @@ def lintify(meta, recipe_dir=None):
                     bad_selectors.append(selector_line)
         if bad_selectors:
             lints.append('Selectors are suggested to take a '
-                         '"  # [<selector>]" form.')
+                         '``<two spaces>#<one space>[<expression>]`` form.')
 
     # 7: The build section should have a build number.
     if build_section.get('number', None) is None:


Test patch:
diff --git a/conda_smithy/tests/test_lint_recipe.py b/conda_smithy/tests/test_lint_recipe.py
--- a/conda_smithy/tests/test_lint_recipe.py
+++ b/conda_smithy/tests/test_lint_recipe.py
@@ -111,7 +111,7 @@ def test_test_section_with_recipe(self):
 
     def test_selectors(self):
         expected_message = ('Selectors are suggested to take a '
-                            '"  # [<selector>]" form.')
+                            '``<two spaces>#<one space>[<expression>]`` form.')
 
         with tmp_directory() as recipe_dir:
             def assert_selector(selector, is_good=True):
Repository: conda-forge/conda-smithy

Issue:
Linter: handle environ
Same issue as https://github.com/conda-forge/conda-forge.github.io/issues/93.
Same fix needed: https://github.com/conda-forge/conda-forge.github.io/pull/107/files

Linter: handle environ
Same issue as https://github.com/conda-forge/conda-forge.github.io/issues/93.
Same fix needed: https://github.com/conda-forge/conda-forge.github.io/pull/107/files



Discussion:
Needed at https://github.com/conda-forge/conda-smithy/blob/master/conda_smithy/lint_recipe.py#L14

Needed at https://github.com/conda-forge/conda-smithy/blob/master/conda_smithy/lint_recipe.py#L14


Resolving patch:
diff --git a/conda_smithy/lint_recipe.py b/conda_smithy/lint_recipe.py
--- a/conda_smithy/lint_recipe.py
+++ b/conda_smithy/lint_recipe.py
@@ -15,6 +15,11 @@ class NullUndefined(jinja2.Undefined):
     def __unicode__(self):
         return unicode(self._undefined_name)
 
+    def __getattr__(self, name):
+        return unicode('{}.{}'.format(self, name))
+
+    def __getitem__(self, name):
+        return '{}["{}"]'.format(self, name)
 
 def get_section(parent, name, lints):
     section = parent.get(name, {})


Test patch:
diff --git a/conda_smithy/tests/test_lint_recipe.py b/conda_smithy/tests/test_lint_recipe.py
--- a/conda_smithy/tests/test_lint_recipe.py
+++ b/conda_smithy/tests/test_lint_recipe.py
@@ -222,6 +222,32 @@ def test_cli_success(self):
             out, _ = child.communicate()
             self.assertEqual(child.returncode, 0, out)
 
+    def test_cli_environ(self):
+        with tmp_directory() as recipe_dir:
+            with open(os.path.join(recipe_dir, 'meta.yaml'), 'w') as fh:
+                fh.write(textwrap.dedent("""
+                    package:
+                        name: 'test_package'
+                    build:
+                        number: 0
+                    test:
+                        requires:
+                            - python {{ environ['PY_VER'] + '*' }}  # [win]
+                    about:
+                        home: something
+                        license: something else
+                        summary: a test recipe
+                    extra:
+                        recipe-maintainers:
+                            - a
+                            - b
+                    """))
+            child = subprocess.Popen(['conda-smithy', 'recipe-lint',
+                                      recipe_dir],
+                                     stdout=subprocess.PIPE)
+            out, _ = child.communicate()
+            self.assertEqual(child.returncode, 0, out)
+
 
 if __name__ == '__main__':
     unittest.main()
Repository: conda-forge/conda-smithy

Issue:
Don't use Exception.message if you want to work on py3k
Found in https://github.com/conda-forge/staged-recipes/issues/720. Currently exists in 2 places at https://github.com/conda-forge/conda-smithy/blob/6c1856a51832b5a014bb9126467804d75d712029/conda_smithy/cli.py.



Discussion:

Resolving patch:
diff --git a/conda_smithy/cli.py b/conda_smithy/cli.py
--- a/conda_smithy/cli.py
+++ b/conda_smithy/cli.py
@@ -107,7 +107,7 @@ def __call__(self, args):
             print("\nRepository created, please edit conda-forge.yml to configure the upload channels\n"
                   "and afterwards call 'conda smithy register-github'")
         except RuntimeError as e:
-            print(e.message)
+            print(e)
 
 
 class RegisterGithub(Subcommand):
@@ -132,7 +132,7 @@ def __call__(self, args):
             github.create_github_repo(args)
             print("\nRepository registered at github, now call 'conda smithy register-ci'")
         except RuntimeError as e:
-            print(e.message)
+            print(e)
 
 
 class RegisterCI(Subcommand):
@@ -168,7 +168,7 @@ def __call__(self, args):
             print("\nCI services have been enabled enabled. You may wish to regnerate the feedstock.\n"
                   "Any changes will need commiting to the repo.")
         except RuntimeError as e:
-            print(e.message)
+            print(e)
 
 class Regenerate(Subcommand):
     subcommand = 'regenerate'
@@ -185,7 +185,7 @@ def __call__(self, args):
             configure_feedstock.main(args.feedstock_directory)
             print("\nCI support files regenerated. These need to be pushed to github!")
         except RuntimeError as e:
-            print(e.message)
+            print(e)
 
 
 class RecipeLint(Subcommand):


Test patch:
Repository: conda-forge/conda-smithy

Issue:
Don't run as root
Some recipes have been doing things to the system that normal conda users don't necessarily have the permissions to do (e.g. modifying `/var/` or `/etc/`) - if we ran as a non-root user in the docker container, we would be able to protect against these kinds of recipes automatically.



Discussion:
👍

Though this feels like a change that should happen to the Docker container directly. That being said, there will be fallout for `conda-smithy` and `staged-recipes` (looking at you `yum_requirements.txt`).

Honestly, I think we are better doing this as part of the feedstock, rather than as part of the Dockerfile (yum requirements is a good example).

xref: https://github.com/conda-forge/staged-recipes/issues/1475

Yeah I still think this should be in the Docker image. We just really shouldn't be handing people a Docker image that runs as `root` if possible.

I also think this should be in the docker image. I understand that there are some commands on the feedstocks that need to run as superuser (like yum). What about giving `sudo` permission only for these commands? 

This way it will be possible to install from `yum_requirements.txt` but not modifying `/var`, `/etc`


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
@@ -159,7 +159,7 @@ def render_circle(jinja_env, forge_config, forge_dir):
                 # "recipe/yum_requirements.txt" file. After updating that file,
                 # run "conda smithy rerender" and this line be updated
                 # automatically.
-                yum install -y {}
+                /usr/bin/sudo -n yum install -y {}
 
 
             """.format(' '.join(requirements)))


Test patch:
Repository: conda-forge/conda-smithy

Issue:
linter false positive with selectors
https://github.com/conda-forge/staged-recipes/pull/3992 got a `Selectors are suggested to take a <two spaces>#<one space>[<expression>] form.` error, when the only selector actually is spaced properly.

Looking at it a bit, `selector_lines` thinks that the following two lines have selectors:
```
    - inotifywatch --help > /dev/null || [[ $? == 1 ]]
    - inotifywait --help > /dev/null || [[ $? == 1 ]]
```
I guess that conda-build would actually identify this line as a selector, but the linter message is pretty confusing. Should we print line numbers or something?


Discussion:
Oh, actually `conda_build.metadata` has a new pattern for selectors (https://github.com/conda/conda-build/commit/7de6a07d4e3f95318938e92d962e456201ff77a6) that excludes brackets inside the selector brackets. Will send a PR updating this in the linter.

Resolving patch:
diff --git a/conda_smithy/lint_recipe.py b/conda_smithy/lint_recipe.py
--- a/conda_smithy/lint_recipe.py
+++ b/conda_smithy/lint_recipe.py
@@ -210,7 +210,7 @@ def run_conda_forge_lints(meta, recipe_dir, lints):
 def selector_lines(lines):
     # Using the same pattern defined in conda-build (metadata.py),
     # we identify selectors.
-    sel_pat = re.compile(r'(.+?)\s*(#.*)?\[(.+)\](?(2).*)$')
+    sel_pat = re.compile(r'(.+?)\s*(#.*)?\[([^\[\]]+)\](?(2).*)$')
 
     for line in lines:
         line = line.rstrip()


Test patch:
Repository: conda-forge/conda-smithy

Issue:
conda-forge.yml matrix ignored on rerender?
I'm trying to test rerendering with conda-smithy master and it's failing in a few cases. The first example I tried was https://github.com/conda-forge/mpi-feedstock which is an empty metapackage with two MPI_VARIANT matrix entries in conda-forge.yml. When I rerendered, I got only a single `config_.yml` without the MPI_VARIANTs.

Is this a bug in rerender or is there an extra step I'm missing to migrate conda-forge.yml matrix entries to conda_build_config.yml?


Discussion:
Add a `recipe/conda_build_config.yaml` file with 
```
mpi_impl:
  - mpich
  - openmpi
```

and you can use `mpi_impl` as a jinja variable in the meta.yaml.

conda-forge.yml's matrix is removed now. (We should warn that it is removed though)
Did this go in the wiki too?
Yes, see https://github.com/conda-forge/conda-smithy/wiki/Release-Notes-3.0.0.rc1
Great, thanks.
Perfect, thanks. Manual step is AOK; a message about what I needed to do on rerender would be great (just a link to that wiki page would have been enough for me).
Thanks @minrk. Appreciate your help testing.

Think we will move the wiki content to the docs once we get closer.

We can certainly add a warning (maybe even error?) when the old cba matrix feature appears.
An error like "Can't rerender until you migrate conda-forge.yml matrix to conda_build_config.yml" sounds like a good idea to me, since the rerender result will always be wrong and need to be redone anyway.
Can you send a PR? You can check for `matrix` in https://github.com/conda-forge/conda-smithy/blob/master/conda_smithy/configure_feedstock.py#L588
Sure, I'll give it a go.

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
@@ -583,6 +583,19 @@ def _load_forge_config(forge_dir, exclusive_config_file):
     else:
         with open(forge_yml, "r") as fh:
             file_config = list(yaml.load_all(fh))[0] or {}
+
+        # check for conda-smithy 2.x matrix which we can't auto-migrate
+        # to conda_build_config
+        if file_config.get('matrix') and not os.path.exists(
+            os.path.join(forge_dir, 'recipe', 'conda_build_config.yaml')
+        ):
+            # FIXME: update docs URL
+            raise ValueError(
+                'Cannot rerender with matrix in conda-forge.yml.'
+                ' Please migrate matrix to conda_build_config.yaml and try again.'
+                ' See https://github.com/conda-forge/conda-smithy/wiki/Release-Notes-3.0.0.rc1'
+                ' for more info.')
+
         # The config is just the union of the defaults, and the overriden
         # values.
         for key, value in file_config.items():


Test patch:
Repository: conda-forge/conda-smithy

Issue:
If host comes before build, incorrect error
As in the title, if the host section comes before the build section, the following nonsensical error is generated:

```
The requirements/build section should be defined before the requirements/run section.
```

Note that the order is: host, build, run.


Discussion:

Resolving patch:
diff --git a/conda_smithy/lint_recipe.py b/conda_smithy/lint_recipe.py
--- a/conda_smithy/lint_recipe.py
+++ b/conda_smithy/lint_recipe.py
@@ -164,8 +164,9 @@ def lintify(meta, recipe_dir=None, conda_forge=False):
     requirements_order_sorted = sorted(seen_requirements,
                                        key=REQUIREMENTS_ORDER.index)
     if seen_requirements != requirements_order_sorted:
-        lints.append('The `requirements/build` section should be defined '
-                     'before the `requirements/run` section.')
+        lints.append('The `requirements/` sections should be defined '
+                     'in the following order: ' + ', '.join(REQUIREMENTS_ORDER)
+                     + '; instead saw: ' + ', '.join(seen_requirements) + '.')
 
     # 9: Files downloaded should have a hash.
     if ('url' in source_section and


Test patch:
diff --git a/tests/test_lint_recipe.py b/tests/test_lint_recipe.py
--- a/tests/test_lint_recipe.py
+++ b/tests/test_lint_recipe.py
@@ -301,8 +301,9 @@ def test_missing_build_number(self):
         self.assertIn(expected_message, lints)
 
     def test_bad_requirements_order(self):
-        expected_message = ("The `requirements/build` section should be "
-                            "defined before the `requirements/run` section.")
+        expected_message = ('The `requirements/` sections should be defined in '
+                            'the following order: build, host, run; '
+                            'instead saw: run, build.')
 
         meta = {'requirements': OrderedDict([['run', 'a'],
                                              ['build', 'a']])}
Repository: conda-forge/conda-smithy

Issue:
BUG: "Recipe maintainers should be a json list"
Seeing the linter complaining about [the recipe maintainers not being a list]( https://github.com/conda-forge/gperftools-feedstock/pull/2#issuecomment-413905960 ). However not only they are a list and they have not changed in that PR, but the linter did not raise the issue earlier in the PR.

Edit: Seems to be [consistent]( https://github.com/conda-forge/gperftools-feedstock/pull/2#issuecomment-413914010 ) though.

cc @xmnlab


Discussion:
Also seeing this for [the scikit-bio feedstock](https://github.com/conda-forge/scikit-bio-feedstock/pull/8#issuecomment-413946216).
I think this error maybe from a change in `ruamel.yaml`?
the yaml is giving back `CommentedSeq` rather than list.

Resolving patch:
diff --git a/conda_smithy/lint_recipe.py b/conda_smithy/lint_recipe.py
--- a/conda_smithy/lint_recipe.py
+++ b/conda_smithy/lint_recipe.py
@@ -132,7 +132,9 @@ def lintify(meta, recipe_dir=None, conda_forge=False):
                      'the `extra/recipe-maintainers` section.')
 
     # 3b: Maintainers should be a list
-    if not isinstance(extra_section.get('recipe-maintainers', []), list):
+    if not (isinstance(extra_section.get('recipe-maintainers', []), Sequence)
+            and not isinstance(extra_section.get('recipe-maintainers', []),
+                               str_type)):
         lints.append('Recipe maintainers should be a json list.')
 
     # 4: The recipe should have some tests.


Test patch:
Repository: conda-forge/conda-smithy

Issue:
Azure pipelines Linux builds don't work if windows is enabled.
See https://github.com/conda-forge/conda-build-feedstock/pull/78/files#diff-6da60ca62019167cbfa11e3ab1106599R30


Discussion:

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
@@ -784,6 +784,8 @@ def _azure_specific_setup(jinja_env, forge_config, forge_dir, platform):
     }
     template_files = platform_templates.get(platform, [])
 
+    forge_config['build_setup'] = 'run_conda_forge_build_setup'
+
     forge_config['docker']['interactive'] = False
     _render_template_exe_files(forge_config=forge_config,
                                target_dir=os.path.join(forge_dir, '.azure-pipelines'),


Test patch:
Repository: conda-forge/conda-smithy

Issue:
Increase timeout for commands with no output on CircleCI and Travis
This increases the timeout for commands with no output from the default (10 minutes) to 30 minutes on CircleCI and Travis, during the build phase. I've started to see some packages where conda is so slow at solving/downloading dependencies that the build times out.

I'm not sure how this is tested, but hopefully the CI will already warn if something is seriously broken.

Fixes https://github.com/conda-forge/conda-smithy/issues/940


Discussion:

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
@@ -860,7 +860,7 @@ def _load_forge_config(forge_dir, exclusive_config_file):
                          'image': 'condaforge/linux-anvil',
                          'command': 'bash',
                          'interactive': True,
-                         },
+                         },               
               'templates': {},
               'travis': {},
               'circle': {},
@@ -876,6 +876,9 @@ def _load_forge_config(forge_dir, exclusive_config_file):
               'win': {'enabled': False},
               'osx': {'enabled': False},
               'linux': {'enabled': False},
+              # Configurable idle timeout.  Used for packages that don't have chatty enough builds
+              # Applicable only to circleci and travis
+              'idle_timeout_minutes': None,
               # Compiler stack environment variable
               'compiler_stack': 'comp4',
               # Stack variables,  These can be used to impose global defaults for how far we build out


Test patch:
Repository: conda-forge/conda-smithy

Issue:
Fix linter error on missing target_platform
Invoking `conda smithy recipe-lint` on the [conda-forge/go1.4-feedstock/meta.yaml](
https://github.com/conda-forge/go1.4-bootstrap-feedstock/blob/master/recipe/meta.yaml) file yields the following exception:

```
± conda smithy recipe-lint
Traceback (most recent call last):
  File "/opt/conda/bin/conda-smithy", line 10, in <module>
    sys.exit(main())
  File "/opt/conda/lib/python3.6/site-packages/conda_smithy/cli.py", line 279, in main
    args.subcommand_func(args)
  File "/opt/conda/lib/python3.6/site-packages/conda_smithy/cli.py", line 203, in __call__
    return_hints=True)
  File "/opt/conda/lib/python3.6/site-packages/conda_smithy/lint_recipe.py", line 428, in main
    content = render_meta_yaml(''.join(fh))
  File "/opt/conda/lib/python3.6/site-packages/conda_smithy/utils.py", line 49, in render_meta_yaml
    content = env.from_string(text).render(os=mockos, environ=mockos.environ)
  File "/opt/conda/lib/python3.6/site-packages/jinja2/asyncsupport.py", line 76, in render
    return original_render(self, *args, **kwargs)
  File "/opt/conda/lib/python3.6/site-packages/jinja2/environment.py", line 1008, in render
    return self.environment.handle_exception(exc_info, True)
  File "/opt/conda/lib/python3.6/site-packages/jinja2/environment.py", line 780, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/opt/conda/lib/python3.6/site-packages/jinja2/_compat.py", line 37, in reraise
    raise value.with_traceback(tb)
  File "<template>", line 29, in top-level template code
jinja2.exceptions.UndefinedError: 'target_platform' is undefined
```


Discussion:

Resolving patch:
diff --git a/conda_smithy/utils.py b/conda_smithy/utils.py
--- a/conda_smithy/utils.py
+++ b/conda_smithy/utils.py
@@ -44,6 +44,7 @@ def render_meta_yaml(text):
                                     defaultdict(lambda : ''),
                             datetime=datetime,
                             time=time,
+                            target_platform="linux-64",
                             ))
     mockos = MockOS()
     content = env.from_string(text).render(os=mockos, environ=mockos.environ)


Test patch:
diff --git a/tests/test_lint_recipe.py b/tests/test_lint_recipe.py
--- a/tests/test_lint_recipe.py
+++ b/tests/test_lint_recipe.py
@@ -302,6 +302,19 @@ def test_jinja_load_file_regex(self):
                         """)
             lints = linter.main(recipe_dir)
 
+    def test_target_platform(self):
+        # Test that we can use target_platform in a recipe. We don't care about
+        # the results here.
+        with tmp_directory() as recipe_dir:
+            with io.open(os.path.join(recipe_dir, 'meta.yaml'), 'w') as fh:
+                fh.write("""
+                        package:
+                           name: foo_{{ target_platform }}
+                           version: 1.0
+                         """)
+            lints = linter.main(recipe_dir)
+
+
     def test_missing_build_number(self):
         expected_message = "The recipe must have a `build/number` section."
Repository: conda-forge/conda-smithy

Issue:
Linter should not suggest noarch when scripts present in setup.py
Ref https://github.com/conda-forge/conda-smithy/pull/1021 - suggest relying on the migrator bot to do the noarch suggestion instead of the linter, since the bot PR's list all prerequisites. Unless the linter checks all of them it's going to repeatedly suggest doing something that shouldn't be done on a number of packages.


Discussion:
FYI, the migrator bot is not currently running noarch migrations.
Was that temporary? The code for it must still exist?
The code still exists, but it was mostly a drive to get things over before the compiler/python/r migration. My hope is that we catch most of the noarch-able packages before they get through staged-recipes. We also ended up having the bot issue some bad PRs and so decided to turn it off.
Does the linter know the difference between staged-recipes vs feedstocks when it decides what message to post?
Yes, https://github.com/conda-forge/conda-smithy/blob/master/conda_smithy/lint_recipe.py#L448

Resolving patch:
diff --git a/conda_smithy/lint_recipe.py b/conda_smithy/lint_recipe.py
--- a/conda_smithy/lint_recipe.py
+++ b/conda_smithy/lint_recipe.py
@@ -134,6 +134,9 @@ def lintify(meta, recipe_dir=None, conda_forge=False):
     package_section = get_section(meta, "package", lints)
     outputs_section = get_section(meta, "outputs", lints)
 
+    recipe_dirname = os.path.basename(recipe_dir) if recipe_dir else "recipe"
+    is_staged_recipes = recipe_dirname != "recipe"
+    
     # 0: Top level keys should be expected
     unexpected_sections = []
     for section in major_sections:
@@ -405,9 +408,9 @@ def lintify(meta, recipe_dir=None, conda_forge=False):
                     "See https://conda-forge.org/docs/meta.html#use-pip"
                 )
 
-    # 2: suggest python noarch
+    # 2: suggest python noarch (skip on feedstocks)
     if build_section.get("noarch") is None and build_reqs and not any(["_compiler_stub" in b for b in build_reqs]) \
-            and ("pip" in build_reqs):
+            and ("pip" in build_reqs) and (is_staged_recipes or not conda_forge):
         with io.open(meta_fname, "rt") as fh:
             in_runreqs = False
             no_arch_possible = True


Test patch: