We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Permission denied when testing a python tool.
Hi,

I am getting an unexpected permission denied error when trying to test a conda build for a tool I wish to include in bioconda.
The error:
```
dotknot.py sample.fasta
~/miniconda2/conda-bld/dotknot_1499267085047/test_tmp/run_test.sh: line 3: ~/miniconda2/conda-bld/dotknot_1499267085047/_t_env/bin/dotknot.py: Permission denied
TESTS FAILED: dotknot-1.3.2-py_0.tar.bz2
```


The following are my `meta.yaml` and `build.sh` (can also be found at https://github.com/HassanAmr/bioconda-recipes/tree/dotknot/recipes/dotknot):
`meta.yaml`
```
package:
  name: dotknot
  version: 1.3.2

build:
  number: 0
  noarch: python

source:
  url: http://dotknot.csse.uwa.edu.au/DotKnot_1.3.2.tar.gz
  md5: caf6dbf3559c699d98b5289983f43b2d
  patches:
    - dotknot.patch

requirements:
  build:
    - python
    - setuptools

  run:
    - python
    - viennarna ==1.8.5

test:
  commands:
    - printf '>sample\nacgtcgttgtgt\n' > sample.fasta && dotknot.py sample.fasta

about:
  home: http://dotknot.csse.uwa.edu.au/
  license: GNU GPL v3
  license_file: COPYING.FILE
  summary: DotKnot is a heuristic method for pseudoknot prediction in a given RNA sequence.
```

`build.sh`
```
#!/bin/bash
cp src/*.py $PREFIX/bin
cp src/stacking_only.par $PREFIX/bin

chmod +x $PREFIX/bin/BPs_to_CT.py
chmod +x $PREFIX/bin/cc06.py
chmod +x $PREFIX/bin/cc09.py
chmod +x $PREFIX/bin/dotknot.py
chmod +x $PREFIX/bin/functions.py
chmod +x $PREFIX/bin/kissing_hairpins.py
chmod +x $PREFIX/bin/longPK.py
chmod +x $PREFIX/bin/mwis_2d.py
chmod +x $PREFIX/bin/mwis.py
chmod +x $PREFIX/bin/pk_construction.py
chmod +x $PREFIX/bin/pk_energy.py
chmod +x $PREFIX/bin/pk_interrupted.py
chmod +x $PREFIX/bin/pk_recursive.py
chmod +x $PREFIX/bin/pk_tools.py
chmod +x $PREFIX/bin/secondary_elements.py
chmod +x $PREFIX/bin/stems.py
chmod +x $PREFIX/bin/user.py
```

Any help regarding this matter is greatly appreciated.
Thanks.


--- 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/noarch_python.py`
Content:
```
1 import io
2 import json
3 import locale
4 import logging
5 import os
6 from os.path import basename, dirname, isdir, join, isfile
7 import shutil
8 import sys
9 
10 ISWIN = sys.platform.startswith('win')
11 
12 
13 def _force_dir(dirname):
14     if not isdir(dirname):
15         os.makedirs(dirname)
16 
17 
18 def _error_exit(exit_message):
19     sys.exit("[noarch_python] %s" % exit_message)
20 
21 
22 def rewrite_script(fn, prefix):
23     """Take a file from the bin directory and rewrite it into the python-scripts
24     directory after it passes some sanity checks for noarch pacakges"""
25 
26     # Load and check the source file for not being a binary
27     src = join(prefix, 'Scripts' if ISWIN else 'bin', fn)
28     with io.open(src, encoding=locale.getpreferredencoding()) as fi:
29         try:
30             data = fi.read()
31         except UnicodeDecodeError:  # file is binary
32             _error_exit("Noarch package contains binary script: %s" % fn)
33     os.unlink(src)
34 
35     # Get rid of '-script.py' suffix on Windows
36     if ISWIN and fn.endswith('-script.py'):
37         fn = fn[:-10]
38 
39     # Rewrite the file to the python-scripts directory
40     dst_dir = join(prefix, 'python-scripts')
41     _force_dir(dst_dir)
42     with open(join(dst_dir, fn), 'w') as fo:
43         fo.write(data)
44     return fn
45 
46 
47 def handle_file(f, d, prefix):
48     """Process a file for inclusion in a noarch python package.
49     """
50     path = join(prefix, f)
51 
52     # Ignore egg-info and pyc files.
53     if f.endswith(('.egg-info', '.pyc', '.pyo')):
54         os.unlink(path)
55 
56     # The presence of .so indicated this is not a noarch package
57     elif f.endswith(('.so', '.dll', '.pyd', '.exe', '.dylib')):
58         if f.endswith('.exe') and (isfile(os.path.join(prefix, f[:-4] + '-script.py')) or
59                                    basename(f[:-4]) in d['python-scripts']):
60             os.unlink(path)  # this is an entry point with a matching xx-script.py
61             return
62         _error_exit("Error: Binary library or executable found: %s" % f)
63 
64     elif 'site-packages' in f:
65         nsp = join(prefix, 'site-packages')
66         _force_dir(nsp)
67 
68         g = f[f.find('site-packages'):]
69         dst = join(prefix, g)
70         dst_dir = dirname(dst)
71         _force_dir(dst_dir)
72         os.rename(path, dst)
73         d['site-packages'].append(g[14:])
74 
75     # Treat scripts specially with the logic from above
76     elif f.startswith(('bin/', 'Scripts')):
77         fn = basename(path)
78         fn = rewrite_script(fn, prefix)
79         d['python-scripts'].append(fn)
80 
81     # Include examples in the metadata doc
82     elif f.startswith(('Examples/', 'Examples\\')):
83         d['Examples'].append(f[9:])
84     else:
85         log = logging.getLogger(__name__)
86         log.warn("Don't know how to handle file: %s.  Omitting it from package." % f)
87         os.unlink(path)
88 
89 
90 def populate_files(m, files, prefix, entry_point_scripts=None):
91     d = {'dist': m.dist(),
92          'site-packages': [],
93          'python-scripts': [],
94          'Examples': []}
95 
96     # Populate site-package, python-scripts, and Examples into above
97     for f in files:
98         handle_file(f, d, prefix)
99 
100     # Windows path conversion
101     if ISWIN:
102         for fns in (d['site-packages'], d['Examples']):
103             for i, fn in enumerate(fns):
104                 fns[i] = fn.replace('\\', '/')
105 
106     if entry_point_scripts:
107         for entry_point in entry_point_scripts:
108             src = join(prefix, entry_point)
109             os.unlink(src)
110 
111     return d
112 
113 
114 def transform(m, files, prefix):
115     bin_dir = join(prefix, 'bin')
116     _force_dir(bin_dir)
117 
118     scripts_dir = join(prefix, 'Scripts')
119     _force_dir(scripts_dir)
120 
121     name = m.name()
122 
123     # Create *nix prelink script
124     # Note: it's important to use LF newlines or it wont work if we build on Win
125     with open(join(bin_dir, '.%s-pre-link.sh' % name), 'wb') as fo:
126         fo.write('''\
127     #!/bin/bash
128     $PREFIX/bin/python $SOURCE_DIR/link.py
129     '''.encode('utf-8'))
130 
131     # Create windows prelink script (be nice and use Windows newlines)
132     with open(join(scripts_dir, '.%s-pre-link.bat' % name), 'wb') as fo:
133         fo.write('''\
134     @echo off
135     "%PREFIX%\\python.exe" "%SOURCE_DIR%\\link.py"
136     '''.replace('\n', '\r\n').encode('utf-8'))
137 
138     d = populate_files(m, files, prefix)
139 
140     # Find our way to this directory
141     this_dir = dirname(__file__)
142 
143     # copy in windows exe shims if there are any python-scripts
144     if d['python-scripts']:
145         for fn in 'cli-32.exe', 'cli-64.exe':
146             shutil.copyfile(join(this_dir, fn), join(prefix, fn))
147 
148     # Read the local _link.py
149     with open(join(this_dir, '_link.py')) as fi:
150         link_code = fi.read()
151 
152     # Write the package metadata, and bumper with code for linking
153     with open(join(prefix, 'link.py'), 'w') as fo:
154         fo.write('DATA = ')
155         json.dump(d, fo, indent=2, sort_keys=True)
156         fo.write('\n## END DATA\n\n')
157         fo.write(link_code)
158
```
--- 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/noarch_python.py b/conda_build/noarch_python.py
--- a/conda_build/noarch_python.py
+++ b/conda_build/noarch_python.py
@@ -21,7 +21,8 @@
 
 def rewrite_script(fn, prefix):
     """Take a file from the bin directory and rewrite it into the python-scripts
-    directory after it passes some sanity checks for noarch pacakges"""
+    directory with the same permissions after it passes some sanity checks for
+    noarch pacakges"""
 
     # Load and check the source file for not being a binary
     src = join(prefix, 'Scripts' if ISWIN else 'bin', fn)
@@ -30,6 +31,7 @@
             data = fi.read()
         except UnicodeDecodeError:  # file is binary
             _error_exit("Noarch package contains binary script: %s" % fn)
+    src_mode = os.stat(src).st_mode
     os.unlink(src)
 
     # Get rid of '-script.py' suffix on Windows
@@ -39,8 +41,10 @@
     # Rewrite the file to the python-scripts directory
     dst_dir = join(prefix, 'python-scripts')
     _force_dir(dst_dir)
-    with open(join(dst_dir, fn), 'w') as fo:
+    dst = join(dst_dir, fn)
+    with open(dst, 'w') as fo:
         fo.write(data)
+    os.chmod(dst, src_mode)
     return fn

{"golden_diff": "diff --git a/conda_build/noarch_python.py b/conda_build/noarch_python.py\n--- a/conda_build/noarch_python.py\n+++ b/conda_build/noarch_python.py\n@@ -21,7 +21,8 @@\n \n def rewrite_script(fn, prefix):\n     \"\"\"Take a file from the bin directory and rewrite it into the python-scripts\n-    directory after it passes some sanity checks for noarch pacakges\"\"\"\n+    directory with the same permissions after it passes some sanity checks for\n+    noarch pacakges\"\"\"\n \n     # Load and check the source file for not being a binary\n     src = join(prefix, 'Scripts' if ISWIN else 'bin', fn)\n@@ -30,6 +31,7 @@\n             data = fi.read()\n         except UnicodeDecodeError:  # file is binary\n             _error_exit(\"Noarch package contains binary script: %s\" % fn)\n+    src_mode = os.stat(src).st_mode\n     os.unlink(src)\n \n     # Get rid of '-script.py' suffix on Windows\n@@ -39,8 +41,10 @@\n     # Rewrite the file to the python-scripts directory\n     dst_dir = join(prefix, 'python-scripts')\n     _force_dir(dst_dir)\n-    with open(join(dst_dir, fn), 'w') as fo:\n+    dst = join(dst_dir, fn)\n+    with open(dst, 'w') as fo:\n         fo.write(data)\n+    os.chmod(dst, src_mode)\n     return fn\n", "issue": "Permission denied when testing a python tool.\nHi,\r\n\r\nI am getting an unexpected permission denied error when trying to test a conda build for a tool I wish to include in bioconda.\r\nThe error:\r\n```\r\ndotknot.py sample.fasta\r\n~/miniconda2/conda-bld/dotknot_1499267085047/test_tmp/run_test.sh: line 3: ~/miniconda2/conda-bld/dotknot_1499267085047/_t_env/bin/dotknot.py: Permission denied\r\nTESTS FAILED: dotknot-1.3.2-py_0.tar.bz2\r\n```\r\n\r\n\r\nThe following are my `meta.yaml` and `build.sh` (can also be found at https://github.com/HassanAmr/bioconda-recipes/tree/dotknot/recipes/dotknot):\r\n`meta.yaml`\r\n```\r\npackage:\r\n  name: dotknot\r\n  version: 1.3.2\r\n\r\nbuild:\r\n  number: 0\r\n  noarch: python\r\n\r\nsource:\r\n  url: http://dotknot.csse.uwa.edu.au/DotKnot_1.3.2.tar.gz\r\n  md5: caf6dbf3559c699d98b5289983f43b2d\r\n  patches:\r\n    - dotknot.patch\r\n\r\nrequirements:\r\n  build:\r\n    - python\r\n    - setuptools\r\n\r\n  run:\r\n    - python\r\n    - viennarna ==1.8.5\r\n\r\ntest:\r\n  commands:\r\n    - printf '>sample\\nacgtcgttgtgt\\n' > sample.fasta && dotknot.py sample.fasta\r\n\r\nabout:\r\n  home: http://dotknot.csse.uwa.edu.au/\r\n  license: GNU GPL v3\r\n  license_file: COPYING.FILE\r\n  summary: DotKnot is a heuristic method for pseudoknot prediction in a given RNA sequence.\r\n```\r\n\r\n`build.sh`\r\n```\r\n#!/bin/bash\r\ncp src/*.py $PREFIX/bin\r\ncp src/stacking_only.par $PREFIX/bin\r\n\r\nchmod +x $PREFIX/bin/BPs_to_CT.py\r\nchmod +x $PREFIX/bin/cc06.py\r\nchmod +x $PREFIX/bin/cc09.py\r\nchmod +x $PREFIX/bin/dotknot.py\r\nchmod +x $PREFIX/bin/functions.py\r\nchmod +x $PREFIX/bin/kissing_hairpins.py\r\nchmod +x $PREFIX/bin/longPK.py\r\nchmod +x $PREFIX/bin/mwis_2d.py\r\nchmod +x $PREFIX/bin/mwis.py\r\nchmod +x $PREFIX/bin/pk_construction.py\r\nchmod +x $PREFIX/bin/pk_energy.py\r\nchmod +x $PREFIX/bin/pk_interrupted.py\r\nchmod +x $PREFIX/bin/pk_recursive.py\r\nchmod +x $PREFIX/bin/pk_tools.py\r\nchmod +x $PREFIX/bin/secondary_elements.py\r\nchmod +x $PREFIX/bin/stems.py\r\nchmod +x $PREFIX/bin/user.py\r\n```\r\n\r\nAny help regarding this matter is greatly appreciated.\r\nThanks.\r\n\n", "before_files": [{"content": "import io\nimport json\nimport locale\nimport logging\nimport os\nfrom os.path import basename, dirname, isdir, join, isfile\nimport shutil\nimport sys\n\nISWIN = sys.platform.startswith('win')\n\n\ndef _force_dir(dirname):\n    if not isdir(dirname):\n        os.makedirs(dirname)\n\n\ndef _error_exit(exit_message):\n    sys.exit(\"[noarch_python] %s\" % exit_message)\n\n\ndef rewrite_script(fn, prefix):\n    \"\"\"Take a file from the bin directory and rewrite it into the python-scripts\n    directory after it passes some sanity checks for noarch pacakges\"\"\"\n\n    # Load and check the source file for not being a binary\n    src = join(prefix, 'Scripts' if ISWIN else 'bin', fn)\n    with io.open(src, encoding=locale.getpreferredencoding()) as fi:\n        try:\n            data = fi.read()\n        except UnicodeDecodeError:  # file is binary\n            _error_exit(\"Noarch package contains binary script: %s\" % fn)\n    os.unlink(src)\n\n    # Get rid of '-script.py' suffix on Windows\n    if ISWIN and fn.endswith('-script.py'):\n        fn = fn[:-10]\n\n    # Rewrite the file to the python-scripts directory\n    dst_dir = join(prefix, 'python-scripts')\n    _force_dir(dst_dir)\n    with open(join(dst_dir, fn), 'w') as fo:\n        fo.write(data)\n    return fn\n\n\ndef handle_file(f, d, prefix):\n    \"\"\"Process a file for inclusion in a noarch python package.\n    \"\"\"\n    path = join(prefix, f)\n\n    # Ignore egg-info and pyc files.\n    if f.endswith(('.egg-info', '.pyc', '.pyo')):\n        os.unlink(path)\n\n    # The presence of .so indicated this is not a noarch package\n    elif f.endswith(('.so', '.dll', '.pyd', '.exe', '.dylib')):\n        if f.endswith('.exe') and (isfile(os.path.join(prefix, f[:-4] + '-script.py')) or\n                                   basename(f[:-4]) in d['python-scripts']):\n            os.unlink(path)  # this is an entry point with a matching xx-script.py\n            return\n        _error_exit(\"Error: Binary library or executable found: %s\" % f)\n\n    elif 'site-packages' in f:\n        nsp = join(prefix, 'site-packages')\n        _force_dir(nsp)\n\n        g = f[f.find('site-packages'):]\n        dst = join(prefix, g)\n        dst_dir = dirname(dst)\n        _force_dir(dst_dir)\n        os.rename(path, dst)\n        d['site-packages'].append(g[14:])\n\n    # Treat scripts specially with the logic from above\n    elif f.startswith(('bin/', 'Scripts')):\n        fn = basename(path)\n        fn = rewrite_script(fn, prefix)\n        d['python-scripts'].append(fn)\n\n    # Include examples in the metadata doc\n    elif f.startswith(('Examples/', 'Examples\\\\')):\n        d['Examples'].append(f[9:])\n    else:\n        log = logging.getLogger(__name__)\n        log.warn(\"Don't know how to handle file: %s.  Omitting it from package.\" % f)\n        os.unlink(path)\n\n\ndef populate_files(m, files, prefix, entry_point_scripts=None):\n    d = {'dist': m.dist(),\n         'site-packages': [],\n         'python-scripts': [],\n         'Examples': []}\n\n    # Populate site-package, python-scripts, and Examples into above\n    for f in files:\n        handle_file(f, d, prefix)\n\n    # Windows path conversion\n    if ISWIN:\n        for fns in (d['site-packages'], d['Examples']):\n            for i, fn in enumerate(fns):\n                fns[i] = fn.replace('\\\\', '/')\n\n    if entry_point_scripts:\n        for entry_point in entry_point_scripts:\n            src = join(prefix, entry_point)\n            os.unlink(src)\n\n    return d\n\n\ndef transform(m, files, prefix):\n    bin_dir = join(prefix, 'bin')\n    _force_dir(bin_dir)\n\n    scripts_dir = join(prefix, 'Scripts')\n    _force_dir(scripts_dir)\n\n    name = m.name()\n\n    # Create *nix prelink script\n    # Note: it's important to use LF newlines or it wont work if we build on Win\n    with open(join(bin_dir, '.%s-pre-link.sh' % name), 'wb') as fo:\n        fo.write('''\\\n    #!/bin/bash\n    $PREFIX/bin/python $SOURCE_DIR/link.py\n    '''.encode('utf-8'))\n\n    # Create windows prelink script (be nice and use Windows newlines)\n    with open(join(scripts_dir, '.%s-pre-link.bat' % name), 'wb') as fo:\n        fo.write('''\\\n    @echo off\n    \"%PREFIX%\\\\python.exe\" \"%SOURCE_DIR%\\\\link.py\"\n    '''.replace('\\n', '\\r\\n').encode('utf-8'))\n\n    d = populate_files(m, files, prefix)\n\n    # Find our way to this directory\n    this_dir = dirname(__file__)\n\n    # copy in windows exe shims if there are any python-scripts\n    if d['python-scripts']:\n        for fn in 'cli-32.exe', 'cli-64.exe':\n            shutil.copyfile(join(this_dir, fn), join(prefix, fn))\n\n    # Read the local _link.py\n    with open(join(this_dir, '_link.py')) as fi:\n        link_code = fi.read()\n\n    # Write the package metadata, and bumper with code for linking\n    with open(join(prefix, 'link.py'), 'w') as fo:\n        fo.write('DATA = ')\n        json.dump(d, fo, indent=2, sort_keys=True)\n        fo.write('\\n## END DATA\\n\\n')\n        fo.write(link_code)\n", "path": "conda_build/noarch_python.py"}], "after_files": [{"content": "import io\nimport json\nimport locale\nimport logging\nimport os\nfrom os.path import basename, dirname, isdir, join, isfile\nimport shutil\nimport sys\n\nISWIN = sys.platform.startswith('win')\n\n\ndef _force_dir(dirname):\n    if not isdir(dirname):\n        os.makedirs(dirname)\n\n\ndef _error_exit(exit_message):\n    sys.exit(\"[noarch_python] %s\" % exit_message)\n\n\ndef rewrite_script(fn, prefix):\n    \"\"\"Take a file from the bin directory and rewrite it into the python-scripts\n    directory with the same permissions after it passes some sanity checks for\n    noarch pacakges\"\"\"\n\n    # Load and check the source file for not being a binary\n    src = join(prefix, 'Scripts' if ISWIN else 'bin', fn)\n    with io.open(src, encoding=locale.getpreferredencoding()) as fi:\n        try:\n            data = fi.read()\n        except UnicodeDecodeError:  # file is binary\n            _error_exit(\"Noarch package contains binary script: %s\" % fn)\n    src_mode = os.stat(src).st_mode\n    os.unlink(src)\n\n    # Get rid of '-script.py' suffix on Windows\n    if ISWIN and fn.endswith('-script.py'):\n        fn = fn[:-10]\n\n    # Rewrite the file to the python-scripts directory\n    dst_dir = join(prefix, 'python-scripts')\n    _force_dir(dst_dir)\n    dst = join(dst_dir, fn)\n    with open(dst, 'w') as fo:\n        fo.write(data)\n    os.chmod(dst, src_mode)\n    return fn\n\n\ndef handle_file(f, d, prefix):\n    \"\"\"Process a file for inclusion in a noarch python package.\n    \"\"\"\n    path = join(prefix, f)\n\n    # Ignore egg-info and pyc files.\n    if f.endswith(('.egg-info', '.pyc', '.pyo')):\n        os.unlink(path)\n\n    # The presence of .so indicated this is not a noarch package\n    elif f.endswith(('.so', '.dll', '.pyd', '.exe', '.dylib')):\n        if f.endswith('.exe') and (isfile(os.path.join(prefix, f[:-4] + '-script.py')) or\n                                   basename(f[:-4]) in d['python-scripts']):\n            os.unlink(path)  # this is an entry point with a matching xx-script.py\n            return\n        _error_exit(\"Error: Binary library or executable found: %s\" % f)\n\n    elif 'site-packages' in f:\n        nsp = join(prefix, 'site-packages')\n        _force_dir(nsp)\n\n        g = f[f.find('site-packages'):]\n        dst = join(prefix, g)\n        dst_dir = dirname(dst)\n        _force_dir(dst_dir)\n        os.rename(path, dst)\n        d['site-packages'].append(g[14:])\n\n    # Treat scripts specially with the logic from above\n    elif f.startswith(('bin/', 'Scripts')):\n        fn = basename(path)\n        fn = rewrite_script(fn, prefix)\n        d['python-scripts'].append(fn)\n\n    # Include examples in the metadata doc\n    elif f.startswith(('Examples/', 'Examples\\\\')):\n        d['Examples'].append(f[9:])\n    else:\n        log = logging.getLogger(__name__)\n        log.warn(\"Don't know how to handle file: %s.  Omitting it from package.\" % f)\n        os.unlink(path)\n\n\ndef populate_files(m, files, prefix, entry_point_scripts=None):\n    d = {'dist': m.dist(),\n         'site-packages': [],\n         'python-scripts': [],\n         'Examples': []}\n\n    # Populate site-package, python-scripts, and Examples into above\n    for f in files:\n        handle_file(f, d, prefix)\n\n    # Windows path conversion\n    if ISWIN:\n        for fns in (d['site-packages'], d['Examples']):\n            for i, fn in enumerate(fns):\n                fns[i] = fn.replace('\\\\', '/')\n\n    if entry_point_scripts:\n        for entry_point in entry_point_scripts:\n            src = join(prefix, entry_point)\n            os.unlink(src)\n\n    return d\n\n\ndef transform(m, files, prefix):\n    bin_dir = join(prefix, 'bin')\n    _force_dir(bin_dir)\n\n    scripts_dir = join(prefix, 'Scripts')\n    _force_dir(scripts_dir)\n\n    name = m.name()\n\n    # Create *nix prelink script\n    # Note: it's important to use LF newlines or it wont work if we build on Win\n    with open(join(bin_dir, '.%s-pre-link.sh' % name), 'wb') as fo:\n        fo.write('''\\\n    #!/bin/bash\n    $PREFIX/bin/python $SOURCE_DIR/link.py\n    '''.encode('utf-8'))\n\n    # Create windows prelink script (be nice and use Windows newlines)\n    with open(join(scripts_dir, '.%s-pre-link.bat' % name), 'wb') as fo:\n        fo.write('''\\\n    @echo off\n    \"%PREFIX%\\\\python.exe\" \"%SOURCE_DIR%\\\\link.py\"\n    '''.replace('\\n', '\\r\\n').encode('utf-8'))\n\n    d = populate_files(m, files, prefix)\n\n    # Find our way to this directory\n    this_dir = dirname(__file__)\n\n    # copy in windows exe shims if there are any python-scripts\n    if d['python-scripts']:\n        for fn in 'cli-32.exe', 'cli-64.exe':\n            shutil.copyfile(join(this_dir, fn), join(prefix, fn))\n\n    # Read the local _link.py\n    with open(join(this_dir, '_link.py')) as fi:\n        link_code = fi.read()\n\n    # Write the package metadata, and bumper with code for linking\n    with open(join(prefix, 'link.py'), 'w') as fo:\n        fo.write('DATA = ')\n        json.dump(d, fo, indent=2, sort_keys=True)\n        fo.write('\\n## END DATA\\n\\n')\n        fo.write(link_code)\n", "path": "conda_build/noarch_python.py"}]}