Repository: conda/conda-build

Issue:
Issue with removing all site-packages files
Trying to build conda 4.4.0rc3 right now.  I'm finding that latest master somehow decides to not include in the final package anything in site-packages.

I've bisected the commit down to a744838fcc403d77f278b054ee98ea97861ec509, which is part of https://github.com/conda/conda-build/pull/2569

Continuing to investigate...


Discussion:
The conda recipe sets `always_include_files`.  That might have an interaction here.

https://github.com/conda/conda/blob/9e9fb2e/conda.recipe/meta.yaml#L14-L21
Yeah, currently, the *only* files being included are the `always_include_files`.

Resolving patch:
diff --git a/conda_build/build.py b/conda_build/build.py
--- a/conda_build/build.py
+++ b/conda_build/build.py
@@ -737,37 +737,42 @@ def bundle_conda(output, metadata, env, **kw):
             f.write('\n')
         output['script'] = script_fn
 
-    if not files or metadata.get_value('build/always_include_files'):
-        if output.get('script'):
-            with utils.path_prepended(metadata.config.build_prefix):
-                env = environ.get_dict(config=metadata.config, m=metadata)
-
-            interpreter = output.get('script_interpreter')
-            if not interpreter:
-                interpreter = guess_interpreter(output['script'])
-            initial_files = utils.prefix_files(metadata.config.host_prefix)
-            env_output = env.copy()
-            env_output['TOP_PKG_NAME'] = env['PKG_NAME']
-            env_output['TOP_PKG_VERSION'] = env['PKG_VERSION']
-            env_output['PKG_VERSION'] = metadata.version()
-            env_output['PKG_NAME'] = metadata.get_value('package/name')
-            for var in utils.ensure_list(metadata.get_value('build/script_env')):
-                if var not in os.environ:
-                    raise ValueError("env var '{}' specified in script_env, but is not set."
-                                     .format(var))
-                env_output[var] = os.environ[var]
-            utils.check_call_env(interpreter.split(' ') +
-                        [os.path.join(metadata.config.work_dir, output['script'])],
-                                cwd=metadata.config.work_dir, env=env_output)
-        else:
-            initial_files = utils.prefix_files(metadata.config.host_prefix)
-    else:
+    if output.get('script'):
+        with utils.path_prepended(metadata.config.build_prefix):
+            env = environ.get_dict(config=metadata.config, m=metadata)
+
+        interpreter = output.get('script_interpreter')
+        if not interpreter:
+            interpreter = guess_interpreter(output['script'])
+        initial_files = utils.prefix_files(metadata.config.host_prefix)
+        env_output = env.copy()
+        env_output['TOP_PKG_NAME'] = env['PKG_NAME']
+        env_output['TOP_PKG_VERSION'] = env['PKG_VERSION']
+        env_output['PKG_VERSION'] = metadata.version()
+        env_output['PKG_NAME'] = metadata.get_value('package/name')
+        for var in utils.ensure_list(metadata.get_value('build/script_env')):
+            if var not in os.environ:
+                raise ValueError("env var '{}' specified in script_env, but is not set."
+                                    .format(var))
+            env_output[var] = os.environ[var]
+        utils.check_call_env(interpreter.split(' ') +
+                    [os.path.join(metadata.config.work_dir, output['script'])],
+                            cwd=metadata.config.work_dir, env=env_output)
+    elif files:
+        # Files is specified by the output
         # we exclude the list of files that we want to keep, so post-process picks them up as "new"
         keep_files = set(utils.expand_globs(files, metadata.config.host_prefix))
         pfx_files = set(utils.prefix_files(metadata.config.host_prefix))
         initial_files = set(item for item in (pfx_files - keep_files)
                             if not any(keep_file.startswith(item + os.path.sep)
                                        for keep_file in keep_files))
+        initial_files = set(item for item in (pfx_files - keep_files)
+                            if not any(keep_file.startswith(item + os.path.sep)
+                                       for keep_file in keep_files))
+    else:
+        if not metadata.always_include_files():
+            log.warn("No files or script found for output {}".format(output.get('name')))
+        initial_files = set(utils.prefix_files(metadata.config.host_prefix))
 
     for pat in metadata.always_include_files():
         has_matches = False
diff --git a/conda_build/utils.py b/conda_build/utils.py
--- a/conda_build/utils.py
+++ b/conda_build/utils.py
@@ -765,7 +765,7 @@ def expand_globs(path_list, root_dir):
             glob_files = glob(path)
             if not glob_files:
                 log = get_logger(__name__)
-                log.error('invalid recipe path: {}'.format(path))
+                log.error('Glob {} did not match in root_dir {}'.format(path, root_dir))
             files.extend(glob_files)
     prefix_path_re = re.compile('^' + re.escape('%s%s' % (root_dir, os.path.sep)))
     files = [prefix_path_re.sub('', f, 1) for f in files]


Test patch:
diff --git a/tests/test-recipes/metadata/always_include_files_glob/meta.yaml b/tests/test-recipes/metadata/always_include_files_glob/meta.yaml
--- a/tests/test-recipes/metadata/always_include_files_glob/meta.yaml
+++ b/tests/test-recipes/metadata/always_include_files_glob/meta.yaml
@@ -10,6 +10,9 @@ build:
     - Library/lib/libpng*.lib # [win]
   ignore_run_exports:
     - libpng
+  script:
+    - echo "weee" > $PREFIX/top_level.txt
+    - echo "weee" > %PREFIX%\top_level.txt
 
 requirements:
     build:
diff --git a/tests/test-recipes/metadata/always_include_files_glob/run_test.py b/tests/test-recipes/metadata/always_include_files_glob/run_test.py
--- a/tests/test-recipes/metadata/always_include_files_glob/run_test.py
+++ b/tests/test-recipes/metadata/always_include_files_glob/run_test.py
@@ -14,17 +14,20 @@ def main():
     if sys.platform == 'darwin':
         assert set(info['files']) == {'lib/libpng.dylib',
                                       'lib/libpng16.16.dylib',
-                                      'lib/libpng16.dylib'}, info['files']
+                                      'lib/libpng16.dylib',
+                                      'top_level.txt'}, info['files']
     elif sys.platform.startswith('linux'):
         assert set(info['files']) == {'lib/libpng.so',
                                       'lib/libpng16.so',
                                       'lib/libpng16.so.16',
-                                      'lib/libpng16.so.16.17.0'}, info['files']
+                                      'lib/libpng16.so.16.17.0',
+                                      'top_level.txt'}, info['files']
     elif sys.platform == 'win32':
-        assert sorted(info['files']) == ['Library/lib/libpng.lib',
-                                         'Library/lib/libpng16.lib',
-                                         'Library/lib/libpng16_static.lib',
-                                         'Library/lib/libpng_static.lib']
+        assert set(info['files']) == {'Library/lib/libpng.lib',
+                                      'Library/lib/libpng16.lib',
+                                      'Library/lib/libpng16_static.lib',
+                                      'Library/lib/libpng_static.lib',
+                                      'top_level.txt'}
 
 if __name__ == '__main__':
     main()