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

Issue:
"conda build --python x.y" does not work as advertised
Using the `CONDA_PY` environment variable works as expected. If it is set to `34`, conda builds a Python 3.4 package using Visual Studio 2010. 

However, `conda build --python 3.4` does not produce the same result. Conda picks Visual Studio 2008, because `config.PY3` is incorrectly set to 0 and `msvc_env_cmd()` relies on this constant to determine the correct version of VS: 

  https://github.com/conda/conda-build/blob/master/conda_build/windows.py#L64



Discussion:

Resolving patch:
diff --git a/conda_build/config.py b/conda_build/config.py
--- a/conda_build/config.py
+++ b/conda_build/config.py
@@ -24,7 +24,9 @@ class Config(object):
     CONDA_NPY = int(os.getenv('CONDA_NPY', '0').replace('.', '')) or None
     CONDA_R = os.getenv("CONDA_R", "3.2.1")
 
-    PY3K = int(bool(CONDA_PY >= 30))
+    @property
+    def PY3K(self):
+        return int(bool(self.CONDA_PY >= 30))
 
     noarch = False
 


Test patch:
Repository: conda/conda-build

Issue:
Trouble building `conda-build` from included recipe
Ran the following.

```
$ conda build conda_build.recipe
```

Long log included in gist. Shortened traceback below.

```
  File "/zopt/conda/envs/_test/lib/python2.7/site-packages/conda_build/config.py", line 24, in Config
    CONDA_NPY = int(os.getenv('CONDA_NPY', '0').replace('.', '')) or None
ValueError: invalid literal for int() with base 10: 'None'
TESTS FAILED: conda-build-1.17.0+7.g7954a9d-py27_15_gb92750e
```

See more details here ( https://gist.github.com/jakirkham/c7719e85ad4540d9b032 )



Discussion:
Can you show me the meta.yaml?

I applied this diff to this commit b92750ea52232a2c64a4b658c8eac2e3df0dafb4. However, if I remove it, I get the same issue. I have added the unpatched log to the gist.

```
$ git diff
diff --git a/conda_build.recipe/meta.yaml b/conda_build.recipe/meta.yaml
index c445e54..aa21be0 100644
--- a/conda_build.recipe/meta.yaml
+++ b/conda_build.recipe/meta.yaml
@@ -1,6 +1,6 @@
 package:
   name: conda-build
-  version: 1.10alpha.0
+  version: 1.17.0+7.g7954a9d

 source:
   git_url: ../
```

Oh it's the included recipe for conda build. I didn't catch that. 


Resolving patch:
diff --git a/conda_build/build.py b/conda_build/build.py
--- a/conda_build/build.py
+++ b/conda_build/build.py
@@ -554,7 +554,7 @@ def test(m, verbose=True, channel_urls=(), override_channels=False):
     if sys.platform == 'win32':
         env['PATH'] = config.test_prefix + os.pathsep + env['PATH']
     for varname in 'CONDA_PY', 'CONDA_NPY', 'CONDA_PERL':
-        env[varname] = str(getattr(config, varname))
+        env[varname] = str(getattr(config, varname) or '')
     env['PREFIX'] = config.test_prefix
 
     # Python 2 Windows requires that envs variables be string, not unicode
diff --git a/conda_build/config.py b/conda_build/config.py
--- a/conda_build/config.py
+++ b/conda_build/config.py
@@ -21,7 +21,11 @@ class Config(object):
     CONDA_PERL = os.getenv('CONDA_PERL', '5.18.2')
     CONDA_PY = int(os.getenv('CONDA_PY', cc.default_python.replace('.',
         '')).replace('.', ''))
-    CONDA_NPY = int(os.getenv('CONDA_NPY', '0').replace('.', '')) or None
+    CONDA_NPY = os.getenv("CONDA_NPY")
+    if not CONDA_NPY:
+        CONDA_NPY = None
+    else:
+        CONDA_NPY = int(CONDA_NPY.replace('.', '')) or None
     CONDA_R = os.getenv("CONDA_R", "3.2.1")
 
     @property
diff --git a/conda_build/environ.py b/conda_build/environ.py
--- a/conda_build/environ.py
+++ b/conda_build/environ.py
@@ -20,7 +20,7 @@ def get_py_ver():
     return '.'.join(str(config.CONDA_PY))
 
 def get_npy_ver():
-    return '.'.join(str(config.CONDA_NPY))
+    return '.'.join(str(config.CONDA_NPY or ''))
 
 def get_stdlib_dir():
     return join(config.build_prefix, 'Lib' if sys.platform == 'win32' else


Test patch:
Repository: conda/conda-build

Issue:
AppVeyor: AttributeError: 'module' object has no attribute 'get_pid_list
https://ci.appveyor.com/project/mpi4py/mpi4py/build/2.0.0a0-17/job/965h1pw9k7476768#L1187

conda info:
https://ci.appveyor.com/project/mpi4py/mpi4py/build/2.0.0a0-17/job/965h1pw9k7476768#L1076

Please note a few lines above I ran:
`C:\Anaconda\Scripts\conda.exe install --yes --quiet anaconda-client conda-build jinja2`



Discussion:
OK, I found the problem. Looking at the `meta.yaml` file https://github.com/conda/conda-build/blob/master/conda_build.recipe/meta.yaml, it seems you are missing a `- psutil [win]` line in the `requirements/run:` section.

Oh, sorry, I got it totally wrong. Now I see `conda-build` uses `psutil` optionally. However, it is attempting to invoke `psutil.get_pid_list()`. That method is not available in recent versions of `psutils`, I guess you have to use `psutil.pids()`, or perhaps better refactor the code and just use `psutil.process_iter()` http://pythonhosted.org/psutil/#processes

hey @dalcinl I am having the same issue with a normal `conda build` on the following package https://github.com/m-labs/migen/tree/master/conda/migen
Did you find any workaround so that I can build my package without waiting conda-build to be fixed?

@fallen At this point I don't remember what I did. After a lot of refactoring of my conda builds in AppVeyor, the problem disappeared . Perhaps you could workaround by forcing an install of the old version of `psutil`.

all right, fixed with conda install psutil=2.2.1
Thanks!

While installing the older version of psutil solved the problem for me too, it would be nice if the call to get_pid_list got fixed.

:+1: 

Quick fix is to replace psutil.get_pid_list() call in pscheck.py with psutil.pids(). Works ok for me.


Resolving patch:
diff --git a/conda_build/windows.py b/conda_build/windows.py
--- a/conda_build/windows.py
+++ b/conda_build/windows.py
@@ -89,7 +89,7 @@ def msvc_env_cmd():
 def kill_processes():
     if psutil is None:
         return
-    for n in psutil.get_pid_list():
+    for n in psutil.pids():
         try:
             p = psutil.Process(n)
             if p.name.lower() == 'msbuild.exe':


Test patch:
Repository: conda/conda-build

Issue:
Entry point pattern doesn't match entrypoints:with.dots
Hi,

Could you please have a look to this. I define entry point as

``` python
entry_points={
    'console_scripts': [
        'poultry = poultry.main:dispatcher.dispatch',
    ],
},
```

https://github.com/dimazest/poultry/blob/e0f39277f0a219a4d3cd461b69ce5dd4422fc9dd/setup.py#L62

which entry point pattern at  https://github.com/conda/conda-build/blob/master/conda_build/scripts.py#L27 doesn't match.

Thanks.



Discussion:
That should generate

``` py
from poultry.main import dispatcher
sys.exit(dispatcher.dispatch())
```

right?

yes, tough buildout does this (it might be easier to implement):

``` python
import poultry.main

sys.exit(poultry.main.dispatcher.dispatch())
```

Conda build does not support `console_scripts` vs `gui_scripts` as far as I can see it (unfortunately). `entry_points` in `meta.yml` should be a simple list.

For gui_scripts, the only option is to set [osx_is_app](http://conda.pydata.org/docs/building/meta-yaml.html#python-app), which makes all entry points "gui_scripts" on OS X. 


Resolving patch:
diff --git a/conda_build/scripts.py b/conda_build/scripts.py
--- a/conda_build/scripts.py
+++ b/conda_build/scripts.py
@@ -18,14 +18,14 @@
 PY_TMPL = """\
 if __name__ == '__main__':
     import sys
-    from %s import %s
+    import %(module)s
 
-    sys.exit(%s())
+    sys.exit(%(module)s.%(func)s())
 """
 
 bin_dirname = 'Scripts' if sys.platform == 'win32' else 'bin'
 
-entry_pat = re.compile('\s*([\w\-\.]+)\s*=\s*([\w.]+):(\w+)\s*$')
+entry_pat = re.compile('\s*([\w\-\.]+)\s*=\s*([\w.]+):([\w.]+)\s*$')
 
 
 def iter_entry_points(items):
@@ -37,7 +37,7 @@ def iter_entry_points(items):
 
 
 def create_entry_point(path, module, func):
-    pyscript = PY_TMPL % (module, func, func)
+    pyscript = PY_TMPL % {'module': module, 'func': func}
     if sys.platform == 'win32':
         with open(path + '-script.py', 'w') as fo:
             fo.write(pyscript)


Test patch:
Repository: conda/conda-build

Issue:
"--perl" option mis-parses multi-digit versions
The `--perl` option for `conda build` separates each digit in a version string with a ".", instead of keeping multi-digit numbers together:

``` bash
$ conda build --perl 5.22.0 perl-try-tiny
Removing old build environment
Removing old work directory
BUILD START: perl-try-tiny-0.22-pl5.2.2.0_1
# "conda build" now attempts to find and/or build a Perl 5.2.2.0 package,
# instead of using an existing Perl 5.22.0 package.
```

This is a major problem as the recent releases of Perl 5 all have double-digit minor numbers. Note that setting the `CONDA_PERL` environment variable works around this problem:

``` bash
$ CONDA_PERL="5.22.0" conda build perl-try-tiny
Removing old build environment
Removing old work directory
BUILD START: perl-try-tiny-0.22-pl5.22.0_1
```

```
$ conda info
Current conda install:

             platform : linux-64
        conda version : 3.18.6
  conda-build version : 1.18.2
```

This problem has also been observed with version 1.18.0 of conda-build.



Discussion:

Resolving patch:
diff --git a/conda_build/main_build.py b/conda_build/main_build.py
--- a/conda_build/main_build.py
+++ b/conda_build/main_build.py
@@ -299,7 +299,9 @@ def execute(args, parser):
                 setattr(args, lang, versions)
             return
         else:
-            version = int(versions[0].replace('.', ''))
+            version = versions[0]
+            if lang in ('python', 'numpy'):
+                version = int(version.replace('.', ''))
             setattr(config, conda_version[lang], version)
         if not len(str(version)) in (2, 3) and lang in ['python', 'numpy']:
             if all_versions[lang]:


Test patch:
Repository: conda/conda-build

Issue:
Error in help message for --numpy
See below: `11.0` is listed as a known version while it should be `1.10`.

```
  --numpy NUMPY_VER     Set the NumPy version used by conda build. Can be
                        passed multiple times to build against multiple
                        versions. Can be 'all' to build against all known
                        versions (['1.6', '1.7', '1.8', '1.9', '11.0'])
```



Discussion:
Looks like the offending line is https://github.com/conda/conda-build/blob/master/conda_build/main_build.py#L174, which is doing https://github.com/conda/conda-build/blob/master/conda_build/main_build.py#L53.

Related ( https://github.com/conda/conda-build/issues/631 ).


Resolving patch:
diff --git a/conda_build/main_build.py b/conda_build/main_build.py
--- a/conda_build/main_build.py
+++ b/conda_build/main_build.py
@@ -51,7 +51,8 @@ def _get_items(self):
 
 class NumPyVersionCompleter(Completer):
     def _get_items(self):
-        return ['all'] + [str(i/10) for i in all_versions['numpy']]
+        versions = [str(i) for i in all_versions['numpy']]
+        return ['all'] + ['%s.%s' % (ver[0], ver[1:]) for ver in versions]
 
 class RVersionsCompleter(Completer):
     def _get_items(self):


Test patch:
Repository: conda/conda-build

Issue:
When building noarch package, the conda-bld/linux-64 dir is not initialized
I get this when I build a noarch package in a clean root conda env (e.g. when building Bokeh's conda package on Travis):

```
almar@almar-ubuntu64:~/py/bokeh$ conda build conda.recipe
Removing old build environment
Removing old work directory
BUILD START: bokeh-nightly-py_1
Using Anaconda Cloud api site https://api.anaconda.org
Fetching package metadata: ...........Error: Could not find URL: file:///home/almar/anaconda34/conda-bld/linux-64/
```

Manually creating the `linux-64` dir is not enough, the `repodata.json` and `repodata.json.bz2` need to be there too.



Discussion:
Quick fix is to use `--skip-existing`. I'm looking into a proper fix as well.


Resolving patch:
diff --git a/conda_build/build.py b/conda_build/build.py
--- a/conda_build/build.py
+++ b/conda_build/build.py
@@ -294,9 +294,10 @@ def create_env(prefix, specs, clear_cache=True):
     '''
     Create a conda envrionment for the given prefix and specs.
     '''
-    if not isdir(config.bldpkgs_dir):
-        os.makedirs(config.bldpkgs_dir)
-    update_index(config.bldpkgs_dir)
+    for d in config.bldpkgs_dirs:
+        if not isdir(d):
+            os.makedirs(d)
+        update_index(d)
     if specs: # Don't waste time if there is nothing to do
         index = get_build_index(clear_cache=True)
 
diff --git a/conda_build/config.py b/conda_build/config.py
--- a/conda_build/config.py
+++ b/conda_build/config.py
@@ -114,11 +114,17 @@ def broken_dir(self):
 
     @property
     def bldpkgs_dir(self):
+        """ Dir where the package is saved. """
         if self.noarch:
             return join(self.croot, "noarch")
         else:
             return join(self.croot, cc.subdir)
 
+    @property
+    def bldpkgs_dirs(self):
+        """ Dirs where previous build packages might be. """
+        return join(self.croot, cc.subdir), join(self.croot, "noarch")
+
 config = Config()
 
 croot = config.croot
diff --git a/conda_build/main_build.py b/conda_build/main_build.py
--- a/conda_build/main_build.py
+++ b/conda_build/main_build.py
@@ -332,9 +332,10 @@ def execute(args, parser):
             os_environ[var] = str(getattr(config, var))
 
     if args.skip_existing:
-        if not isdir(config.bldpkgs_dir):
-            makedirs(config.bldpkgs_dir)
-        update_index(config.bldpkgs_dir)
+        for d in config.bldpkgs_dirs:
+            if not isdir(d):
+                makedirs(d)
+            update_index(d)
         index = build.get_build_index(clear_cache=True)
 
     already_built = []


Test patch:
Repository: conda/conda-build

Issue:
conda-build 1.19.1 breaks C compilation
I am using conda build on [this recipe](https://github.com/mmp2/megaman/tree/master/conda_recipes/pyamg)

It works on 1.19.0, but on 1.19.1 fails with this message:

```
creating build/temp.macosx-10.5-x86_64-3.5
creating build/temp.macosx-10.5-x86_64-3.5/pyamg
creating build/temp.macosx-10.5-x86_64-3.5/pyamg/amg_core
compile options: '-D__STDC_FORMAT_MACROS=1 -I/Users/jakevdp/anaconda/envs/_build/lib/python3.5/site-packages/numpy/core/include -I/Users/jakevdp/anaconda/envs/_build/include/python3.5m -c'
g++: pyamg/amg_core/amg_core_wrap.cxx
g++ -bundle -undefined dynamic_lookup -L/Users/jakevdp/anaconda/envs/_build/lib -rpath /Users/jakevdp/anaconda/envs/_build/lib -rpath /Users/jakevdp/anaconda/envs/_build/lib -arch x86_64 build/temp.macosx-10.5-x86_64-3.5/pyamg/amg_core/amg_core_wrap.o -L/Users/jakevdp/anaconda/envs/_build/lib -o build/lib.macosx-10.5-x86_64-3.5/pyamg/amg_core/_amg_core.cpython-35m-darwin.so
g++: error: unrecognized command line option ‘-rpath’
g++: error: unrecognized command line option ‘-rpath’
g++: error: unrecognized command line option â-rpathâ
g++: error: unrecognized command line option â-rpathâ
error: Command "g++ -bundle -undefined dynamic_lookup -L/Users/jakevdp/anaconda/envs/_build/lib -rpath /Users/jakevdp/anaconda/envs/_build/lib -rpath /Users/jakevdp/anaconda/envs/_build/lib -arch x86_64 build/temp.macosx-10.5-x86_64-3.5/pyamg/amg_core/amg_core_wrap.o -L/Users/jakevdp/anaconda/envs/_build/lib -o build/lib.macosx-10.5-x86_64-3.5/pyamg/amg_core/_amg_core.cpython-35m-darwin.so" failed with exit status 1
Command failed: /bin/bash -x -e /Users/jakevdp/Opensource/megaman/conda_recipes/pyamg/build.sh
```



Discussion:
Looks like #808 is the relevant changeset.

If you could change your copy of `conda_build/environ.py`, line 212 from this:

``` python
        rpath = ' -rpath %(PREFIX)s/lib' % d # SIP workaround, DYLD_* no longer works.
```

to this:

``` python
        rpath = ' -Wl,-rpath,%(PREFIX)s/lib' % d # SIP workaround, DYLD_* no longer works.
```

and report back, that would be useful.

Everything works fine with that patch.


Resolving patch:
diff --git a/conda_build/environ.py b/conda_build/environ.py
--- a/conda_build/environ.py
+++ b/conda_build/environ.py
@@ -209,7 +209,7 @@ def get_dict(m=None, prefix=None):
         d['OSX_ARCH'] = 'i386' if cc.bits == 32 else 'x86_64'
         d['CFLAGS'] = cflags + ' -arch %(OSX_ARCH)s' % d
         d['CXXFLAGS'] = cxxflags + ' -arch %(OSX_ARCH)s' % d
-        rpath = ' -rpath %(PREFIX)s/lib' % d # SIP workaround, DYLD_* no longer works.
+        rpath = ' -Wl,-rpath,%(PREFIX)s/lib' % d # SIP workaround, DYLD_* no longer works.
         d['LDFLAGS'] = ldflags + rpath + ' -arch %(OSX_ARCH)s' % d
         d['MACOSX_DEPLOYMENT_TARGET'] = '10.6'
 


Test patch:
Repository: conda/conda-build

Issue:
error separating build from test
I'm running `conda build` once with '--no-test', then again with '-t' to split the build from the test step when building my project.
This works fine with Anaconda 4, but results in an error ("Error:  Package missing in current linux-64 channels: ...") when using miniconda.



Discussion:
It turns out the difference isn't between Anaconda and miniconda, it's between conda-build versions <= 1.18 or above. The bug is present with 1.19 and 1.20, but goes away if I downgrade conda-build to 1.18.


Resolving patch:
diff --git a/conda_build/build.py b/conda_build/build.py
--- a/conda_build/build.py
+++ b/conda_build/build.py
@@ -446,11 +446,6 @@ def build(m, get_src=True, post=None, include_recipe=True, keep_old_work=False):
             finally:
                 os.environ['PATH'] = _old_path
 
-        # Parse our metadata again because we did not initialize the source
-        # information before.
-        # By now, all jinja variables should be defined, so don't permit undefined vars.
-        m.parse_again(permit_undefined_jinja=False)
-
         print("Package:", m.dist())
 
         assert isdir(source.WORK_DIR)
diff --git a/conda_build/main_build.py b/conda_build/main_build.py
--- a/conda_build/main_build.py
+++ b/conda_build/main_build.py
@@ -20,11 +20,11 @@
 from conda.install import delete_trash
 from conda.resolve import NoPackagesFound, Unsatisfiable
 
-from conda_build import exceptions
 from conda_build.index import update_index
 from conda_build.main_render import get_render_parser
 from conda_build.utils import find_recipe
-from conda_build.main_render import get_package_build_string, set_language_env_vars, RecipeCompleter
+from conda_build.main_render import (get_package_build_string, set_language_env_vars,
+                                     RecipeCompleter, render_recipe)
 on_win = (sys.platform == 'win32')
 
 
@@ -194,7 +194,6 @@ def execute(args, parser):
     import conda_build.build as build
     import conda_build.source as source
     from conda_build.config import config
-    from conda_build.metadata import MetaData
 
     check_external()
 
@@ -255,14 +254,10 @@ def execute(args, parser):
             if not isdir(recipe_dir):
                 sys.exit("Error: no such directory: %s" % recipe_dir)
 
-            try:
-                m = MetaData(recipe_dir)
-                if m.get_value('build/noarch_python'):
-                    config.noarch = True
-            except exceptions.YamlParsingError as e:
-                sys.stderr.write(e.error_msg())
-                sys.exit(1)
-            binstar_upload = False
+            # this fully renders any jinja templating, throwing an error if any data is missing
+            m = render_recipe(recipe_dir, no_download_source=False)
+            if m.get_value('build/noarch_python'):
+                config.noarch = True
             if args.check and len(args.recipe) > 1:
                 print(m.path)
             m.check_fields()


Test patch:
Repository: conda/conda-build

Issue:
conda-build no longer prints upload instructions
At the end of `conda build`, the user typically sees a helpful message explaining how to upload the package, like this:

```
# If you want to upload this package to anaconda.org later, type:
#
# $ anaconda upload /miniconda/conda-bld/osx-64/my-package-1.0-0.tar.bz2
#
# To have conda build upload to anaconda.org automatically, use
# $ conda config --set anaconda_upload yes
```

It looks like that was accidentally removed via b83d9c87b895c7c83d881195e4eeb05f4ecb706f.

(At the moment, this affects the master branch, but not the release yet.)

Counter-intuitively, it looks like the old code expected `handle_binstar_upload()` to always get called, regardless of what the user passed in on the command-line. Now that it only gets called conditionally, the friendly message doesn't get printed.

Ping: @msarahan



Discussion:
Thanks, I'll put that back in.  I didn't like that it was always true.  There must be a better way to express this logic.


Resolving patch:
diff --git a/conda_build/main_build.py b/conda_build/main_build.py
--- a/conda_build/main_build.py
+++ b/conda_build/main_build.py
@@ -338,8 +338,8 @@ def execute(args, parser):
         if need_cleanup:
             shutil.rmtree(recipe_dir)
 
-        if args.binstar_upload:
-            handle_binstar_upload(build.bldpkg_path(m), args)
+        # outputs message, or does upload, depending on value of args.binstar_upload
+        handle_binstar_upload(build.bldpkg_path(m), args)
 
         already_built.add(m.pkg_fn())
 


Test patch:
Repository: conda/conda-build

Issue:
__conda_???__.txt files for post-build assignment of metadata need deprecation
I don't see a reason for these that Jinja templates do not fulfill in better ways.

If anyone can point out use cases for post-build version/build string, I'm happy to consider them.

Otherwise, I'm marking these as deprecated, and will remove them in 2.0.



Discussion:

Resolving patch:
diff --git a/conda_build/post.py b/conda_build/post.py
--- a/conda_build/post.py
+++ b/conda_build/post.py
@@ -376,17 +376,26 @@ def check_symlinks(files):
 def get_build_metadata(m):
     src_dir = source.get_dir()
     if exists(join(src_dir, '__conda_version__.txt')):
+        print("Deprecation warning: support for __conda_version__ will be removed in Conda build 2.0."
+              "Try Jinja templates instead: "
+              "http://conda.pydata.org/docs/building/environment-vars.html#git-environment-variables")
         with open(join(src_dir, '__conda_version__.txt')) as f:
             version = f.read().strip()
             print("Setting version from __conda_version__.txt: %s" % version)
             m.meta['package']['version'] = version
     if exists(join(src_dir, '__conda_buildnum__.txt')):
+        print("Deprecation warning: support for __conda_buildnum__ will be removed in Conda build 2.0."
+              "Try Jinja templates instead: "
+              "http://conda.pydata.org/docs/building/environment-vars.html#git-environment-variables")
         with open(join(src_dir, '__conda_buildnum__.txt')) as f:
             build_number = f.read().strip()
             print("Setting build number from __conda_buildnum__.txt: %s" %
                   build_number)
             m.meta['build']['number'] = build_number
     if exists(join(src_dir, '__conda_buildstr__.txt')):
+        print("Deprecation warning: support for __conda_buildstr__ will be removed in Conda build 2.0."
+              "Try Jinja templates instead: "
+              "http://conda.pydata.org/docs/building/environment-vars.html#git-environment-variables")
         with open(join(src_dir, '__conda_buildstr__.txt')) as f:
             buildstr = f.read().strip()
             print("Setting version from __conda_buildstr__.txt: %s" % buildstr)


Test patch: