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

Issue:
conda skeleton pypi assumes the source archive extension to be .tar.gz
A counter example to the assumption is: algopy . `conda skeleton pypi algopy` generates a recipe pointing to the source tarball ending with .tar.gz, whereas the source tarball ends in .zip


Discussion:

Resolving patch:
diff --git a/conda_build/skeletons/pypi.py b/conda_build/skeletons/pypi.py
--- a/conda_build/skeletons/pypi.py
+++ b/conda_build/skeletons/pypi.py
@@ -73,8 +73,11 @@
 # ready...list these in order of decreasing preference.
 POSSIBLE_DIGESTS = ['sha256', 'md5']
 
+POSSIBLE_FILE_EXTENSIONS = ['tar.gz', 'tar.bz2', 'zip', 'tar', 'gz']
+
 PYPI_META_HEADER = """{{% set name = "{packagename}" %}}
 {{% set version = "{version}" %}}
+{{% set file_ext = "{file_ext}" %}}
 {{% set hash_type = "{hash_type}" %}}
 {{% set hash_value = "{hash_value}" %}}
 
@@ -90,8 +93,8 @@
         ('version', '{{ version }}'),
     ]),
     'source': ruamel_yaml.comments.CommentedMap([
-        ('fn', '{{ name }}-{{ version }}.tar.gz'),
-        ('url', 'https://pypi.io/packages/source/{{ name[0] }}/{{ name }}/{{ name }}-{{ version }}.tar.gz'),  # NOQA
+        ('fn', '{{ name }}-{{ version }}.{{ file_ext }}'),
+        ('url', 'https://pypi.io/packages/source/{{ name[0] }}/{{ name }}/{{ name }}-{{ version }}.{{ file_ext }}'),  # NOQA
         ('{{ hash_type }}', '{{ hash_value }}'),
     ]),
     'build': ruamel_yaml.comments.CommentedMap([
@@ -718,6 +721,11 @@ def get_package_metadata(package, d, data, output_dir, python_version, all_extra
     if d['version'] == 'UNKNOWN':
         d['version'] = pkginfo['version']
 
+    for ext in POSSIBLE_FILE_EXTENSIONS:
+        if d['pypiurl'].split('#')[0].endswith(ext):
+            d['file_ext'] = ext
+            break
+
     if pkginfo.get('packages'):
         deps = set(pkginfo['packages'])
         if d['import_tests']:


Test patch:
Repository: conda/conda-build

Issue:
noarch: python packages strip data_files
in setup.py, `data_files` can be used to deliver support files, especially to `$PREFIX/share`. `noarch: python` [doesn't know how to handle these](https://github.com/conda/conda-build/blob/3.0.23/conda_build/noarch_python.py#L90) and ends up omitting them.

It seems like 'unknown' files in the prefix should be included as-is relative to $PREFIX (exactly as in a non-noarch package) rather than excluded.


Discussion:

Resolving patch:
diff --git a/conda_build/noarch_python.py b/conda_build/noarch_python.py
--- a/conda_build/noarch_python.py
+++ b/conda_build/noarch_python.py
@@ -85,10 +85,11 @@ def handle_file(f, d, prefix):
     # Include examples in the metadata doc
     elif f.startswith(('Examples/', 'Examples\\')):
         d['Examples'].append(f[9:])
+    # No special treatment for other files
+    # leave them as-is
     else:
         log = logging.getLogger(__name__)
-        log.warn("Don't know how to handle file: %s.  Omitting it from package." % f)
-        os.unlink(path)
+        log.debug("Don't know how to handle file: %s.  Including it as-is." % f)
 
 
 def populate_files(m, files, prefix, entry_point_scripts=None):


Test patch:
Repository: conda/conda-build

Issue:
[Feature request] conda convert doesn't work yet with non x86 platform (linux-armv7l, ...)
There are very few package in armv7l (architecture of Raspberry Pi 2&3, Odroid XU4, ... it would be a great to allow `conda convert` to create packages for [non_x86_linux_machines](https://github.com/conda/conda/blob/master/conda/config.py#L33). For pure Python packages it will work out of the box.



Discussion:

Resolving patch:
diff --git a/conda_build/cli/main_convert.py b/conda_build/cli/main_convert.py
--- a/conda_build/cli/main_convert.py
+++ b/conda_build/cli/main_convert.py
@@ -60,7 +60,9 @@ def parse_args(args):
         '-p', "--platform",
         dest='platforms',
         action="append",
-        choices=['osx-64', 'linux-32', 'linux-64', 'win-32', 'win-64', 'all'],
+        choices=['osx-64', 'linux-32', 'linux-64',
+                 'linux-ppc64le', 'linux-armv6l', 'linux-armv7l', 'linux-aarch64'
+                 'win-32', 'win-64', 'all'],
         help="Platform to convert the packages to.",
         default=None
     )
diff --git a/conda_build/convert.py b/conda_build/convert.py
--- a/conda_build/convert.py
+++ b/conda_build/convert.py
@@ -169,7 +169,14 @@ def update_index_file(temp_dir, target_platform, dependencies, verbose):
         index = json.load(file)
 
     platform, architecture = target_platform.split('-')
-    source_architecture = '64' if index['arch'] == 'x86_64' else '32'
+    other_platforms = ['linux-ppc64le', 'linux-armv6l', 'linux-armv7l', 'linux-aarch64']
+
+    if target_platform in other_platforms:
+        source_architecture = architecture
+    elif index.get('arch') == 'x86_64':
+        source_architecture = '64'
+    else:
+        source_architecture = '32'
 
     if verbose:
         print('Updating platform from {} to {}' .format(index['platform'], platform))
@@ -178,7 +185,13 @@ def update_index_file(temp_dir, target_platform, dependencies, verbose):
 
     index['platform'] = platform
     index['subdir'] = target_platform
-    index['arch'] = 'x86_64' if architecture == '64' else 'x86'
+
+    if architecture == '64':
+        index['arch'] = 'x86_64'
+    elif architecture == '32':
+        index['arch'] = 'x86'
+    else:
+        index['arch'] = architecture
 
     if dependencies:
         index['depends'] = update_dependencies(dependencies, index['depends'])
@@ -705,7 +718,9 @@ def conda_convert(file_path, output_dir=".", show_imports=False, platforms=None,
     source_platform_architecture = '{}-{}' .format(source_platform, architecture)
 
     if 'all' in platforms:
-        platforms = ['osx-64', 'linux-32', 'linux-64', 'win-32', 'win-64']
+        platforms = ['osx-64', 'linux-32', 'linux-64',
+                     'linux-ppc64le', 'linux-armv6l', 'linux-armv7l', 'linux-aarch64'
+                     'win-32', 'win-64']
 
     for platform in platforms:
 


Test patch:
Repository: conda/conda-build

Issue:
building with `--python=2.` and `--python=2.7` ought to yield the same package name...
...but doesn't, despite both having the same content.


Discussion:

Resolving patch:
diff --git a/conda_build/metadata.py b/conda_build/metadata.py
--- a/conda_build/metadata.py
+++ b/conda_build/metadata.py
@@ -464,6 +464,14 @@ def check_bad_chrs(s, field):
             sys.exit("Error: bad character '%s' in %s: %s" % (c, field, s))
 
 
+def get_package_version_pin(build_reqs, name):
+    version = ""
+    for spec in build_reqs:
+        if spec.split()[0] == name and len(spec.split()) > 1:
+            version = spec.split()[1]
+    return version
+
+
 def build_string_from_metadata(metadata):
     if metadata.meta.get('build', {}).get('string'):
         build_str = metadata.get_value('build/string')
@@ -471,6 +479,7 @@ def build_string_from_metadata(metadata):
         res = []
         build_or_host = 'host' if metadata.is_cross else 'build'
         build_pkg_names = [ms.name for ms in metadata.ms_depends(build_or_host)]
+        build_deps = metadata.meta.get('requirements', {}).get(build_or_host, [])
         # TODO: this is the bit that puts in strings like py27np111 in the filename.  It would be
         #    nice to get rid of this, since the hash supercedes that functionally, but not clear
         #    whether anyone's tools depend on this file naming right now.
@@ -490,8 +499,9 @@ def build_string_from_metadata(metadata):
                             pkg_names.extend([_n.replace('-', '_')
                                               for _n in ensure_list(names) if '-' in _n])
                             for _n in pkg_names:
-                                _n = _n.replace('-', '_')
-                                variant_version = metadata.config.variant.get(_n, "")
+                                variant_version = (get_package_version_pin(build_deps, _n) or
+                                                   metadata.config.variant.get(_n.replace('-', '_'),
+                                                                               ''))
                                 if variant_version:
                                     break
                             res.append(''.join([s] + variant_version.split('.')[:places]))


Test patch:
Repository: conda/conda-build

Issue:
icon file in app section causes packaging problem
Recipes which include an icon file in the `app` section fail to build with conda build 3.1.0 but work with earlier versions.  

A minimal example:

```yaml
package:
  name: foobar
  version: 1.0.0

app:
  entry: foobar
  icon: icon.png
  summary: Foobar Application
  type: desk
```

```
$ conda build -V
$ conda build .
Attempting to finalize metadata for foobar
INFO:conda_build.metadata:Attempting to finalize metadata for foobar
BUILD START: ['foobar-1.0.0-0.tar.bz2']
source tree in: /home/jhelmus/anaconda3/conda-bld/foobar_1512581374458/work
Packaging foobar
INFO:conda_build.build:Packaging foobar
Packaging foobar-1.0.0-0
INFO:conda_build.build:Packaging foobar-1.0.0-0
number of files: 0
Fixing permissions
Fixing permissions
'info/icon.png' not in info/files
Traceback (most recent call last):
  File "/home/jhelmus/anaconda3/bin/conda-build", line 11, in <module>
    sys.exit(main())
  File "/home/jhelmus/anaconda3/lib/python3.6/site-packages/conda_build/cli/main_build.py", line 388, in main
    execute(sys.argv[1:])
  File "/home/jhelmus/anaconda3/lib/python3.6/site-packages/conda_build/cli/main_build.py", line 379, in execute
    verify=args.verify)
  File "/home/jhelmus/anaconda3/lib/python3.6/site-packages/conda_build/api.py", line 187, in build
    need_source_download=need_source_download, config=config, variants=variants)
  File "/home/jhelmus/anaconda3/lib/python3.6/site-packages/conda_build/build.py", line 1833, in build_tree
    notest=notest,
  File "/home/jhelmus/anaconda3/lib/python3.6/site-packages/conda_build/build.py", line 1285, in build
    built_package = bundlers[output_d.get('type', 'conda')](output_d, m, env)
  File "/home/jhelmus/anaconda3/lib/python3.6/site-packages/conda_build/build.py", line 796, in bundle_conda
    tarcheck.check_all(tmp_path, metadata.config)
  File "/home/jhelmus/anaconda3/lib/python3.6/site-packages/conda_build/tarcheck.py", line 89, in check_all
    x.info_files()
  File "/home/jhelmus/anaconda3/lib/python3.6/site-packages/conda_build/tarcheck.py", line 53, in info_files
    raise Exception('info/files')
Exception: info/files
```



Discussion:

Resolving patch:
diff --git a/conda_build/utils.py b/conda_build/utils.py
--- a/conda_build/utils.py
+++ b/conda_build/utils.py
@@ -1022,6 +1022,7 @@ def filter_info_files(files_list, prefix):
                     'info[\\\\/]platform',
                     'info[\\\\/]no_link',
                     'info[\\\\/]link.json',
+                    'info[\\\\/]icon.png',
             ))
 
 


Test patch:
Repository: conda/conda-build

Issue:
Jinja2 is a direct dependency for CB
https://github.com/conda/conda-build/blob/3.1.2/conda_build/index.py#L21

Although it is present in conda.recipe, shouldn't this also be specified in `install_requires` in setup.py? I was trying to (in the base env):
```
pip install https://github.com/conda/conda-build/archive/master.zip
```
But it didn't pull in jinja2, which is not part of the Miniconda installers.


Discussion:
sure, please file a PR

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -42,7 +42,7 @@
                             'conda-skeleton = conda_build.cli.main_skeleton:main',
                             ]},
     install_requires=['conda', 'requests', 'filelock', 'pyyaml', 'conda-verify',
-                      'pkginfo', 'glob2', 'beautifulsoup4'],
+                      'jinja2', 'pkginfo', 'glob2', 'beautifulsoup4'],
     package_data={'conda_build': ['templates/*', 'cli-*.exe']},
     zip_safe=False,
 )


Test patch:
Repository: conda/conda-build

Issue:
empty preprocessed conda_build_config.yaml gives error
### Actual Behavior

```
Traceback (most recent call last):
  File "/home/isuru/miniconda3/bin/conda-build", line 11, in <module>
    sys.exit(main())
  File "/home/isuru/miniconda3/lib/python3.6/site-packages/conda_build/cli/main_build.py", line 415, in main
    execute(sys.argv[1:])
  File "/home/isuru/miniconda3/lib/python3.6/site-packages/conda_build/cli/main_build.py", line 406, in execute
    verify=args.verify)
  File "/home/isuru/miniconda3/lib/python3.6/site-packages/conda_build/api.py", line 199, in build
    notest=notest, need_source_download=need_source_download, variants=variants)
  File "/home/isuru/miniconda3/lib/python3.6/site-packages/conda_build/build.py", line 2004, in build_tree
    bypass_env_check=True)
  File "/home/isuru/miniconda3/lib/python3.6/site-packages/conda_build/render.py", line 658, in render_recipe
    variants = get_package_variants(m, variants=variants)
  File "/home/isuru/miniconda3/lib/python3.6/site-packages/conda_build/variants.py", line 473, in get_package_variants
    specs[f] = parse_config_file(f, config)
  File "/home/isuru/miniconda3/lib/python3.6/site-packages/conda_build/variants.py", line 116, in parse_config_file
    trim_empty_keys(content)
  File "/home/isuru/miniconda3/lib/python3.6/site-packages/conda_build/utils.py", line 1110, in trim_empty_keys
    for k, v in dict_.items():
AttributeError: 'NoneType' object has no attribute 'items'
```

### Expected Behavior
no error

### Steps to Reproduce
```yaml
asd: # [osx]
  - 1  # [osx]
```
Use above file as a variant config file

##### `Output of conda info`
<!-- Between the ticks below, paste the output of 'conda info' -->
```
               platform : linux-64
          conda version : 4.3.34
       conda is private : False
      conda-env version : 4.3.34
    conda-build version : 3.5.1
         python version : 3.6.4.final.0
       requests version : 2.14.2
```




Discussion:

Resolving patch:
diff --git a/conda_build/variants.py b/conda_build/variants.py
--- a/conda_build/variants.py
+++ b/conda_build/variants.py
@@ -114,7 +114,7 @@ def parse_config_file(path, config):
     with open(path) as f:
         contents = f.read()
     contents = select_lines(contents, ns_cfg(config), variants_in_place=False)
-    content = yaml.load(contents, Loader=yaml.loader.BaseLoader)
+    content = yaml.load(contents, Loader=yaml.loader.BaseLoader) or {}
     trim_empty_keys(content)
     return content
 


Test patch:
Repository: conda/conda-build

Issue:
'conda index' is broken when info/recipe/meta.yaml contains non-rendered jinja2
Apparently, some older packages can contain non-rendered jinja2 in info/recipe/meta.yaml.


Discussion:

Resolving patch:
diff --git a/conda_build/index.py b/conda_build/index.py
--- a/conda_build/index.py
+++ b/conda_build/index.py
@@ -311,6 +311,9 @@ def _read_index_tar(tar_path, lock, locking=True, timeout=90):
                 recipe_json = yaml.load(recipe_text)
             except KeyError:
                 recipe_json = {}
+            except Exception as e:
+                log.debug("'info/recipe/meta.yaml' could not be read for '%s': %r", tar_path, e)
+                recipe_json = {}
 
             # If a conda package contains an icon, also extract and cache that in an .icon/
             # directory.  The icon file name is the name of the package, plus the extension


Test patch:
Repository: conda/conda-build

Issue:
Empty requirements/run throws traceback in py3
Recipe:
```
package:
  name: test
  version: 1.0.0

requirements:
  run:
    - enum34  # [py<35] 
```

Error:
```
# conda build . --python 3.6
Adding in variants from internal_defaults
INFO:conda_build.variants:Adding in variants from internal_defaults
Attempting to finalize metadata for test
INFO:conda_build.metadata:Attempting to finalize metadata for test
BUILD START: ['test-1.0.0-0.tar.bz2']
Traceback (most recent call last):
  File "/opt/conda/bin/conda-build", line 11, in <module>
    sys.exit(main())
  File "/opt/conda/lib/python3.6/site-packages/conda_build/cli/main_build.py", line 420, in main
    execute(sys.argv[1:])
  File "/opt/conda/lib/python3.6/site-packages/conda_build/cli/main_build.py", line 411, in execute
    verify=args.verify)
  File "/opt/conda/lib/python3.6/site-packages/conda_build/api.py", line 200, in build
    notest=notest, need_source_download=need_source_download, variants=variants)
  File "/opt/conda/lib/python3.6/site-packages/conda_build/build.py", line 2168, in build_tree
    notest=notest,
  File "/opt/conda/lib/python3.6/site-packages/conda_build/build.py", line 1303, in build
    m.get_value('requirements/run', [])
TypeError: can only concatenate list (not "NoneType") to list
```

Doesn't happen with CB 3.10.3


Discussion:

Resolving patch:
diff --git a/conda_build/build.py b/conda_build/build.py
--- a/conda_build/build.py
+++ b/conda_build/build.py
@@ -1299,8 +1299,8 @@ def build(m, stats, post=None, need_source_download=True, need_reparse_in_env=Fa
             if not notest:
                 utils.insert_variant_versions(m.meta.get('requirements', {}),
                                               m.config.variant, 'run')
-                test_run_ms_deps = m.get_value('test/requires', []) + \
-                                   m.get_value('requirements/run', [])
+                test_run_ms_deps = utils.ensure_list(m.get_value('test/requires', [])) + \
+                                   utils.ensure_list(m.get_value('requirements/run', []))
                 # make sure test deps are available before taking time to create build env
                 environ.get_install_actions(m.config.test_prefix,
                                             tuple(test_run_ms_deps), 'test',


Test patch:
diff --git a/tests/test-recipes/metadata/empty_run_section/meta.yaml b/tests/test-recipes/metadata/empty_run_section/meta.yaml
new file mode 100644
--- /dev/null
+++ b/tests/test-recipes/metadata/empty_run_section/meta.yaml
@@ -0,0 +1,12 @@
+package:
+  name: test_empty_run_deps
+  version: 1.0
+
+requirements:
+  run:
+
+
+test:
+  requires:
+  commands:
+    - echo 'test'
Repository: conda/conda-build

Issue:
load_file_regex() in jinja_context.py does not close the file
### Actual Behavior

ResourceWarning: File is not closed when using load_file_regex()

### Expected Behavior

Close the file when it is out of scope.
I opened PR#2915 but need to clear internal red-tape. The patch is trivial, so including here:
```
diff --git a/conda_build/jinja_context.py b/conda_build/jinja_context.py
index 1b45883a..e2125be0 100644
--- a/conda_build/jinja_context.py
+++ b/conda_build/jinja_context.py
@@ -184,7 +184,8 @@ def load_file_regex(config, load_file, regex_pattern, from_recipe_dir=False,
             raise RuntimeError(message)

     if os.path.isfile(load_file):
-        match = re.search(regex_pattern, open(load_file, 'r').read())
+        with open(load_file, 'r') as lfile:
+            match = re.search(regex_pattern, lfile.read())
     else:
         if not permit_undefined_jinja:
             raise TypeError('{} is not a file that can be read'.format(load_file))
```

### Steps to Reproduce

Use load_file_regex() in a jinja template


##### `Output of conda info`
<!-- Between the ticks below, paste the output of 'conda info' -->
```

```




Discussion:

Resolving patch:
diff --git a/conda_build/jinja_context.py b/conda_build/jinja_context.py
--- a/conda_build/jinja_context.py
+++ b/conda_build/jinja_context.py
@@ -184,7 +184,8 @@ def load_file_regex(config, load_file, regex_pattern, from_recipe_dir=False,
             raise RuntimeError(message)
 
     if os.path.isfile(load_file):
-        match = re.search(regex_pattern, open(load_file, 'r').read())
+        with open(load_file, 'r') as lfile:
+            match = re.search(regex_pattern, lfile.read())
     else:
         if not permit_undefined_jinja:
             raise TypeError('{} is not a file that can be read'.format(load_file))


Test patch:
Repository: conda/conda-build

Issue:
conda-smithy doesn't understand missing_dso_whitelist
<!--
Thanks for opening an issue! A few things to keep in mind:

- This issue tracker is for issues with or enhancements for conda-build.

For conda issues, you should open an issue at https://github.com/conda/conda/issues
For Anaconda issues, you should open an issue at https://github.com/ContinuumIO/anaconda-issues/issues
For an issue with a particular conda-forge package, you should open an issue on the 
corresponding feedstock: https://github.com/conda-forge
-->

### Actual Behavior
conda-smithy marks recipe as bad due to linting failure.

```
(base) [root@18192a96432c krb5-feedstock]# conda-smithy recipe-lint recipe/
recipe/ has some lint:
   The build section contained an unexpected subsection name. missing_dso_whitelist is not a valid subsection name.
```

### Expected Behavior
conda-smithy should be happy with missing_dso_whitelist in the build section.

### Steps to Reproduce
Send a PR to conda-forge with missing_dso_whitelist in the build section. ;-)

Reporting it here because conda-smithy relies on conda-build internals to figure out valid fields.


Discussion:

Resolving patch:
diff --git a/conda_build/metadata.py b/conda_build/metadata.py
--- a/conda_build/metadata.py
+++ b/conda_build/metadata.py
@@ -489,7 +489,7 @@ def _str_version(package_meta):
               'preferred_env', 'preferred_env_executable_paths', 'run_exports',
               'ignore_run_exports', 'requires_features', 'provides_features',
               'force_use_keys', 'force_ignore_keys', 'merge_build_host',
-              'pre-link', 'post-link', 'pre-unlink',
+              'pre-link', 'post-link', 'pre-unlink', 'missing_dso_whitelist',
               },
     'requirements': {'build', 'host', 'run', 'conflicts', 'run_constrained'},
     'app': {'entry', 'icon', 'summary', 'type', 'cli_opts',


Test patch:
Repository: conda/conda-build

Issue:
build/no_link is not honored when it has a pattern
I tried building the conda-forge nginx package. Recipe: https://github.com/conda-forge/nginx-feedstock

Package: https://anaconda.org/nwani/nginx/1.14.0/download/linux-64/nginx-1.14.0-h1c2f66e_0.tar.bz2

In the recipe, `build/no_link` has `/etc/*` and conda build does create a file with the contents in `info/no_link` inside the package, however conda gives more priority to `info/paths.json` and in this file, conda build doesn't put `no_links: true` for the files in `etc/*` and this causes trouble, since conda thinks that this file has to be hard linked and not copied.


Discussion:

Resolving patch:
diff --git a/conda_build/build.py b/conda_build/build.py
--- a/conda_build/build.py
+++ b/conda_build/build.py
@@ -702,7 +702,8 @@ def has_prefix(short_path, files_with_prefix):
 
 
 def is_no_link(no_link, short_path):
-    if no_link is not None and short_path in no_link:
+    no_link = utils.ensure_list(no_link)
+    if any(fnmatch.fnmatch(short_path, p) for p in no_link):
         return True
 
 


Test patch: