Repository: conda/conda-build

Issue:
Symbolic link folders don't work anymore
A symbolic link to a folder worked fine in conda-build 2.1.4, but it's not in conda-build 2.1.5 on osx (linux works fine).

conda-build 2.1.5 log
https://travis-ci.org/conda-forge/gap-feedstock/builds/204615074

conda-build 2.1.4 log
https://travis-ci.org/conda-forge/gap-feedstock/builds/200925407


Discussion:
Thanks for reporting.  I'm writing a test and will fix asap.

Resolving patch:
diff --git a/conda_build/build.py b/conda_build/build.py
--- a/conda_build/build.py
+++ b/conda_build/build.py
@@ -87,6 +87,7 @@ def prefix_files(prefix):
             path = join(root, dn)
             if islink(path):
                 res.add(path[len(prefix) + 1:])
+    res = set(utils.expand_globs(res, prefix))
     return res
 
 
@@ -874,8 +875,9 @@ def bundle_conda(output, metadata, config, env, **kw):
                     cwd=config.build_prefix, env=env)
     else:
         # we exclude the list of files that we want to keep, so post-process picks them up as "new"
-        files = list(set(utils.expand_globs(files, config.build_prefix)))
-        initial_files = set(prefix_files(config.build_prefix)) - set(files)
+        keep_files = set(utils.expand_globs(files, config.build_prefix))
+        pfx_files = set(prefix_files(config.build_prefix))
+        initial_files = pfx_files - keep_files
 
     files = post_process_files(metadata, initial_files)
 
diff --git a/conda_build/post.py b/conda_build/post.py
--- a/conda_build/post.py
+++ b/conda_build/post.py
@@ -5,6 +5,7 @@
 from glob import glob
 import io
 import locale
+import logging
 import mmap
 import re
 import os
@@ -414,7 +415,11 @@ def fix_permissions(files, prefix):
         # ensure user and group can write and all can read
         new_mode = new_mode | stat.S_IWUSR | stat.S_IWGRP | stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH  # noqa
         if old_mode != new_mode:
-            lchmod(path, new_mode)
+            try:
+                lchmod(path, new_mode)
+            except (OSError, utils.PermissionError) as e:
+                log = logging.getLogger(__name__)
+                log.warn(str(e))
 
 
 def post_build(m, files, prefix, build_python, croot):
diff --git a/conda_build/utils.py b/conda_build/utils.py
--- a/conda_build/utils.py
+++ b/conda_build/utils.py
@@ -36,6 +36,7 @@
     import urllib.request as urllib
     # NOQA because it is not used in this file.
     from contextlib import ExitStack  # NOQA
+    PermissionError = PermissionError
 else:
     import urlparse
     import urllib


Test patch:
diff --git a/tests/test-recipes/metadata/symlinks/build.sh b/tests/test-recipes/metadata/symlinks/build.sh
new file mode 100644
--- /dev/null
+++ b/tests/test-recipes/metadata/symlinks/build.sh
@@ -0,0 +1,8 @@
+mkdir -p $PREFIX/test
+echo "echo weee" > $PREFIX/test/weee
+chmod +x $PREFIX/test/weee
+
+mkdir -p $PREFIX/bin
+ln -s $PREFIX/test/weee $PREFIX/bin/weee
+
+ln -s $PREFIX/test $PREFIX/test_link
diff --git a/tests/test-recipes/metadata/symlinks/meta.yaml b/tests/test-recipes/metadata/symlinks/meta.yaml
new file mode 100644
--- /dev/null
+++ b/tests/test-recipes/metadata/symlinks/meta.yaml
@@ -0,0 +1,3 @@
+package:
+  name: test_symlinks
+  version: 1.0
diff --git a/tests/test-recipes/metadata/symlinks/run_test.sh b/tests/test-recipes/metadata/symlinks/run_test.sh
new file mode 100644
--- /dev/null
+++ b/tests/test-recipes/metadata/symlinks/run_test.sh
@@ -0,0 +1,8 @@
+# the real file
+sh $PREFIX/test/weee
+
+# the symlink to the file
+sh $PREFIX/test/weee
+
+# the symlink to the folder
+sh $PREFIX/test_link/weee