We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
allow overriding the .so check for noarch: python?
`compas` is a pure-python package that could be made `noarch: python` except that it [ships some `.so` and `.dll` files](https://github.com/compas-dev/compas/tree/master/src/compas/numerical/fd/__fd_cpp) (that it doesn't compile, so they're the same across platforms). That's triggering [this check](https://github.com/conda/conda-build/blob/19f5d7847ee8a4c5b979680595103fa6cc21e4b1/conda_build/noarch_python.py#L60-L66) and killing the build ([PR](https://github.com/conda-forge/compas-feedstock/pull/6#issuecomment-429024394), [failed build](https://circleci.com/gh/conda-forge/compas-feedstock/37?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link)).

The check definitely makes sense in general. But maybe there should be a way to override it for cases like this?

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

{"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@@ -57,13 +57,10 @@\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+    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 \n     elif 'site-packages' in f:\n         nsp = join(prefix, 'site-packages')\n", "issue": "allow overriding the .so check for noarch: python?\n`compas` is a pure-python package that could be made `noarch: python` except that it [ships some `.so` and `.dll` files](https://github.com/compas-dev/compas/tree/master/src/compas/numerical/fd/__fd_cpp) (that it doesn't compile, so they're the same across platforms). That's triggering [this check](https://github.com/conda/conda-build/blob/19f5d7847ee8a4c5b979680595103fa6cc21e4b1/conda_build/noarch_python.py#L60-L66) and killing the build ([PR](https://github.com/conda-forge/compas-feedstock/pull/6#issuecomment-429024394), [failed build](https://circleci.com/gh/conda-forge/compas-feedstock/37?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link)).\r\n\r\nThe check definitely makes sense in general. But maybe there should be a way to override it for cases like this?\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 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        shutil.move(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    # No special treatment for other files\n    # leave them as-is\n    else:\n        # this should be the built-in logging module, not conda-build's stuff, because this file is standalone.\n        log = logging.getLogger(__name__)\n        log.debug(\"Don't know how to handle file: %s.  Including it as-is.\" % f)\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            if os.path.isfile(src):\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    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\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        shutil.move(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    # No special treatment for other files\n    # leave them as-is\n    else:\n        # this should be the built-in logging module, not conda-build's stuff, because this file is standalone.\n        log = logging.getLogger(__name__)\n        log.debug(\"Don't know how to handle file: %s.  Including it as-is.\" % f)\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            if os.path.isfile(src):\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"}]}