We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN 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
```


--- 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/environ.py`
Content:
```
1 from __future__ import absolute_import, division, print_function
2 
3 import os
4 import sys
5 from os.path import join, normpath, isabs
6 from subprocess import STDOUT, check_output, CalledProcessError, Popen, PIPE
7 import multiprocessing
8 import warnings
9 
10 import conda.config as cc
11 
12 from conda_build.config import config
13 
14 from conda_build import source
15 from conda_build.scripts import prepend_bin_path
16 
17 
18 def get_perl_ver():
19     return str(config.CONDA_PERL)
20 
21 
22 def get_py_ver():
23     return '.'.join(str(config.CONDA_PY))
24 
25 
26 def get_npy_ver():
27     if config.CONDA_NPY:
28         # Convert int -> string, e.g.
29         #   17 -> '1.7'
30         #   110 -> '1.10'
31         conda_npy = str(config.CONDA_NPY)
32         return conda_npy[0] + '.' + conda_npy[1:]
33     return ''
34 
35 
36 def get_stdlib_dir():
37     return join(config.build_prefix, 'Lib' if sys.platform == 'win32' else
38                 'lib/python%s' % get_py_ver())
39 
40 
41 def get_sp_dir():
42     return join(get_stdlib_dir(), 'site-packages')
43 
44 
45 def get_git_build_info(src_dir, git_url, expected_rev):
46     expected_rev = expected_rev or 'HEAD'
47     env = os.environ.copy()
48     d = {}
49     git_dir = join(src_dir, '.git')
50     if not os.path.exists(git_dir):
51         return d
52 
53     env['GIT_DIR'] = git_dir
54     try:
55         # Verify current commit matches expected commit
56         current_commit = check_output(["git", "log", "-n1", "--format=%H"],
57                                       env=env, stderr=STDOUT)
58         current_commit = current_commit.decode('utf-8')
59         expected_tag_commit = check_output(["git", "log", "-n1", "--format=%H",
60                                             expected_rev],
61                                            env=env, stderr=STDOUT)
62         expected_tag_commit = expected_tag_commit.decode('utf-8')
63 
64         # Verify correct remote url. Need to find the git cache directory,
65         # and check the remote from there.
66         cache_details = check_output(["git", "remote", "-v"], env=env,
67                                      stderr=STDOUT)
68         cache_details = cache_details.decode('utf-8')
69         cache_dir = cache_details.split('\n')[0].split()[1]
70         assert "conda-bld/git_cache" in cache_dir
71 
72         env['GIT_DIR'] = cache_dir
73         remote_details = check_output(["git", "remote", "-v"], env=env,
74                                       stderr=STDOUT)
75         remote_details = remote_details.decode('utf-8')
76         remote_url = remote_details.split('\n')[0].split()[1]
77         if '://' not in remote_url:
78             # Local filepaths are allowed, but make sure we normalize them
79             remote_url = normpath(remote_url)
80 
81         # If the current source directory in conda-bld/work doesn't match the
82         # user's metadata git_url or git_rev, then we aren't looking at the
83         # right source.
84         if remote_url != git_url or current_commit != expected_tag_commit:
85             return d
86     except CalledProcessError:
87         return d
88 
89     env['GIT_DIR'] = git_dir
90 
91     # grab information from describe
92     key_name = lambda a: "GIT_DESCRIBE_{}".format(a)
93     keys = [key_name("TAG"), key_name("NUMBER"), key_name("HASH")]
94     env = {str(key): str(value) for key, value in env.items()}
95     process = Popen(["git", "describe", "--tags", "--long", "HEAD"],
96                     stdout=PIPE, stderr=PIPE,
97                     env=env)
98     output = process.communicate()[0].strip()
99     output = output.decode('utf-8')
100     parts = output.rsplit('-', 2)
101     parts_length = len(parts)
102     if parts_length == 3:
103         d.update(dict(zip(keys, parts)))
104     # get the _full_ hash of the current HEAD
105     process = Popen(["git", "rev-parse", "HEAD"],
106                     stdout=PIPE, stderr=PIPE, env=env)
107     output = process.communicate()[0].strip()
108     output = output.decode('utf-8')
109     d['GIT_FULL_HASH'] = output
110     # set up the build string
111     if key_name('NUMBER') in d and key_name('HASH') in d:
112         d['GIT_BUILD_STR'] = '{}_{}'.format(d[key_name('NUMBER')],
113                                             d[key_name('HASH')])
114 
115     return d
116 
117 
118 def get_dict(m=None, prefix=None):
119     if not prefix:
120         prefix = config.build_prefix
121 
122     python = config.build_python
123     d = {'CONDA_BUILD': '1', 'PYTHONNOUSERSITE': '1'}
124     d['CONDA_DEFAULT_ENV'] = config.build_prefix
125     d['ARCH'] = str(cc.bits)
126     d['PREFIX'] = prefix
127     d['PYTHON'] = python
128     d['PY3K'] = str(config.PY3K)
129     d['STDLIB_DIR'] = get_stdlib_dir()
130     d['SP_DIR'] = get_sp_dir()
131     d['SYS_PREFIX'] = sys.prefix
132     d['SYS_PYTHON'] = sys.executable
133     d['PERL_VER'] = get_perl_ver()
134     d['PY_VER'] = get_py_ver()
135     if get_npy_ver():
136         d['NPY_VER'] = get_npy_ver()
137     d['SRC_DIR'] = source.get_dir()
138     if "LANG" in os.environ:
139         d['LANG'] = os.environ['LANG']
140     if "HTTPS_PROXY" in os.environ:
141         d['HTTPS_PROXY'] = os.environ['HTTPS_PROXY']
142     if "HTTP_PROXY" in os.environ:
143         d['HTTP_PROXY'] = os.environ['HTTP_PROXY']
144 
145     if m:
146         for var_name in m.get_value('build/script_env', []):
147             value = os.getenv(var_name)
148             if value is None:
149                 warnings.warn(
150                     "The environment variable '%s' is undefined." % var_name,
151                     UserWarning
152                 )
153             else:
154                 d[var_name] = value
155 
156     if sys.platform == "darwin":
157         # multiprocessing.cpu_count() is not reliable on OSX
158         # See issue #645 on github.com/conda/conda-build
159         out, err = Popen('sysctl -n hw.logicalcpu', shell=True,
160                          stdout=PIPE).communicate()
161         d['CPU_COUNT'] = out.decode('utf-8').strip()
162     else:
163         try:
164             d['CPU_COUNT'] = str(multiprocessing.cpu_count())
165         except NotImplementedError:
166             d['CPU_COUNT'] = "1"
167 
168     if m and m.get_value('source/git_url'):
169         git_url = m.get_value('source/git_url')
170         if '://' not in git_url:
171             # If git_url is a relative path instead of a url, convert it to an
172             # abspath
173             if not isabs(git_url):
174                 git_url = join(m.path, git_url)
175             git_url = normpath(join(m.path, git_url))
176         d.update(**get_git_build_info(d['SRC_DIR'],
177                                       git_url,
178                                       m.get_value('source/git_rev')))
179 
180     d['PATH'] = dict(os.environ)['PATH']
181     d = prepend_bin_path(d, prefix)
182 
183     if sys.platform == 'win32':
184         # -------- Windows
185         d['SCRIPTS'] = join(prefix, 'Scripts')
186         d['LIBRARY_PREFIX'] = join(prefix, 'Library')
187         d['LIBRARY_BIN'] = join(d['LIBRARY_PREFIX'], 'bin')
188         d['LIBRARY_INC'] = join(d['LIBRARY_PREFIX'], 'include')
189         d['LIBRARY_LIB'] = join(d['LIBRARY_PREFIX'], 'lib')
190 
191         drive, tail = prefix.split(':')
192         d['CYGWIN_PREFIX'] = ''.join(['/cygdrive/', drive.lower(),
193                                      tail.replace('\\', '/')])
194 
195         d['R'] = join(prefix, 'Scripts', 'R.exe')
196     else:
197         # -------- Unix
198         d['HOME'] = os.getenv('HOME', 'UNKNOWN')
199         d['PKG_CONFIG_PATH'] = join(prefix, 'lib', 'pkgconfig')
200         d['R'] = join(prefix, 'bin', 'R')
201 
202     # in case CFLAGS was added in the `script_env` section above
203     cflags = d.get('CFLAGS', '')
204     cxxflags = d.get('CXXFLAGS', '')
205     ldflags = d.get('LDFLAGS', '')
206 
207     if sys.platform == 'darwin':
208         # -------- OSX
209         d['OSX_ARCH'] = 'i386' if cc.bits == 32 else 'x86_64'
210         d['CFLAGS'] = cflags + ' -arch %(OSX_ARCH)s' % d
211         d['CXXFLAGS'] = cxxflags + ' -arch %(OSX_ARCH)s' % d
212         rpath = ' -rpath %(PREFIX)s/lib' % d # SIP workaround, DYLD_* no longer works.
213         d['LDFLAGS'] = ldflags + rpath + ' -arch %(OSX_ARCH)s' % d
214         d['MACOSX_DEPLOYMENT_TARGET'] = '10.6'
215 
216     elif sys.platform.startswith('linux'):
217         # -------- Linux
218         d['LD_RUN_PATH'] = prefix + '/lib'
219         if cc.bits == 32:
220             d['CFLAGS'] = cflags + ' -m32'
221             d['CXXFLAGS'] = cxxflags + ' -m32'
222 
223     if m:
224         d['PKG_NAME'] = m.name()
225         d['PKG_VERSION'] = m.version()
226         d['PKG_BUILDNUM'] = str(m.build_number())
227         d['PKG_BUILD_STRING'] = str(m.build_id())
228         d['RECIPE_DIR'] = m.path
229 
230     return d
231 
232 
233 if __name__ == '__main__':
234     e = get_dict()
235     for k in sorted(e):
236         assert isinstance(e[k], str), k
237         print('%s=%s' % (k, e[k]))
238
```
--- 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/environ.py b/conda_build/environ.py
--- a/conda_build/environ.py
+++ b/conda_build/environ.py
@@ -209,7 +209,7 @@
         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'

{"golden_diff": "diff --git a/conda_build/environ.py b/conda_build/environ.py\n--- a/conda_build/environ.py\n+++ b/conda_build/environ.py\n@@ -209,7 +209,7 @@\n         d['OSX_ARCH'] = 'i386' if cc.bits == 32 else 'x86_64'\n         d['CFLAGS'] = cflags + ' -arch %(OSX_ARCH)s' % d\n         d['CXXFLAGS'] = cxxflags + ' -arch %(OSX_ARCH)s' % d\n-        rpath = ' -rpath %(PREFIX)s/lib' % d # SIP workaround, DYLD_* no longer works.\n+        rpath = ' -Wl,-rpath,%(PREFIX)s/lib' % d # SIP workaround, DYLD_* no longer works.\n         d['LDFLAGS'] = ldflags + rpath + ' -arch %(OSX_ARCH)s' % d\n         d['MACOSX_DEPLOYMENT_TARGET'] = '10.6'\n", "issue": "conda-build 1.19.1 breaks C compilation\nI am using conda build on [this recipe](https://github.com/mmp2/megaman/tree/master/conda_recipes/pyamg)\n\nIt works on 1.19.0, but on 1.19.1 fails with this message:\n\n```\ncreating build/temp.macosx-10.5-x86_64-3.5\ncreating build/temp.macosx-10.5-x86_64-3.5/pyamg\ncreating build/temp.macosx-10.5-x86_64-3.5/pyamg/amg_core\ncompile 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'\ng++: pyamg/amg_core/amg_core_wrap.cxx\ng++ -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\ng++: error: unrecognized command line option \u2018-rpath\u2019\ng++: error: unrecognized command line option \u2018-rpath\u2019\ng++: error: unrecognized command line option \u00e2\u0080\u0098-rpath\u00e2\u0080\u0099\ng++: error: unrecognized command line option \u00e2\u0080\u0098-rpath\u00e2\u0080\u0099\nerror: 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\nCommand failed: /bin/bash -x -e /Users/jakevdp/Opensource/megaman/conda_recipes/pyamg/build.sh\n```\n\n", "before_files": [{"content": "from __future__ import absolute_import, division, print_function\n\nimport os\nimport sys\nfrom os.path import join, normpath, isabs\nfrom subprocess import STDOUT, check_output, CalledProcessError, Popen, PIPE\nimport multiprocessing\nimport warnings\n\nimport conda.config as cc\n\nfrom conda_build.config import config\n\nfrom conda_build import source\nfrom conda_build.scripts import prepend_bin_path\n\n\ndef get_perl_ver():\n    return str(config.CONDA_PERL)\n\n\ndef get_py_ver():\n    return '.'.join(str(config.CONDA_PY))\n\n\ndef get_npy_ver():\n    if config.CONDA_NPY:\n        # Convert int -> string, e.g.\n        #   17 -> '1.7'\n        #   110 -> '1.10'\n        conda_npy = str(config.CONDA_NPY)\n        return conda_npy[0] + '.' + conda_npy[1:]\n    return ''\n\n\ndef get_stdlib_dir():\n    return join(config.build_prefix, 'Lib' if sys.platform == 'win32' else\n                'lib/python%s' % get_py_ver())\n\n\ndef get_sp_dir():\n    return join(get_stdlib_dir(), 'site-packages')\n\n\ndef get_git_build_info(src_dir, git_url, expected_rev):\n    expected_rev = expected_rev or 'HEAD'\n    env = os.environ.copy()\n    d = {}\n    git_dir = join(src_dir, '.git')\n    if not os.path.exists(git_dir):\n        return d\n\n    env['GIT_DIR'] = git_dir\n    try:\n        # Verify current commit matches expected commit\n        current_commit = check_output([\"git\", \"log\", \"-n1\", \"--format=%H\"],\n                                      env=env, stderr=STDOUT)\n        current_commit = current_commit.decode('utf-8')\n        expected_tag_commit = check_output([\"git\", \"log\", \"-n1\", \"--format=%H\",\n                                            expected_rev],\n                                           env=env, stderr=STDOUT)\n        expected_tag_commit = expected_tag_commit.decode('utf-8')\n\n        # Verify correct remote url. Need to find the git cache directory,\n        # and check the remote from there.\n        cache_details = check_output([\"git\", \"remote\", \"-v\"], env=env,\n                                     stderr=STDOUT)\n        cache_details = cache_details.decode('utf-8')\n        cache_dir = cache_details.split('\\n')[0].split()[1]\n        assert \"conda-bld/git_cache\" in cache_dir\n\n        env['GIT_DIR'] = cache_dir\n        remote_details = check_output([\"git\", \"remote\", \"-v\"], env=env,\n                                      stderr=STDOUT)\n        remote_details = remote_details.decode('utf-8')\n        remote_url = remote_details.split('\\n')[0].split()[1]\n        if '://' not in remote_url:\n            # Local filepaths are allowed, but make sure we normalize them\n            remote_url = normpath(remote_url)\n\n        # If the current source directory in conda-bld/work doesn't match the\n        # user's metadata git_url or git_rev, then we aren't looking at the\n        # right source.\n        if remote_url != git_url or current_commit != expected_tag_commit:\n            return d\n    except CalledProcessError:\n        return d\n\n    env['GIT_DIR'] = git_dir\n\n    # grab information from describe\n    key_name = lambda a: \"GIT_DESCRIBE_{}\".format(a)\n    keys = [key_name(\"TAG\"), key_name(\"NUMBER\"), key_name(\"HASH\")]\n    env = {str(key): str(value) for key, value in env.items()}\n    process = Popen([\"git\", \"describe\", \"--tags\", \"--long\", \"HEAD\"],\n                    stdout=PIPE, stderr=PIPE,\n                    env=env)\n    output = process.communicate()[0].strip()\n    output = output.decode('utf-8')\n    parts = output.rsplit('-', 2)\n    parts_length = len(parts)\n    if parts_length == 3:\n        d.update(dict(zip(keys, parts)))\n    # get the _full_ hash of the current HEAD\n    process = Popen([\"git\", \"rev-parse\", \"HEAD\"],\n                    stdout=PIPE, stderr=PIPE, env=env)\n    output = process.communicate()[0].strip()\n    output = output.decode('utf-8')\n    d['GIT_FULL_HASH'] = output\n    # set up the build string\n    if key_name('NUMBER') in d and key_name('HASH') in d:\n        d['GIT_BUILD_STR'] = '{}_{}'.format(d[key_name('NUMBER')],\n                                            d[key_name('HASH')])\n\n    return d\n\n\ndef get_dict(m=None, prefix=None):\n    if not prefix:\n        prefix = config.build_prefix\n\n    python = config.build_python\n    d = {'CONDA_BUILD': '1', 'PYTHONNOUSERSITE': '1'}\n    d['CONDA_DEFAULT_ENV'] = config.build_prefix\n    d['ARCH'] = str(cc.bits)\n    d['PREFIX'] = prefix\n    d['PYTHON'] = python\n    d['PY3K'] = str(config.PY3K)\n    d['STDLIB_DIR'] = get_stdlib_dir()\n    d['SP_DIR'] = get_sp_dir()\n    d['SYS_PREFIX'] = sys.prefix\n    d['SYS_PYTHON'] = sys.executable\n    d['PERL_VER'] = get_perl_ver()\n    d['PY_VER'] = get_py_ver()\n    if get_npy_ver():\n        d['NPY_VER'] = get_npy_ver()\n    d['SRC_DIR'] = source.get_dir()\n    if \"LANG\" in os.environ:\n        d['LANG'] = os.environ['LANG']\n    if \"HTTPS_PROXY\" in os.environ:\n        d['HTTPS_PROXY'] = os.environ['HTTPS_PROXY']\n    if \"HTTP_PROXY\" in os.environ:\n        d['HTTP_PROXY'] = os.environ['HTTP_PROXY']\n\n    if m:\n        for var_name in m.get_value('build/script_env', []):\n            value = os.getenv(var_name)\n            if value is None:\n                warnings.warn(\n                    \"The environment variable '%s' is undefined.\" % var_name,\n                    UserWarning\n                )\n            else:\n                d[var_name] = value\n\n    if sys.platform == \"darwin\":\n        # multiprocessing.cpu_count() is not reliable on OSX\n        # See issue #645 on github.com/conda/conda-build\n        out, err = Popen('sysctl -n hw.logicalcpu', shell=True,\n                         stdout=PIPE).communicate()\n        d['CPU_COUNT'] = out.decode('utf-8').strip()\n    else:\n        try:\n            d['CPU_COUNT'] = str(multiprocessing.cpu_count())\n        except NotImplementedError:\n            d['CPU_COUNT'] = \"1\"\n\n    if m and m.get_value('source/git_url'):\n        git_url = m.get_value('source/git_url')\n        if '://' not in git_url:\n            # If git_url is a relative path instead of a url, convert it to an\n            # abspath\n            if not isabs(git_url):\n                git_url = join(m.path, git_url)\n            git_url = normpath(join(m.path, git_url))\n        d.update(**get_git_build_info(d['SRC_DIR'],\n                                      git_url,\n                                      m.get_value('source/git_rev')))\n\n    d['PATH'] = dict(os.environ)['PATH']\n    d = prepend_bin_path(d, prefix)\n\n    if sys.platform == 'win32':\n        # -------- Windows\n        d['SCRIPTS'] = join(prefix, 'Scripts')\n        d['LIBRARY_PREFIX'] = join(prefix, 'Library')\n        d['LIBRARY_BIN'] = join(d['LIBRARY_PREFIX'], 'bin')\n        d['LIBRARY_INC'] = join(d['LIBRARY_PREFIX'], 'include')\n        d['LIBRARY_LIB'] = join(d['LIBRARY_PREFIX'], 'lib')\n\n        drive, tail = prefix.split(':')\n        d['CYGWIN_PREFIX'] = ''.join(['/cygdrive/', drive.lower(),\n                                     tail.replace('\\\\', '/')])\n\n        d['R'] = join(prefix, 'Scripts', 'R.exe')\n    else:\n        # -------- Unix\n        d['HOME'] = os.getenv('HOME', 'UNKNOWN')\n        d['PKG_CONFIG_PATH'] = join(prefix, 'lib', 'pkgconfig')\n        d['R'] = join(prefix, 'bin', 'R')\n\n    # in case CFLAGS was added in the `script_env` section above\n    cflags = d.get('CFLAGS', '')\n    cxxflags = d.get('CXXFLAGS', '')\n    ldflags = d.get('LDFLAGS', '')\n\n    if sys.platform == 'darwin':\n        # -------- OSX\n        d['OSX_ARCH'] = 'i386' if cc.bits == 32 else 'x86_64'\n        d['CFLAGS'] = cflags + ' -arch %(OSX_ARCH)s' % d\n        d['CXXFLAGS'] = cxxflags + ' -arch %(OSX_ARCH)s' % d\n        rpath = ' -rpath %(PREFIX)s/lib' % d # SIP workaround, DYLD_* no longer works.\n        d['LDFLAGS'] = ldflags + rpath + ' -arch %(OSX_ARCH)s' % d\n        d['MACOSX_DEPLOYMENT_TARGET'] = '10.6'\n\n    elif sys.platform.startswith('linux'):\n        # -------- Linux\n        d['LD_RUN_PATH'] = prefix + '/lib'\n        if cc.bits == 32:\n            d['CFLAGS'] = cflags + ' -m32'\n            d['CXXFLAGS'] = cxxflags + ' -m32'\n\n    if m:\n        d['PKG_NAME'] = m.name()\n        d['PKG_VERSION'] = m.version()\n        d['PKG_BUILDNUM'] = str(m.build_number())\n        d['PKG_BUILD_STRING'] = str(m.build_id())\n        d['RECIPE_DIR'] = m.path\n\n    return d\n\n\nif __name__ == '__main__':\n    e = get_dict()\n    for k in sorted(e):\n        assert isinstance(e[k], str), k\n        print('%s=%s' % (k, e[k]))\n", "path": "conda_build/environ.py"}], "after_files": [{"content": "from __future__ import absolute_import, division, print_function\n\nimport os\nimport sys\nfrom os.path import join, normpath, isabs\nfrom subprocess import STDOUT, check_output, CalledProcessError, Popen, PIPE\nimport multiprocessing\nimport warnings\n\nimport conda.config as cc\n\nfrom conda_build.config import config\n\nfrom conda_build import source\nfrom conda_build.scripts import prepend_bin_path\n\n\ndef get_perl_ver():\n    return str(config.CONDA_PERL)\n\n\ndef get_py_ver():\n    return '.'.join(str(config.CONDA_PY))\n\n\ndef get_npy_ver():\n    if config.CONDA_NPY:\n        # Convert int -> string, e.g.\n        #   17 -> '1.7'\n        #   110 -> '1.10'\n        conda_npy = str(config.CONDA_NPY)\n        return conda_npy[0] + '.' + conda_npy[1:]\n    return ''\n\n\ndef get_stdlib_dir():\n    return join(config.build_prefix, 'Lib' if sys.platform == 'win32' else\n                'lib/python%s' % get_py_ver())\n\n\ndef get_sp_dir():\n    return join(get_stdlib_dir(), 'site-packages')\n\n\ndef get_git_build_info(src_dir, git_url, expected_rev):\n    expected_rev = expected_rev or 'HEAD'\n    env = os.environ.copy()\n    d = {}\n    git_dir = join(src_dir, '.git')\n    if not os.path.exists(git_dir):\n        return d\n\n    env['GIT_DIR'] = git_dir\n    try:\n        # Verify current commit matches expected commit\n        current_commit = check_output([\"git\", \"log\", \"-n1\", \"--format=%H\"],\n                                      env=env, stderr=STDOUT)\n        current_commit = current_commit.decode('utf-8')\n        expected_tag_commit = check_output([\"git\", \"log\", \"-n1\", \"--format=%H\",\n                                            expected_rev],\n                                           env=env, stderr=STDOUT)\n        expected_tag_commit = expected_tag_commit.decode('utf-8')\n\n        # Verify correct remote url. Need to find the git cache directory,\n        # and check the remote from there.\n        cache_details = check_output([\"git\", \"remote\", \"-v\"], env=env,\n                                     stderr=STDOUT)\n        cache_details = cache_details.decode('utf-8')\n        cache_dir = cache_details.split('\\n')[0].split()[1]\n        assert \"conda-bld/git_cache\" in cache_dir\n\n        env['GIT_DIR'] = cache_dir\n        remote_details = check_output([\"git\", \"remote\", \"-v\"], env=env,\n                                      stderr=STDOUT)\n        remote_details = remote_details.decode('utf-8')\n        remote_url = remote_details.split('\\n')[0].split()[1]\n        if '://' not in remote_url:\n            # Local filepaths are allowed, but make sure we normalize them\n            remote_url = normpath(remote_url)\n\n        # If the current source directory in conda-bld/work doesn't match the\n        # user's metadata git_url or git_rev, then we aren't looking at the\n        # right source.\n        if remote_url != git_url or current_commit != expected_tag_commit:\n            return d\n    except CalledProcessError:\n        return d\n\n    env['GIT_DIR'] = git_dir\n\n    # grab information from describe\n    key_name = lambda a: \"GIT_DESCRIBE_{}\".format(a)\n    keys = [key_name(\"TAG\"), key_name(\"NUMBER\"), key_name(\"HASH\")]\n    env = {str(key): str(value) for key, value in env.items()}\n    process = Popen([\"git\", \"describe\", \"--tags\", \"--long\", \"HEAD\"],\n                    stdout=PIPE, stderr=PIPE,\n                    env=env)\n    output = process.communicate()[0].strip()\n    output = output.decode('utf-8')\n    parts = output.rsplit('-', 2)\n    parts_length = len(parts)\n    if parts_length == 3:\n        d.update(dict(zip(keys, parts)))\n    # get the _full_ hash of the current HEAD\n    process = Popen([\"git\", \"rev-parse\", \"HEAD\"],\n                    stdout=PIPE, stderr=PIPE, env=env)\n    output = process.communicate()[0].strip()\n    output = output.decode('utf-8')\n    d['GIT_FULL_HASH'] = output\n    # set up the build string\n    if key_name('NUMBER') in d and key_name('HASH') in d:\n        d['GIT_BUILD_STR'] = '{}_{}'.format(d[key_name('NUMBER')],\n                                            d[key_name('HASH')])\n\n    return d\n\n\ndef get_dict(m=None, prefix=None):\n    if not prefix:\n        prefix = config.build_prefix\n\n    python = config.build_python\n    d = {'CONDA_BUILD': '1', 'PYTHONNOUSERSITE': '1'}\n    d['CONDA_DEFAULT_ENV'] = config.build_prefix\n    d['ARCH'] = str(cc.bits)\n    d['PREFIX'] = prefix\n    d['PYTHON'] = python\n    d['PY3K'] = str(config.PY3K)\n    d['STDLIB_DIR'] = get_stdlib_dir()\n    d['SP_DIR'] = get_sp_dir()\n    d['SYS_PREFIX'] = sys.prefix\n    d['SYS_PYTHON'] = sys.executable\n    d['PERL_VER'] = get_perl_ver()\n    d['PY_VER'] = get_py_ver()\n    if get_npy_ver():\n        d['NPY_VER'] = get_npy_ver()\n    d['SRC_DIR'] = source.get_dir()\n    if \"LANG\" in os.environ:\n        d['LANG'] = os.environ['LANG']\n    if \"HTTPS_PROXY\" in os.environ:\n        d['HTTPS_PROXY'] = os.environ['HTTPS_PROXY']\n    if \"HTTP_PROXY\" in os.environ:\n        d['HTTP_PROXY'] = os.environ['HTTP_PROXY']\n\n    if m:\n        for var_name in m.get_value('build/script_env', []):\n            value = os.getenv(var_name)\n            if value is None:\n                warnings.warn(\n                    \"The environment variable '%s' is undefined.\" % var_name,\n                    UserWarning\n                )\n            else:\n                d[var_name] = value\n\n    if sys.platform == \"darwin\":\n        # multiprocessing.cpu_count() is not reliable on OSX\n        # See issue #645 on github.com/conda/conda-build\n        out, err = Popen('sysctl -n hw.logicalcpu', shell=True,\n                         stdout=PIPE).communicate()\n        d['CPU_COUNT'] = out.decode('utf-8').strip()\n    else:\n        try:\n            d['CPU_COUNT'] = str(multiprocessing.cpu_count())\n        except NotImplementedError:\n            d['CPU_COUNT'] = \"1\"\n\n    if m and m.get_value('source/git_url'):\n        git_url = m.get_value('source/git_url')\n        if '://' not in git_url:\n            # If git_url is a relative path instead of a url, convert it to an\n            # abspath\n            if not isabs(git_url):\n                git_url = join(m.path, git_url)\n            git_url = normpath(join(m.path, git_url))\n        d.update(**get_git_build_info(d['SRC_DIR'],\n                                      git_url,\n                                      m.get_value('source/git_rev')))\n\n    d['PATH'] = dict(os.environ)['PATH']\n    d = prepend_bin_path(d, prefix)\n\n    if sys.platform == 'win32':\n        # -------- Windows\n        d['SCRIPTS'] = join(prefix, 'Scripts')\n        d['LIBRARY_PREFIX'] = join(prefix, 'Library')\n        d['LIBRARY_BIN'] = join(d['LIBRARY_PREFIX'], 'bin')\n        d['LIBRARY_INC'] = join(d['LIBRARY_PREFIX'], 'include')\n        d['LIBRARY_LIB'] = join(d['LIBRARY_PREFIX'], 'lib')\n\n        drive, tail = prefix.split(':')\n        d['CYGWIN_PREFIX'] = ''.join(['/cygdrive/', drive.lower(),\n                                     tail.replace('\\\\', '/')])\n\n        d['R'] = join(prefix, 'Scripts', 'R.exe')\n    else:\n        # -------- Unix\n        d['HOME'] = os.getenv('HOME', 'UNKNOWN')\n        d['PKG_CONFIG_PATH'] = join(prefix, 'lib', 'pkgconfig')\n        d['R'] = join(prefix, 'bin', 'R')\n\n    # in case CFLAGS was added in the `script_env` section above\n    cflags = d.get('CFLAGS', '')\n    cxxflags = d.get('CXXFLAGS', '')\n    ldflags = d.get('LDFLAGS', '')\n\n    if sys.platform == 'darwin':\n        # -------- OSX\n        d['OSX_ARCH'] = 'i386' if cc.bits == 32 else 'x86_64'\n        d['CFLAGS'] = cflags + ' -arch %(OSX_ARCH)s' % d\n        d['CXXFLAGS'] = cxxflags + ' -arch %(OSX_ARCH)s' % d\n        rpath = ' -Wl,-rpath,%(PREFIX)s/lib' % d # SIP workaround, DYLD_* no longer works.\n        d['LDFLAGS'] = ldflags + rpath + ' -arch %(OSX_ARCH)s' % d\n        d['MACOSX_DEPLOYMENT_TARGET'] = '10.6'\n\n    elif sys.platform.startswith('linux'):\n        # -------- Linux\n        d['LD_RUN_PATH'] = prefix + '/lib'\n        if cc.bits == 32:\n            d['CFLAGS'] = cflags + ' -m32'\n            d['CXXFLAGS'] = cxxflags + ' -m32'\n\n    if m:\n        d['PKG_NAME'] = m.name()\n        d['PKG_VERSION'] = m.version()\n        d['PKG_BUILDNUM'] = str(m.build_number())\n        d['PKG_BUILD_STRING'] = str(m.build_id())\n        d['RECIPE_DIR'] = m.path\n\n    return d\n\n\nif __name__ == '__main__':\n    e = get_dict()\n    for k in sorted(e):\n        assert isinstance(e[k], str), k\n        print('%s=%s' % (k, e[k]))\n", "path": "conda_build/environ.py"}]}