We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
patching issue with test_api_skeleton.py
Hi, 

I am having issued with tests/test_api_skeleton.py.

On the first failure:

```bash
============================= test session starts ==============================
platform linux -- Python 3.5.2, pytest-2.9.2, py-1.4.31, pluggy-0.3.1
rootdir: <...>/conda-build, inifile: setup.cfg
plugins: capturelog-0.7, cov-2.3.1
collected 11 items

tests/test_api_skeleton.py F

 generated xml file: <...>/conda-build/junit.xml 
=================================== FAILURES ===================================
__________________________ test_repo[-pypi-pip-8.1.2] __________________________
Traceback (most recent call last):
  File "<...>/conda-build/tests/test_api_skeleton.py", line 21, in test_repo
    api.skeletonize(package, repo, version=version, output_dir=testing_workdir, config=test_config)
  File "<...>/conda-build/conda_build/api.py", line 193, in skeletonize
    recursive=recursive, config=config, **kwargs)
  File "<...>/conda-build/conda_build/skeletons/pypi.py", line 406, in skeletonize
    noprompt, packages, config=config, setup_options=setup_options)
  File "<...>/conda-build/conda_build/skeletons/pypi.py", line 664, in get_package_metadata
    config=config)
  File "<...>/conda-build/conda_build/skeletons/pypi.py", line 924, in get_pkginfo
    run_setuppy(src_dir, tempdir, python_version, config=config, setup_options=setup_options)
  File "<...>/conda-build/conda_build/skeletons/pypi.py", line 983, in run_setuppy
    apply_patch(join(stdlib_dir, 'distutils'), patch, config=config)
  File "<...>/conda-build/conda_build/source.py", line 483, in apply_patch
    check_call_env([patch] + patch_args, cwd=src_dir)
  File "<...>/conda-build/conda_build/utils.py", line 552, in check_call_env
    return _func_defaulting_env_to_os_environ(subprocess.check_call, *popenargs, **kwargs)
  File "<...>/conda-build/conda_build/utils.py", line 548, in _func_defaulting_env_to_os_environ
    return func(_args, **kwargs)
  File "<...>/lib/python3.5/subprocess.py", line 581, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/usr/bin/patch', '-p0', '-i', '/tmp/tmp3rh8k2j4conda_skeleton_pip-8.1.2.tar.gz/pypi-distutils.patch']' returned non-zero exit status 1
----------------------------- Captured stdout call -----------------------------
Using url https://pypi.python.org/packages/e7/a8/7556133689add8d1a54c0b14aeff0acb03c64707ce100ecd53934da1aa13/pip-8.1.2.tar.gz (1.1 MB) for pip.
Downloading pip
Unpacking pip...
done
working in /tmp/tmp3rh8k2j4conda_skeleton_pip-8.1.2.tar.gz
updating index in: /tmp/pytest-of-<...>/pytest-7/test_repo__pypi_pip_8_1_2_0/linux-64
updating index in: /tmp/pytest-of-<...>/pytest-7/test_repo__pypi_pip_8_1_2_0/noarch

The following NEW packages will be INSTALLED:

    openssl:    1.0.2j-0      (soft-link)
    pip:        8.1.2-py35_0  (soft-link)
    python:     3.5.2-0       (soft-link)
    pyyaml:     3.12-py35_0   (soft-link)
    readline:   6.2-2         (soft-link)
    setuptools: 27.2.0-py35_0 (soft-link)
    sqlite:     3.13.0-0      (soft-link)
    tk:         8.5.18-0      (soft-link)
    wheel:      0.29.0-py35_0 (soft-link)
    xz:         5.2.2-0       (soft-link)
    yaml:       0.1.6-0       (soft-link)
    zlib:       1.2.8-3       (soft-link)

Applying patch: '/tmp/tmp3rh8k2j4conda_skeleton_pip-8.1.2.tar.gz/pypi-distutils.patch' in /tmp/pytest-of-<...>/pytest-7/test_repo__pypi_pip_8_1_2_0/skeleton_1478167437529/_b_env_placehold_<...>/lib/python3.5/distutils
File core.py is not a regular file -- refusing to patch
1 out of 1 hunk ignored -- saving rejects to file core.py.rej
```

patching fails because core.py is a symlink ...

A temporary fix would be adding --follow-symlinks in the patch command, but this is ugly
**source.py l.480 in apply_patch**
```python
patch_args = ['-p%d' % patch_strip_level, '-i', path, '--follow-symlinks']
``` 

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `conda_build/conda_interface.py`
Content:
```
1 # -*- coding: utf-8 -*-
2 from __future__ import absolute_import, division, print_function, unicode_literals
3 
4 from functools import partial
5 from pkg_resources import parse_version
6 
7 import conda
8 from conda import compat, plan  # NOQA
9 from conda.api import get_index  # NOQA
10 from conda.cli.common import (Completer, InstalledPackages, add_parser_channels, add_parser_prefix,  # NOQA
11                               specs_from_args, spec_from_line, specs_from_url)  # NOQA
12 from conda.cli.conda_argparse import ArgumentParser  # NOQA
13 from conda.compat import (PY3, StringIO, configparser, input, iteritems, lchmod, string_types,  # NOQA
14                           text_type, TemporaryDirectory)  # NOQA
15 from conda.connection import CondaSession  # NOQA
16 from conda.fetch import TmpDownload, download, fetch_index, handle_proxy_407  # NOQA
17 from conda.install import (delete_trash, is_linked, linked, linked_data, prefix_placeholder,  # NOQA
18                            rm_rf, symlink_conda, rm_fetched, package_cache)  # NOQA
19 from conda.lock import Locked  # NOQA
20 from conda.misc import untracked, walk_prefix  # NOQA
21 from conda.resolve import MatchSpec, NoPackagesFound, Resolve, Unsatisfiable, normalized_version  # NOQA
22 from conda.signature import KEYS, KEYS_DIR, hash_file, verify  # NOQA
23 from conda.utils import human_bytes, hashsum_file, md5_file, memoized, unix_path_to_win, win_path_to_unix, url_path  # NOQA
24 import conda.config as cc  # NOQA
25 from conda.config import rc_path  # NOQA
26 from conda.version import VersionOrder  # NOQA
27 
28 if parse_version(conda.__version__) >= parse_version("4.2"):
29     # conda 4.2.x
30     import conda.base.context
31     import conda.exceptions
32     from conda.base.context import get_prefix as context_get_prefix, non_x86_linux_machines  # NOQA
33 
34     from conda.base.constants import DEFAULT_CHANNELS  # NOQA
35     get_prefix = partial(context_get_prefix, conda.base.context.context)
36     get_default_urls = lambda: DEFAULT_CHANNELS
37 
38     arch_name = conda.base.context.context.arch_name
39     binstar_upload = conda.base.context.context.binstar_upload
40     bits = conda.base.context.context.bits
41     default_prefix = conda.base.context.context.default_prefix
42     default_python = conda.base.context.context.default_python
43     envs_dirs = conda.base.context.context.envs_dirs
44     pkgs_dirs = conda.base.context.context.pkgs_dirs
45     platform = conda.base.context.context.platform
46     root_dir = conda.base.context.context.root_dir
47     root_writable = conda.base.context.context.root_writable
48     subdir = conda.base.context.context.subdir
49     from conda.models.channel import get_conda_build_local_url
50     get_rc_urls = lambda: list(conda.base.context.context.channels)
51     get_local_urls = lambda: list(get_conda_build_local_url()) or []
52     load_condarc = lambda fn: conda.base.context.reset_context([fn])
53     PaddingError = conda.exceptions.PaddingError
54     LinkError = conda.exceptions.LinkError
55     NoPackagesFoundError = conda.exceptions.NoPackagesFoundError
56     CondaValueError = conda.exceptions.CondaValueError
57 
58 else:
59     from conda.config import get_default_urls, non_x86_linux_machines, load_condarc  # NOQA
60     from conda.cli.common import get_prefix  # NOQA
61 
62     arch_name = cc.arch_name
63     binstar_upload = cc.binstar_upload
64     bits = cc.bits
65     default_prefix = cc.default_prefix
66     default_python = cc.default_python
67     envs_dirs = cc.envs_dirs
68     pkgs_dirs = cc.pkgs_dirs
69     platform = cc.platform
70     root_dir = cc.root_dir
71     root_writable = cc.root_writable
72     subdir = cc.subdir
73 
74     get_rc_urls = cc.get_rc_urls
75     get_local_urls = cc.get_local_urls
76 
77     class PaddingError(Exception):
78         pass
79 
80     class LinkError(Exception):
81         pass
82 
83     class NoPackagesFoundError(Exception):
84         pass
85 
86     class CondaValueError(Exception):
87         pass
88 
89 
90 class SignatureError(Exception):
91     pass
92 
93 
94 def which_package(path):
95     """
96     given the path (of a (presumably) conda installed file) iterate over
97     the conda packages the file came from.  Usually the iteration yields
98     only one package.
99     """
100     from os.path import abspath, join
101     path = abspath(path)
102     prefix = which_prefix(path)
103     if prefix is None:
104         raise RuntimeError("could not determine conda prefix from: %s" % path)
105     for dist in linked(prefix):
106         meta = is_linked(prefix, dist)
107         if any(abspath(join(prefix, f)) == path for f in meta['files']):
108             yield dist
109 
110 
111 def which_prefix(path):
112     """
113     given the path (to a (presumably) conda installed file) return the
114     environment prefix in which the file in located
115     """
116     from os.path import abspath, join, isdir, dirname
117     prefix = abspath(path)
118     while True:
119         if isdir(join(prefix, 'conda-meta')):
120             # we found the it, so let's return it
121             return prefix
122         if prefix == dirname(prefix):
123             # we cannot chop off any more directories, so we didn't find it
124             return None
125         prefix = dirname(prefix)
126
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/conda_build/conda_interface.py b/conda_build/conda_interface.py
--- a/conda_build/conda_interface.py
+++ b/conda_build/conda_interface.py
@@ -55,6 +55,9 @@
     NoPackagesFoundError = conda.exceptions.NoPackagesFoundError
     CondaValueError = conda.exceptions.CondaValueError
 
+    # disallow softlinks.  This avoids a lot of dumb issues, at the potential cost of disk space.
+    conda.base.context.context.allow_softlinks = False
+
 else:
     from conda.config import get_default_urls, non_x86_linux_machines, load_condarc  # NOQA
     from conda.cli.common import get_prefix  # NOQA
@@ -74,6 +77,8 @@
     get_rc_urls = cc.get_rc_urls
     get_local_urls = cc.get_local_urls
 
+    cc.allow_softlinks = False
+
     class PaddingError(Exception):
         pass

{"golden_diff": "diff --git a/conda_build/conda_interface.py b/conda_build/conda_interface.py\n--- a/conda_build/conda_interface.py\n+++ b/conda_build/conda_interface.py\n@@ -55,6 +55,9 @@\n     NoPackagesFoundError = conda.exceptions.NoPackagesFoundError\n     CondaValueError = conda.exceptions.CondaValueError\n \n+    # disallow softlinks.  This avoids a lot of dumb issues, at the potential cost of disk space.\n+    conda.base.context.context.allow_softlinks = False\n+\n else:\n     from conda.config import get_default_urls, non_x86_linux_machines, load_condarc  # NOQA\n     from conda.cli.common import get_prefix  # NOQA\n@@ -74,6 +77,8 @@\n     get_rc_urls = cc.get_rc_urls\n     get_local_urls = cc.get_local_urls\n \n+    cc.allow_softlinks = False\n+\n     class PaddingError(Exception):\n         pass\n", "issue": "patching issue with test_api_skeleton.py\nHi, \r\n\r\nI am having issued with tests/test_api_skeleton.py.\r\n\r\nOn the first failure:\r\n\r\n```bash\r\n============================= test session starts ==============================\r\nplatform linux -- Python 3.5.2, pytest-2.9.2, py-1.4.31, pluggy-0.3.1\r\nrootdir: <...>/conda-build, inifile: setup.cfg\r\nplugins: capturelog-0.7, cov-2.3.1\r\ncollected 11 items\r\n\r\ntests/test_api_skeleton.py F\r\n\r\n generated xml file: <...>/conda-build/junit.xml \r\n=================================== FAILURES ===================================\r\n__________________________ test_repo[-pypi-pip-8.1.2] __________________________\r\nTraceback (most recent call last):\r\n  File \"<...>/conda-build/tests/test_api_skeleton.py\", line 21, in test_repo\r\n    api.skeletonize(package, repo, version=version, output_dir=testing_workdir, config=test_config)\r\n  File \"<...>/conda-build/conda_build/api.py\", line 193, in skeletonize\r\n    recursive=recursive, config=config, **kwargs)\r\n  File \"<...>/conda-build/conda_build/skeletons/pypi.py\", line 406, in skeletonize\r\n    noprompt, packages, config=config, setup_options=setup_options)\r\n  File \"<...>/conda-build/conda_build/skeletons/pypi.py\", line 664, in get_package_metadata\r\n    config=config)\r\n  File \"<...>/conda-build/conda_build/skeletons/pypi.py\", line 924, in get_pkginfo\r\n    run_setuppy(src_dir, tempdir, python_version, config=config, setup_options=setup_options)\r\n  File \"<...>/conda-build/conda_build/skeletons/pypi.py\", line 983, in run_setuppy\r\n    apply_patch(join(stdlib_dir, 'distutils'), patch, config=config)\r\n  File \"<...>/conda-build/conda_build/source.py\", line 483, in apply_patch\r\n    check_call_env([patch] + patch_args, cwd=src_dir)\r\n  File \"<...>/conda-build/conda_build/utils.py\", line 552, in check_call_env\r\n    return _func_defaulting_env_to_os_environ(subprocess.check_call, *popenargs, **kwargs)\r\n  File \"<...>/conda-build/conda_build/utils.py\", line 548, in _func_defaulting_env_to_os_environ\r\n    return func(_args, **kwargs)\r\n  File \"<...>/lib/python3.5/subprocess.py\", line 581, in check_call\r\n    raise CalledProcessError(retcode, cmd)\r\nsubprocess.CalledProcessError: Command '['/usr/bin/patch', '-p0', '-i', '/tmp/tmp3rh8k2j4conda_skeleton_pip-8.1.2.tar.gz/pypi-distutils.patch']' returned non-zero exit status 1\r\n----------------------------- Captured stdout call -----------------------------\r\nUsing url https://pypi.python.org/packages/e7/a8/7556133689add8d1a54c0b14aeff0acb03c64707ce100ecd53934da1aa13/pip-8.1.2.tar.gz (1.1 MB) for pip.\r\nDownloading pip\r\nUnpacking pip...\r\ndone\r\nworking in /tmp/tmp3rh8k2j4conda_skeleton_pip-8.1.2.tar.gz\r\nupdating index in: /tmp/pytest-of-<...>/pytest-7/test_repo__pypi_pip_8_1_2_0/linux-64\r\nupdating index in: /tmp/pytest-of-<...>/pytest-7/test_repo__pypi_pip_8_1_2_0/noarch\r\n\r\nThe following NEW packages will be INSTALLED:\r\n\r\n    openssl:    1.0.2j-0      (soft-link)\r\n    pip:        8.1.2-py35_0  (soft-link)\r\n    python:     3.5.2-0       (soft-link)\r\n    pyyaml:     3.12-py35_0   (soft-link)\r\n    readline:   6.2-2         (soft-link)\r\n    setuptools: 27.2.0-py35_0 (soft-link)\r\n    sqlite:     3.13.0-0      (soft-link)\r\n    tk:         8.5.18-0      (soft-link)\r\n    wheel:      0.29.0-py35_0 (soft-link)\r\n    xz:         5.2.2-0       (soft-link)\r\n    yaml:       0.1.6-0       (soft-link)\r\n    zlib:       1.2.8-3       (soft-link)\r\n\r\nApplying patch: '/tmp/tmp3rh8k2j4conda_skeleton_pip-8.1.2.tar.gz/pypi-distutils.patch' in /tmp/pytest-of-<...>/pytest-7/test_repo__pypi_pip_8_1_2_0/skeleton_1478167437529/_b_env_placehold_<...>/lib/python3.5/distutils\r\nFile core.py is not a regular file -- refusing to patch\r\n1 out of 1 hunk ignored -- saving rejects to file core.py.rej\r\n```\r\n\r\npatching fails because core.py is a symlink ...\r\n\r\nA temporary fix would be adding --follow-symlinks in the patch command, but this is ugly\r\n**source.py l.480 in apply_patch**\r\n```python\r\npatch_args = ['-p%d' % patch_strip_level, '-i', path, '--follow-symlinks']\r\n``` \n", "before_files": [{"content": "# -*- coding: utf-8 -*-\nfrom __future__ import absolute_import, division, print_function, unicode_literals\n\nfrom functools import partial\nfrom pkg_resources import parse_version\n\nimport conda\nfrom conda import compat, plan  # NOQA\nfrom conda.api import get_index  # NOQA\nfrom conda.cli.common import (Completer, InstalledPackages, add_parser_channels, add_parser_prefix,  # NOQA\n                              specs_from_args, spec_from_line, specs_from_url)  # NOQA\nfrom conda.cli.conda_argparse import ArgumentParser  # NOQA\nfrom conda.compat import (PY3, StringIO, configparser, input, iteritems, lchmod, string_types,  # NOQA\n                          text_type, TemporaryDirectory)  # NOQA\nfrom conda.connection import CondaSession  # NOQA\nfrom conda.fetch import TmpDownload, download, fetch_index, handle_proxy_407  # NOQA\nfrom conda.install import (delete_trash, is_linked, linked, linked_data, prefix_placeholder,  # NOQA\n                           rm_rf, symlink_conda, rm_fetched, package_cache)  # NOQA\nfrom conda.lock import Locked  # NOQA\nfrom conda.misc import untracked, walk_prefix  # NOQA\nfrom conda.resolve import MatchSpec, NoPackagesFound, Resolve, Unsatisfiable, normalized_version  # NOQA\nfrom conda.signature import KEYS, KEYS_DIR, hash_file, verify  # NOQA\nfrom conda.utils import human_bytes, hashsum_file, md5_file, memoized, unix_path_to_win, win_path_to_unix, url_path  # NOQA\nimport conda.config as cc  # NOQA\nfrom conda.config import rc_path  # NOQA\nfrom conda.version import VersionOrder  # NOQA\n\nif parse_version(conda.__version__) >= parse_version(\"4.2\"):\n    # conda 4.2.x\n    import conda.base.context\n    import conda.exceptions\n    from conda.base.context import get_prefix as context_get_prefix, non_x86_linux_machines  # NOQA\n\n    from conda.base.constants import DEFAULT_CHANNELS  # NOQA\n    get_prefix = partial(context_get_prefix, conda.base.context.context)\n    get_default_urls = lambda: DEFAULT_CHANNELS\n\n    arch_name = conda.base.context.context.arch_name\n    binstar_upload = conda.base.context.context.binstar_upload\n    bits = conda.base.context.context.bits\n    default_prefix = conda.base.context.context.default_prefix\n    default_python = conda.base.context.context.default_python\n    envs_dirs = conda.base.context.context.envs_dirs\n    pkgs_dirs = conda.base.context.context.pkgs_dirs\n    platform = conda.base.context.context.platform\n    root_dir = conda.base.context.context.root_dir\n    root_writable = conda.base.context.context.root_writable\n    subdir = conda.base.context.context.subdir\n    from conda.models.channel import get_conda_build_local_url\n    get_rc_urls = lambda: list(conda.base.context.context.channels)\n    get_local_urls = lambda: list(get_conda_build_local_url()) or []\n    load_condarc = lambda fn: conda.base.context.reset_context([fn])\n    PaddingError = conda.exceptions.PaddingError\n    LinkError = conda.exceptions.LinkError\n    NoPackagesFoundError = conda.exceptions.NoPackagesFoundError\n    CondaValueError = conda.exceptions.CondaValueError\n\nelse:\n    from conda.config import get_default_urls, non_x86_linux_machines, load_condarc  # NOQA\n    from conda.cli.common import get_prefix  # NOQA\n\n    arch_name = cc.arch_name\n    binstar_upload = cc.binstar_upload\n    bits = cc.bits\n    default_prefix = cc.default_prefix\n    default_python = cc.default_python\n    envs_dirs = cc.envs_dirs\n    pkgs_dirs = cc.pkgs_dirs\n    platform = cc.platform\n    root_dir = cc.root_dir\n    root_writable = cc.root_writable\n    subdir = cc.subdir\n\n    get_rc_urls = cc.get_rc_urls\n    get_local_urls = cc.get_local_urls\n\n    class PaddingError(Exception):\n        pass\n\n    class LinkError(Exception):\n        pass\n\n    class NoPackagesFoundError(Exception):\n        pass\n\n    class CondaValueError(Exception):\n        pass\n\n\nclass SignatureError(Exception):\n    pass\n\n\ndef which_package(path):\n    \"\"\"\n    given the path (of a (presumably) conda installed file) iterate over\n    the conda packages the file came from.  Usually the iteration yields\n    only one package.\n    \"\"\"\n    from os.path import abspath, join\n    path = abspath(path)\n    prefix = which_prefix(path)\n    if prefix is None:\n        raise RuntimeError(\"could not determine conda prefix from: %s\" % path)\n    for dist in linked(prefix):\n        meta = is_linked(prefix, dist)\n        if any(abspath(join(prefix, f)) == path for f in meta['files']):\n            yield dist\n\n\ndef which_prefix(path):\n    \"\"\"\n    given the path (to a (presumably) conda installed file) return the\n    environment prefix in which the file in located\n    \"\"\"\n    from os.path import abspath, join, isdir, dirname\n    prefix = abspath(path)\n    while True:\n        if isdir(join(prefix, 'conda-meta')):\n            # we found the it, so let's return it\n            return prefix\n        if prefix == dirname(prefix):\n            # we cannot chop off any more directories, so we didn't find it\n            return None\n        prefix = dirname(prefix)\n", "path": "conda_build/conda_interface.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\nfrom __future__ import absolute_import, division, print_function, unicode_literals\n\nfrom functools import partial\nfrom pkg_resources import parse_version\n\nimport conda\nfrom conda import compat, plan  # NOQA\nfrom conda.api import get_index  # NOQA\nfrom conda.cli.common import (Completer, InstalledPackages, add_parser_channels, add_parser_prefix,  # NOQA\n                              specs_from_args, spec_from_line, specs_from_url)  # NOQA\nfrom conda.cli.conda_argparse import ArgumentParser  # NOQA\nfrom conda.compat import (PY3, StringIO, configparser, input, iteritems, lchmod, string_types,  # NOQA\n                          text_type, TemporaryDirectory)  # NOQA\nfrom conda.connection import CondaSession  # NOQA\nfrom conda.fetch import TmpDownload, download, fetch_index, handle_proxy_407  # NOQA\nfrom conda.install import (delete_trash, is_linked, linked, linked_data, prefix_placeholder,  # NOQA\n                           rm_rf, symlink_conda, rm_fetched, package_cache)  # NOQA\nfrom conda.lock import Locked  # NOQA\nfrom conda.misc import untracked, walk_prefix  # NOQA\nfrom conda.resolve import MatchSpec, NoPackagesFound, Resolve, Unsatisfiable, normalized_version  # NOQA\nfrom conda.signature import KEYS, KEYS_DIR, hash_file, verify  # NOQA\nfrom conda.utils import human_bytes, hashsum_file, md5_file, memoized, unix_path_to_win, win_path_to_unix, url_path  # NOQA\nimport conda.config as cc  # NOQA\nfrom conda.config import rc_path  # NOQA\nfrom conda.version import VersionOrder  # NOQA\n\nif parse_version(conda.__version__) >= parse_version(\"4.2\"):\n    # conda 4.2.x\n    import conda.base.context\n    import conda.exceptions\n    from conda.base.context import get_prefix as context_get_prefix, non_x86_linux_machines  # NOQA\n\n    from conda.base.constants import DEFAULT_CHANNELS  # NOQA\n    get_prefix = partial(context_get_prefix, conda.base.context.context)\n    get_default_urls = lambda: DEFAULT_CHANNELS\n\n    arch_name = conda.base.context.context.arch_name\n    binstar_upload = conda.base.context.context.binstar_upload\n    bits = conda.base.context.context.bits\n    default_prefix = conda.base.context.context.default_prefix\n    default_python = conda.base.context.context.default_python\n    envs_dirs = conda.base.context.context.envs_dirs\n    pkgs_dirs = conda.base.context.context.pkgs_dirs\n    platform = conda.base.context.context.platform\n    root_dir = conda.base.context.context.root_dir\n    root_writable = conda.base.context.context.root_writable\n    subdir = conda.base.context.context.subdir\n    from conda.models.channel import get_conda_build_local_url\n    get_rc_urls = lambda: list(conda.base.context.context.channels)\n    get_local_urls = lambda: list(get_conda_build_local_url()) or []\n    load_condarc = lambda fn: conda.base.context.reset_context([fn])\n    PaddingError = conda.exceptions.PaddingError\n    LinkError = conda.exceptions.LinkError\n    NoPackagesFoundError = conda.exceptions.NoPackagesFoundError\n    CondaValueError = conda.exceptions.CondaValueError\n\n    # disallow softlinks.  This avoids a lot of dumb issues, at the potential cost of disk space.\n    conda.base.context.context.allow_softlinks = False\n\nelse:\n    from conda.config import get_default_urls, non_x86_linux_machines, load_condarc  # NOQA\n    from conda.cli.common import get_prefix  # NOQA\n\n    arch_name = cc.arch_name\n    binstar_upload = cc.binstar_upload\n    bits = cc.bits\n    default_prefix = cc.default_prefix\n    default_python = cc.default_python\n    envs_dirs = cc.envs_dirs\n    pkgs_dirs = cc.pkgs_dirs\n    platform = cc.platform\n    root_dir = cc.root_dir\n    root_writable = cc.root_writable\n    subdir = cc.subdir\n\n    get_rc_urls = cc.get_rc_urls\n    get_local_urls = cc.get_local_urls\n\n    cc.allow_softlinks = False\n\n    class PaddingError(Exception):\n        pass\n\n    class LinkError(Exception):\n        pass\n\n    class NoPackagesFoundError(Exception):\n        pass\n\n    class CondaValueError(Exception):\n        pass\n\n\nclass SignatureError(Exception):\n    pass\n\n\ndef which_package(path):\n    \"\"\"\n    given the path (of a (presumably) conda installed file) iterate over\n    the conda packages the file came from.  Usually the iteration yields\n    only one package.\n    \"\"\"\n    from os.path import abspath, join\n    path = abspath(path)\n    prefix = which_prefix(path)\n    if prefix is None:\n        raise RuntimeError(\"could not determine conda prefix from: %s\" % path)\n    for dist in linked(prefix):\n        meta = is_linked(prefix, dist)\n        if any(abspath(join(prefix, f)) == path for f in meta['files']):\n            yield dist\n\n\ndef which_prefix(path):\n    \"\"\"\n    given the path (to a (presumably) conda installed file) return the\n    environment prefix in which the file in located\n    \"\"\"\n    from os.path import abspath, join, isdir, dirname\n    prefix = abspath(path)\n    while True:\n        if isdir(join(prefix, 'conda-meta')):\n            # we found the it, so let's return it\n            return prefix\n        if prefix == dirname(prefix):\n            # we cannot chop off any more directories, so we didn't find it\n            return None\n        prefix = dirname(prefix)\n", "path": "conda_build/conda_interface.py"}]}