Repository: conda/conda-build

Issue:
conda-build-3.0.0alpha1 contains bin/conda, breaks universe
I'm finally getting around to installing conda-build 3.0 from conda canary.  Unfortunately, it seems to contain 'bin/conda' for some reason and I'm unable to install it.  What's worse, if I try to install it without 'conda' also being installed in the same command, it will leave my conda install in a broken state (i.e. bin/conda will be missing from my root environment).

Here's what the install looks like:
```
spa105:~ % conda update -n root -c http://conda.anaconda.org/conda-canary conda-build 
[sudo] password for tsnyder:                                                              
Fetching package metadata .......                                                         
Solving package specifications: .                                                         

Package plan for installation in environment /my/conda/prefix:

The following packages will be UPDATED:

    conda:       4.3.14-py27_0 defaults --> 4.3.16-py27_0              http://conda.anaconda.org/conda-canary
    conda-build: 2.1.6-py27_0  defaults --> 3.0.0alpha1-py27h7def278_0 http://conda.anaconda.org/conda-canary

The following packages will be SUPERCEDED by a higher-priority channel:

    conda-env:   2.6.0-0       defaults --> 2.6.0-0                    http://conda.anaconda.org/conda-canary

Proceed ([y]/n)? y

conda-env-2.6. 100% |####################################################################################################################################| Time: 0:00:00  93.78 kB/s
conda-4.3.16-p 100% |####################################################################################################################################| Time: 0:00:00   1.81 MB/s
ERROR conda.core.link:_execute_actions(335): An error occurred while installing package 'http://conda.anaconda.org/conda-canary::conda-build-3.0.0alpha1-py27h7def278_0'.           
IOError(2, 'No such file or directory')                                                                                                                                             
Attempting to roll back.                                                                                                                                                            



IOError(2, 'No such file or directory')



```

The `IOError(2, 'No such file or directory')` are happening during the `conda-build` install because `conda` itself was deleted.

Looking in the `info/files` for `conda-build-3.0.0alpha1`, I see `bin/conda` but none of my earlier `conda-build` packages have `bin/conda` in their `info/files`

@msarahan ,  I'll also email you some more debug info that I don't want to post on github.

cc: @groutr 


Discussion:
Thanks, this is a regression in how the files to be packaged are being detected.  I'll add a regression test.

Resolving patch:
diff --git a/conda_build/build.py b/conda_build/build.py
--- a/conda_build/build.py
+++ b/conda_build/build.py
@@ -674,10 +674,15 @@ def bundle_conda(output, metadata, env, **kw):
         keep_files = set(utils.expand_globs(files, metadata.config.build_prefix))
         pfx_files = set(utils.prefix_files(metadata.config.build_prefix))
         initial_files = set(item for item in (pfx_files - keep_files)
-                            if not any(keep_file.startswith(item) for keep_file in keep_files))
+                            if not any(keep_file == item for keep_file in keep_files))
 
     files = post_process_files(metadata, initial_files)
 
+    if output.get('name') and output.get('name') != 'conda':
+        assert 'bin/conda' not in files and 'Scripts/conda.exe' not in files, ("Bug in conda-build "
+            "has included conda binary in package. Please report this on the conda-build issue "
+            "tracker.")
+
     output_filename = ('-'.join([output['name'], metadata.version(),
                                  metadata.build_id()]) + '.tar.bz2')
     # first filter is so that info_files does not pick up ignored files
diff --git a/conda_build/metadata.py b/conda_build/metadata.py
--- a/conda_build/metadata.py
+++ b/conda_build/metadata.py
@@ -1305,7 +1305,6 @@ def get_output_metadata_set(self, permit_undefined_jinja=False,
 
         # this is the old, default behavior: conda package, with difference between start
         #    set of files and end set of files
-
         prefix_file_list = join(om.config.build_folder, 'prefix_files.txt')
         if os.path.isfile(prefix_file_list):
             with open(prefix_file_list) as f:


Test patch: