We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Linux support in AppVeyor
FYI
https://www.appveyor.com/blog/2018/03/06/appveyor-for-linux/
https://www.appveyor.com/blog/2018/05/15/appveyor-for-linux-is-generally-available/
https://www.appveyor.com/docs/getting-started-with-appveyor-for-linux/

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `cibuildwheel/__main__.py`
Content:
```
1 from __future__ import print_function
2 import argparse, os, subprocess, sys, textwrap
3 
4 import cibuildwheel
5 import cibuildwheel.linux, cibuildwheel.windows, cibuildwheel.macos
6 from cibuildwheel.environment import parse_environment, EnvironmentParseError
7 from cibuildwheel.util import BuildSelector, Unbuffered
8 
9 def get_option_from_environment(option_name, platform=None, default=None):
10     '''
11     Returns an option from the environment, optionally scoped by the platform.
12 
13     Example:
14       get_option_from_environment('CIBW_COLOR', platform='macos')
15 
16       This will return the value of CIBW_COLOR_MACOS if it exists, otherwise the value of
17       CIBW_COLOR.
18     '''
19     if platform:
20         option = os.environ.get('%s_%s' % (option_name, platform.upper()))
21         if option is not None:
22             return option
23 
24     return os.environ.get(option_name, default)
25 
26 
27 def main():
28     parser = argparse.ArgumentParser(
29         description='Build wheels for all the platforms.',
30         epilog=('Most options are supplied via environment variables. '
31                 'See https://github.com/joerick/cibuildwheel#options for info.'))
32 
33     parser.add_argument('--platform',
34                         choices=['auto', 'linux', 'macos', 'windows'],
35                         default=os.environ.get('CIBW_PLATFORM', 'auto'),
36                         help=('Platform to build for. For "linux" you need docker running, on Mac '
37                               'or Linux. For "macos", you need a Mac machine, and note that this '
38                               'script is going to automatically install MacPython on your system, '
39                               'so don\'t run on your development machine. For "windows", you need to '
40                               'run in Windows, and it will build and test for all versions of '
41                               'Python at C:\\PythonXX[-x64]. Default: auto.'))
42     parser.add_argument('--output-dir',
43                         default=os.environ.get('CIBW_OUTPUT_DIR', 'wheelhouse'),
44                         help='Destination folder for the wheels.')
45     parser.add_argument('project_dir',
46                         default='.',
47                         nargs='?',
48                         help=('Path to the project that you want wheels for. Default: the current '
49                               'directory.'))
50 
51     parser.add_argument('--print-build-identifiers',
52                         action='store_true',
53                         help='Print the build identifiers matched by the current invocation and exit.')
54 
55     args = parser.parse_args()
56 
57     detect_obsolete_options()
58 
59     if args.platform != 'auto':
60         platform = args.platform
61     else:
62         platform = None
63 
64         if os.environ.get('TRAVIS_OS_NAME') == 'linux':
65             platform = 'linux'
66         elif os.environ.get('TRAVIS_OS_NAME') == 'osx':
67             platform = 'macos'
68         elif os.environ.get('TRAVIS_OS_NAME') == 'windows':
69             platform = 'windows'
70         elif 'APPVEYOR' in os.environ:
71             platform = 'windows'
72         elif 'BITRISE_BUILD_NUMBER' in os.environ:
73             platform = 'macos'
74         elif os.environ.get('CIRCLECI'):
75             if sys.platform.startswith('linux'):
76                 platform = 'linux'
77             elif sys.platform.startswith('darwin'):
78                 platform = 'macos'
79         elif 'AZURE_HTTP_USER_AGENT' in os.environ:
80             if os.environ['AGENT_OS'] == 'Linux':
81                 platform = 'linux'
82             elif os.environ['AGENT_OS'] == 'Darwin':
83                 platform = 'macos'
84             elif os.environ['AGENT_OS'] == 'Windows_NT':
85                 platform = 'windows'
86 
87         if platform is None:
88             print('cibuildwheel: Unable to detect platform. cibuildwheel should run on your CI server, '
89                   'Travis CI, AppVeyor, and CircleCI are supported. You can run on your development '
90                   'machine using the --platform argument. Check --help output for more '
91                   'information.',
92                   file=sys.stderr)
93             exit(2)
94 
95     output_dir = args.output_dir
96     test_command = get_option_from_environment('CIBW_TEST_COMMAND', platform=platform)
97     test_requires = get_option_from_environment('CIBW_TEST_REQUIRES', platform=platform, default='').split()
98     test_extras = get_option_from_environment('CIBW_TEST_EXTRAS', platform=platform, default='')
99     project_dir = args.project_dir
100     before_build = get_option_from_environment('CIBW_BEFORE_BUILD', platform=platform)
101     build_verbosity = get_option_from_environment('CIBW_BUILD_VERBOSITY', platform=platform, default='')
102     build_config, skip_config = os.environ.get('CIBW_BUILD', '*'), os.environ.get('CIBW_SKIP', '')
103     environment_config = get_option_from_environment('CIBW_ENVIRONMENT', platform=platform, default='')
104 
105     if test_extras:
106         test_extras = '[{0}]'.format(test_extras)
107 
108     try:
109         build_verbosity = min(3, max(-3, int(build_verbosity)))
110     except ValueError:
111         build_verbosity = 0
112 
113     try:
114         environment = parse_environment(environment_config)
115     except (EnvironmentParseError, ValueError) as e:
116         print('cibuildwheel: Malformed environment option "%s"' % environment_config, file=sys.stderr)
117         import traceback
118         traceback.print_exc(None, sys.stderr)
119         exit(2)
120 
121     build_selector = BuildSelector(build_config, skip_config)
122 
123     # Add CIBUILDWHEEL environment variable
124     # This needs to be passed on to the docker container in linux.py
125     os.environ['CIBUILDWHEEL'] = '1'
126 
127     if not os.path.exists(os.path.join(project_dir, 'setup.py')):
128         print('cibuildwheel: Could not find setup.py at root of project', file=sys.stderr)
129         exit(2)
130 
131     if args.print_build_identifiers:
132         print_build_identifiers(platform, build_selector)
133         exit(0)
134 
135     build_options = dict(
136         project_dir=project_dir,
137         output_dir=output_dir,
138         test_command=test_command,
139         test_requires=test_requires,
140         test_extras=test_extras,
141         before_build=before_build,
142         build_verbosity=build_verbosity,
143         build_selector=build_selector,
144         environment=environment,
145     )
146 
147     if platform == 'linux':
148         manylinux_x86_64_image = os.environ.get('CIBW_MANYLINUX_X86_64_IMAGE', 'manylinux2010')
149         manylinux_i686_image = os.environ.get('CIBW_MANYLINUX_I686_IMAGE', 'manylinux2010')
150 
151         default_manylinux_images_x86_64 = {'manylinux1': 'quay.io/pypa/manylinux1_x86_64',
152                                            'manylinux2010': 'quay.io/pypa/manylinux2010_x86_64'}
153         default_manylinux_images_i686 = {'manylinux1': 'quay.io/pypa/manylinux1_i686',
154                                          'manylinux2010': 'quay.io/pypa/manylinux2010_i686'}
155 
156         build_options.update(
157             manylinux_images={'x86_64': default_manylinux_images_x86_64.get(manylinux_x86_64_image) or manylinux_x86_64_image,
158                               'i686': default_manylinux_images_i686.get(manylinux_i686_image) or manylinux_i686_image},
159         )
160     elif platform == 'macos':
161         pass
162     elif platform == 'windows':
163         pass
164 
165     # Python is buffering by default when running on the CI platforms, giving problems interleaving subprocess call output with unflushed calls to 'print'
166     sys.stdout = Unbuffered(sys.stdout)
167 
168     print_preamble(platform, build_options)
169 
170     if not os.path.exists(output_dir):
171         os.makedirs(output_dir)
172 
173     if platform == 'linux':
174         cibuildwheel.linux.build(**build_options)
175     elif platform == 'windows':
176         cibuildwheel.windows.build(**build_options)
177     elif platform == 'macos':
178         cibuildwheel.macos.build(**build_options)
179     else:
180         raise Exception('Unsupported platform')
181 
182 
183 def detect_obsolete_options():
184     # Check the old 'MANYLINUX1_*_IMAGE' options
185     for (deprecated, alternative) in [('CIBW_MANYLINUX1_X86_64_IMAGE', 'CIBW_MANYLINUX_X86_64_IMAGE'),
186                                       ('CIBW_MANYLINUX1_I686_IMAGE', 'CIBW_MANYLINUX_I686_IMAGE')]:
187         if deprecated in os.environ:
188             print("'{}' has been deprecated, and will be removed in a future release. Use the option '{}' instead.".format(deprecated, alternative))
189             if alternative not in os.environ:
190                 print("Using value of option '{}' as replacement for '{}'".format(deprecated, alternative))
191                 os.environ[alternative] = os.environ[deprecated]
192             else:
193                 print("Option '{}' is not empty. Please unset '{}'".format(alternative, deprecated))
194                 exit(2)
195 
196     # Check for 'manylinux1' in the 'CIBW_BUILD' and 'CIBW_SKIP' options
197     for deprecated in ['CIBW_BUILD', 'CIBW_SKIP']:
198         if deprecated in os.environ and 'manylinux1' in os.environ[deprecated]:
199             print("Build identifiers with 'manylinux1' been deprecated. Replacing all occurences of 'manylinux1' by 'manylinux' in the option '{}'".format(deprecated))
200             os.environ[deprecated] = os.environ[deprecated].replace('manylinux1', 'manylinux')
201 
202 
203 def print_preamble(platform, build_options):
204     print(textwrap.dedent('''
205              _ _       _ _   _       _           _
206          ___|_| |_ _ _|_| |_| |_ _ _| |_ ___ ___| |
207         |  _| | . | | | | | . | | | |   | -_| -_| |
208         |___|_|___|___|_|_|___|_____|_|_|___|___|_|
209         '''))
210 
211     print('cibuildwheel version %s\n' % cibuildwheel.__version__)
212 
213 
214     print('Build options:')
215     print('  platform: %r' % platform)
216     for option, value in sorted(build_options.items()):
217         print('  %s: %r' % (option, value))
218 
219     warnings = detect_warnings(platform, build_options)
220     if warnings:
221         print('\nWarnings:')
222         for warning in warnings:
223             print('  ' + warning)
224 
225     print('\nHere we go!\n')
226 
227 
228 def print_build_identifiers(platform, build_selector):
229     if platform == 'linux':
230         python_configurations = cibuildwheel.linux.get_python_configurations(build_selector)
231     elif platform == 'windows':
232         python_configurations = cibuildwheel.windows.get_python_configurations(build_selector)
233     elif platform == 'macos':
234         python_configurations = cibuildwheel.macos.get_python_configurations(build_selector)
235     else:
236         python_configurations = []
237 
238     for config in python_configurations:
239         print(config.identifier)
240 
241 
242 def detect_warnings(platform, build_options):
243     warnings = []
244 
245     # warn about deprecated {python} and {pip}
246     for option_name in ['test_command', 'before_build']:
247         option_value = build_options.get(option_name)
248 
249         if option_value:
250             if '{python}' in option_value or '{pip}' in option_value:
251                 warnings.append(option_name + ": '{python}' and '{pip}' are no longer needed, and will be removed in a future release. Simply use 'python' or 'pip' instead.")
252 
253     return warnings
254 
255 
256 if __name__ == '__main__':
257     main()
258
```
--- 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/cibuildwheel/__main__.py b/cibuildwheel/__main__.py
--- a/cibuildwheel/__main__.py
+++ b/cibuildwheel/__main__.py
@@ -24,6 +24,12 @@
     return os.environ.get(option_name, default)
 
 
+def strtobool(val):
+    if val.lower() in ('y', 'yes', 't', 'true', 'on', '1'):
+        return True
+    return False
+
+
 def main():
     parser = argparse.ArgumentParser(
         description='Build wheels for all the platforms.',
@@ -38,7 +44,7 @@
                               'script is going to automatically install MacPython on your system, '
                               'so don\'t run on your development machine. For "windows", you need to '
                               'run in Windows, and it will build and test for all versions of '
-                              'Python at C:\\PythonXX[-x64]. Default: auto.'))
+                              'Python. Default: auto.'))
     parser.add_argument('--output-dir',
                         default=os.environ.get('CIBW_OUTPUT_DIR', 'wheelhouse'),
                         help='Destination folder for the wheels.')
@@ -59,36 +65,19 @@
     if args.platform != 'auto':
         platform = args.platform
     else:
-        platform = None
-
-        if os.environ.get('TRAVIS_OS_NAME') == 'linux':
-            platform = 'linux'
-        elif os.environ.get('TRAVIS_OS_NAME') == 'osx':
-            platform = 'macos'
-        elif os.environ.get('TRAVIS_OS_NAME') == 'windows':
-            platform = 'windows'
-        elif 'APPVEYOR' in os.environ:
-            platform = 'windows'
-        elif 'BITRISE_BUILD_NUMBER' in os.environ:
-            platform = 'macos'
-        elif os.environ.get('CIRCLECI'):
+        ci = strtobool(os.environ.get('CI', 'false')) or 'BITRISE_BUILD_NUMBER' in os.environ or 'AZURE_HTTP_USER_AGENT' in os.environ
+        if ci:
             if sys.platform.startswith('linux'):
                 platform = 'linux'
-            elif sys.platform.startswith('darwin'):
+            elif sys.platform == 'darwin':
                 platform = 'macos'
-        elif 'AZURE_HTTP_USER_AGENT' in os.environ:
-            if os.environ['AGENT_OS'] == 'Linux':
-                platform = 'linux'
-            elif os.environ['AGENT_OS'] == 'Darwin':
-                platform = 'macos'
-            elif os.environ['AGENT_OS'] == 'Windows_NT':
+            elif sys.platform == 'win32':
                 platform = 'windows'
-
         if platform is None:
             print('cibuildwheel: Unable to detect platform. cibuildwheel should run on your CI server, '
-                  'Travis CI, AppVeyor, and CircleCI are supported. You can run on your development '
-                  'machine using the --platform argument. Check --help output for more '
-                  'information.',
+                  'Travis CI, AppVeyor, Azure Pipelines and CircleCI are supported. You can run on your '
+                  'development machine or other CI providers using the --platform argument. Check --help '
+                  'output for more information.',
                   file=sys.stderr)
             exit(2)

{"golden_diff": "diff --git a/cibuildwheel/__main__.py b/cibuildwheel/__main__.py\n--- a/cibuildwheel/__main__.py\n+++ b/cibuildwheel/__main__.py\n@@ -24,6 +24,12 @@\n     return os.environ.get(option_name, default)\n \n \n+def strtobool(val):\n+    if val.lower() in ('y', 'yes', 't', 'true', 'on', '1'):\n+        return True\n+    return False\n+\n+\n def main():\n     parser = argparse.ArgumentParser(\n         description='Build wheels for all the platforms.',\n@@ -38,7 +44,7 @@\n                               'script is going to automatically install MacPython on your system, '\n                               'so don\\'t run on your development machine. For \"windows\", you need to '\n                               'run in Windows, and it will build and test for all versions of '\n-                              'Python at C:\\\\PythonXX[-x64]. Default: auto.'))\n+                              'Python. Default: auto.'))\n     parser.add_argument('--output-dir',\n                         default=os.environ.get('CIBW_OUTPUT_DIR', 'wheelhouse'),\n                         help='Destination folder for the wheels.')\n@@ -59,36 +65,19 @@\n     if args.platform != 'auto':\n         platform = args.platform\n     else:\n-        platform = None\n-\n-        if os.environ.get('TRAVIS_OS_NAME') == 'linux':\n-            platform = 'linux'\n-        elif os.environ.get('TRAVIS_OS_NAME') == 'osx':\n-            platform = 'macos'\n-        elif os.environ.get('TRAVIS_OS_NAME') == 'windows':\n-            platform = 'windows'\n-        elif 'APPVEYOR' in os.environ:\n-            platform = 'windows'\n-        elif 'BITRISE_BUILD_NUMBER' in os.environ:\n-            platform = 'macos'\n-        elif os.environ.get('CIRCLECI'):\n+        ci = strtobool(os.environ.get('CI', 'false')) or 'BITRISE_BUILD_NUMBER' in os.environ or 'AZURE_HTTP_USER_AGENT' in os.environ\n+        if ci:\n             if sys.platform.startswith('linux'):\n                 platform = 'linux'\n-            elif sys.platform.startswith('darwin'):\n+            elif sys.platform == 'darwin':\n                 platform = 'macos'\n-        elif 'AZURE_HTTP_USER_AGENT' in os.environ:\n-            if os.environ['AGENT_OS'] == 'Linux':\n-                platform = 'linux'\n-            elif os.environ['AGENT_OS'] == 'Darwin':\n-                platform = 'macos'\n-            elif os.environ['AGENT_OS'] == 'Windows_NT':\n+            elif sys.platform == 'win32':\n                 platform = 'windows'\n-\n         if platform is None:\n             print('cibuildwheel: Unable to detect platform. cibuildwheel should run on your CI server, '\n-                  'Travis CI, AppVeyor, and CircleCI are supported. You can run on your development '\n-                  'machine using the --platform argument. Check --help output for more '\n-                  'information.',\n+                  'Travis CI, AppVeyor, Azure Pipelines and CircleCI are supported. You can run on your '\n+                  'development machine or other CI providers using the --platform argument. Check --help '\n+                  'output for more information.',\n                   file=sys.stderr)\n             exit(2)\n", "issue": "Linux support in AppVeyor\nFYI\r\nhttps://www.appveyor.com/blog/2018/03/06/appveyor-for-linux/\r\nhttps://www.appveyor.com/blog/2018/05/15/appveyor-for-linux-is-generally-available/\r\nhttps://www.appveyor.com/docs/getting-started-with-appveyor-for-linux/\n", "before_files": [{"content": "from __future__ import print_function\nimport argparse, os, subprocess, sys, textwrap\n\nimport cibuildwheel\nimport cibuildwheel.linux, cibuildwheel.windows, cibuildwheel.macos\nfrom cibuildwheel.environment import parse_environment, EnvironmentParseError\nfrom cibuildwheel.util import BuildSelector, Unbuffered\n\ndef get_option_from_environment(option_name, platform=None, default=None):\n    '''\n    Returns an option from the environment, optionally scoped by the platform.\n\n    Example:\n      get_option_from_environment('CIBW_COLOR', platform='macos')\n\n      This will return the value of CIBW_COLOR_MACOS if it exists, otherwise the value of\n      CIBW_COLOR.\n    '''\n    if platform:\n        option = os.environ.get('%s_%s' % (option_name, platform.upper()))\n        if option is not None:\n            return option\n\n    return os.environ.get(option_name, default)\n\n\ndef main():\n    parser = argparse.ArgumentParser(\n        description='Build wheels for all the platforms.',\n        epilog=('Most options are supplied via environment variables. '\n                'See https://github.com/joerick/cibuildwheel#options for info.'))\n\n    parser.add_argument('--platform',\n                        choices=['auto', 'linux', 'macos', 'windows'],\n                        default=os.environ.get('CIBW_PLATFORM', 'auto'),\n                        help=('Platform to build for. For \"linux\" you need docker running, on Mac '\n                              'or Linux. For \"macos\", you need a Mac machine, and note that this '\n                              'script is going to automatically install MacPython on your system, '\n                              'so don\\'t run on your development machine. For \"windows\", you need to '\n                              'run in Windows, and it will build and test for all versions of '\n                              'Python at C:\\\\PythonXX[-x64]. Default: auto.'))\n    parser.add_argument('--output-dir',\n                        default=os.environ.get('CIBW_OUTPUT_DIR', 'wheelhouse'),\n                        help='Destination folder for the wheels.')\n    parser.add_argument('project_dir',\n                        default='.',\n                        nargs='?',\n                        help=('Path to the project that you want wheels for. Default: the current '\n                              'directory.'))\n\n    parser.add_argument('--print-build-identifiers',\n                        action='store_true',\n                        help='Print the build identifiers matched by the current invocation and exit.')\n\n    args = parser.parse_args()\n\n    detect_obsolete_options()\n\n    if args.platform != 'auto':\n        platform = args.platform\n    else:\n        platform = None\n\n        if os.environ.get('TRAVIS_OS_NAME') == 'linux':\n            platform = 'linux'\n        elif os.environ.get('TRAVIS_OS_NAME') == 'osx':\n            platform = 'macos'\n        elif os.environ.get('TRAVIS_OS_NAME') == 'windows':\n            platform = 'windows'\n        elif 'APPVEYOR' in os.environ:\n            platform = 'windows'\n        elif 'BITRISE_BUILD_NUMBER' in os.environ:\n            platform = 'macos'\n        elif os.environ.get('CIRCLECI'):\n            if sys.platform.startswith('linux'):\n                platform = 'linux'\n            elif sys.platform.startswith('darwin'):\n                platform = 'macos'\n        elif 'AZURE_HTTP_USER_AGENT' in os.environ:\n            if os.environ['AGENT_OS'] == 'Linux':\n                platform = 'linux'\n            elif os.environ['AGENT_OS'] == 'Darwin':\n                platform = 'macos'\n            elif os.environ['AGENT_OS'] == 'Windows_NT':\n                platform = 'windows'\n\n        if platform is None:\n            print('cibuildwheel: Unable to detect platform. cibuildwheel should run on your CI server, '\n                  'Travis CI, AppVeyor, and CircleCI are supported. You can run on your development '\n                  'machine using the --platform argument. Check --help output for more '\n                  'information.',\n                  file=sys.stderr)\n            exit(2)\n\n    output_dir = args.output_dir\n    test_command = get_option_from_environment('CIBW_TEST_COMMAND', platform=platform)\n    test_requires = get_option_from_environment('CIBW_TEST_REQUIRES', platform=platform, default='').split()\n    test_extras = get_option_from_environment('CIBW_TEST_EXTRAS', platform=platform, default='')\n    project_dir = args.project_dir\n    before_build = get_option_from_environment('CIBW_BEFORE_BUILD', platform=platform)\n    build_verbosity = get_option_from_environment('CIBW_BUILD_VERBOSITY', platform=platform, default='')\n    build_config, skip_config = os.environ.get('CIBW_BUILD', '*'), os.environ.get('CIBW_SKIP', '')\n    environment_config = get_option_from_environment('CIBW_ENVIRONMENT', platform=platform, default='')\n\n    if test_extras:\n        test_extras = '[{0}]'.format(test_extras)\n\n    try:\n        build_verbosity = min(3, max(-3, int(build_verbosity)))\n    except ValueError:\n        build_verbosity = 0\n\n    try:\n        environment = parse_environment(environment_config)\n    except (EnvironmentParseError, ValueError) as e:\n        print('cibuildwheel: Malformed environment option \"%s\"' % environment_config, file=sys.stderr)\n        import traceback\n        traceback.print_exc(None, sys.stderr)\n        exit(2)\n\n    build_selector = BuildSelector(build_config, skip_config)\n\n    # Add CIBUILDWHEEL environment variable\n    # This needs to be passed on to the docker container in linux.py\n    os.environ['CIBUILDWHEEL'] = '1'\n\n    if not os.path.exists(os.path.join(project_dir, 'setup.py')):\n        print('cibuildwheel: Could not find setup.py at root of project', file=sys.stderr)\n        exit(2)\n\n    if args.print_build_identifiers:\n        print_build_identifiers(platform, build_selector)\n        exit(0)\n\n    build_options = dict(\n        project_dir=project_dir,\n        output_dir=output_dir,\n        test_command=test_command,\n        test_requires=test_requires,\n        test_extras=test_extras,\n        before_build=before_build,\n        build_verbosity=build_verbosity,\n        build_selector=build_selector,\n        environment=environment,\n    )\n\n    if platform == 'linux':\n        manylinux_x86_64_image = os.environ.get('CIBW_MANYLINUX_X86_64_IMAGE', 'manylinux2010')\n        manylinux_i686_image = os.environ.get('CIBW_MANYLINUX_I686_IMAGE', 'manylinux2010')\n\n        default_manylinux_images_x86_64 = {'manylinux1': 'quay.io/pypa/manylinux1_x86_64',\n                                           'manylinux2010': 'quay.io/pypa/manylinux2010_x86_64'}\n        default_manylinux_images_i686 = {'manylinux1': 'quay.io/pypa/manylinux1_i686',\n                                         'manylinux2010': 'quay.io/pypa/manylinux2010_i686'}\n\n        build_options.update(\n            manylinux_images={'x86_64': default_manylinux_images_x86_64.get(manylinux_x86_64_image) or manylinux_x86_64_image,\n                              'i686': default_manylinux_images_i686.get(manylinux_i686_image) or manylinux_i686_image},\n        )\n    elif platform == 'macos':\n        pass\n    elif platform == 'windows':\n        pass\n\n    # Python is buffering by default when running on the CI platforms, giving problems interleaving subprocess call output with unflushed calls to 'print'\n    sys.stdout = Unbuffered(sys.stdout)\n\n    print_preamble(platform, build_options)\n\n    if not os.path.exists(output_dir):\n        os.makedirs(output_dir)\n\n    if platform == 'linux':\n        cibuildwheel.linux.build(**build_options)\n    elif platform == 'windows':\n        cibuildwheel.windows.build(**build_options)\n    elif platform == 'macos':\n        cibuildwheel.macos.build(**build_options)\n    else:\n        raise Exception('Unsupported platform')\n\n\ndef detect_obsolete_options():\n    # Check the old 'MANYLINUX1_*_IMAGE' options\n    for (deprecated, alternative) in [('CIBW_MANYLINUX1_X86_64_IMAGE', 'CIBW_MANYLINUX_X86_64_IMAGE'),\n                                      ('CIBW_MANYLINUX1_I686_IMAGE', 'CIBW_MANYLINUX_I686_IMAGE')]:\n        if deprecated in os.environ:\n            print(\"'{}' has been deprecated, and will be removed in a future release. Use the option '{}' instead.\".format(deprecated, alternative))\n            if alternative not in os.environ:\n                print(\"Using value of option '{}' as replacement for '{}'\".format(deprecated, alternative))\n                os.environ[alternative] = os.environ[deprecated]\n            else:\n                print(\"Option '{}' is not empty. Please unset '{}'\".format(alternative, deprecated))\n                exit(2)\n\n    # Check for 'manylinux1' in the 'CIBW_BUILD' and 'CIBW_SKIP' options\n    for deprecated in ['CIBW_BUILD', 'CIBW_SKIP']:\n        if deprecated in os.environ and 'manylinux1' in os.environ[deprecated]:\n            print(\"Build identifiers with 'manylinux1' been deprecated. Replacing all occurences of 'manylinux1' by 'manylinux' in the option '{}'\".format(deprecated))\n            os.environ[deprecated] = os.environ[deprecated].replace('manylinux1', 'manylinux')\n\n\ndef print_preamble(platform, build_options):\n    print(textwrap.dedent('''\n             _ _       _ _   _       _           _\n         ___|_| |_ _ _|_| |_| |_ _ _| |_ ___ ___| |\n        |  _| | . | | | | | . | | | |   | -_| -_| |\n        |___|_|___|___|_|_|___|_____|_|_|___|___|_|\n        '''))\n\n    print('cibuildwheel version %s\\n' % cibuildwheel.__version__)\n\n\n    print('Build options:')\n    print('  platform: %r' % platform)\n    for option, value in sorted(build_options.items()):\n        print('  %s: %r' % (option, value))\n\n    warnings = detect_warnings(platform, build_options)\n    if warnings:\n        print('\\nWarnings:')\n        for warning in warnings:\n            print('  ' + warning)\n\n    print('\\nHere we go!\\n')\n\n\ndef print_build_identifiers(platform, build_selector):\n    if platform == 'linux':\n        python_configurations = cibuildwheel.linux.get_python_configurations(build_selector)\n    elif platform == 'windows':\n        python_configurations = cibuildwheel.windows.get_python_configurations(build_selector)\n    elif platform == 'macos':\n        python_configurations = cibuildwheel.macos.get_python_configurations(build_selector)\n    else:\n        python_configurations = []\n\n    for config in python_configurations:\n        print(config.identifier)\n\n\ndef detect_warnings(platform, build_options):\n    warnings = []\n\n    # warn about deprecated {python} and {pip}\n    for option_name in ['test_command', 'before_build']:\n        option_value = build_options.get(option_name)\n\n        if option_value:\n            if '{python}' in option_value or '{pip}' in option_value:\n                warnings.append(option_name + \": '{python}' and '{pip}' are no longer needed, and will be removed in a future release. Simply use 'python' or 'pip' instead.\")\n\n    return warnings\n\n\nif __name__ == '__main__':\n    main()\n", "path": "cibuildwheel/__main__.py"}], "after_files": [{"content": "from __future__ import print_function\nimport argparse, os, subprocess, sys, textwrap\n\nimport cibuildwheel\nimport cibuildwheel.linux, cibuildwheel.windows, cibuildwheel.macos\nfrom cibuildwheel.environment import parse_environment, EnvironmentParseError\nfrom cibuildwheel.util import BuildSelector, Unbuffered\n\ndef get_option_from_environment(option_name, platform=None, default=None):\n    '''\n    Returns an option from the environment, optionally scoped by the platform.\n\n    Example:\n      get_option_from_environment('CIBW_COLOR', platform='macos')\n\n      This will return the value of CIBW_COLOR_MACOS if it exists, otherwise the value of\n      CIBW_COLOR.\n    '''\n    if platform:\n        option = os.environ.get('%s_%s' % (option_name, platform.upper()))\n        if option is not None:\n            return option\n\n    return os.environ.get(option_name, default)\n\n\ndef strtobool(val):\n    if val.lower() in ('y', 'yes', 't', 'true', 'on', '1'):\n        return True\n    return False\n\n\ndef main():\n    parser = argparse.ArgumentParser(\n        description='Build wheels for all the platforms.',\n        epilog=('Most options are supplied via environment variables. '\n                'See https://github.com/joerick/cibuildwheel#options for info.'))\n\n    parser.add_argument('--platform',\n                        choices=['auto', 'linux', 'macos', 'windows'],\n                        default=os.environ.get('CIBW_PLATFORM', 'auto'),\n                        help=('Platform to build for. For \"linux\" you need docker running, on Mac '\n                              'or Linux. For \"macos\", you need a Mac machine, and note that this '\n                              'script is going to automatically install MacPython on your system, '\n                              'so don\\'t run on your development machine. For \"windows\", you need to '\n                              'run in Windows, and it will build and test for all versions of '\n                              'Python. Default: auto.'))\n    parser.add_argument('--output-dir',\n                        default=os.environ.get('CIBW_OUTPUT_DIR', 'wheelhouse'),\n                        help='Destination folder for the wheels.')\n    parser.add_argument('project_dir',\n                        default='.',\n                        nargs='?',\n                        help=('Path to the project that you want wheels for. Default: the current '\n                              'directory.'))\n\n    parser.add_argument('--print-build-identifiers',\n                        action='store_true',\n                        help='Print the build identifiers matched by the current invocation and exit.')\n\n    args = parser.parse_args()\n\n    detect_obsolete_options()\n\n    if args.platform != 'auto':\n        platform = args.platform\n    else:\n        ci = strtobool(os.environ.get('CI', 'false')) or 'BITRISE_BUILD_NUMBER' in os.environ or 'AZURE_HTTP_USER_AGENT' in os.environ\n        if ci:\n            if sys.platform.startswith('linux'):\n                platform = 'linux'\n            elif sys.platform == 'darwin':\n                platform = 'macos'\n            elif sys.platform == 'win32':\n                platform = 'windows'\n        if platform is None:\n            print('cibuildwheel: Unable to detect platform. cibuildwheel should run on your CI server, '\n                  'Travis CI, AppVeyor, Azure Pipelines and CircleCI are supported. You can run on your '\n                  'development machine or other CI providers using the --platform argument. Check --help '\n                  'output for more information.',\n                  file=sys.stderr)\n            exit(2)\n\n    output_dir = args.output_dir\n    test_command = get_option_from_environment('CIBW_TEST_COMMAND', platform=platform)\n    test_requires = get_option_from_environment('CIBW_TEST_REQUIRES', platform=platform, default='').split()\n    test_extras = get_option_from_environment('CIBW_TEST_EXTRAS', platform=platform, default='')\n    project_dir = args.project_dir\n    before_build = get_option_from_environment('CIBW_BEFORE_BUILD', platform=platform)\n    build_verbosity = get_option_from_environment('CIBW_BUILD_VERBOSITY', platform=platform, default='')\n    build_config, skip_config = os.environ.get('CIBW_BUILD', '*'), os.environ.get('CIBW_SKIP', '')\n    environment_config = get_option_from_environment('CIBW_ENVIRONMENT', platform=platform, default='')\n\n    if test_extras:\n        test_extras = '[{0}]'.format(test_extras)\n\n    try:\n        build_verbosity = min(3, max(-3, int(build_verbosity)))\n    except ValueError:\n        build_verbosity = 0\n\n    try:\n        environment = parse_environment(environment_config)\n    except (EnvironmentParseError, ValueError) as e:\n        print('cibuildwheel: Malformed environment option \"%s\"' % environment_config, file=sys.stderr)\n        import traceback\n        traceback.print_exc(None, sys.stderr)\n        exit(2)\n\n    build_selector = BuildSelector(build_config, skip_config)\n\n    # Add CIBUILDWHEEL environment variable\n    # This needs to be passed on to the docker container in linux.py\n    os.environ['CIBUILDWHEEL'] = '1'\n\n    if not os.path.exists(os.path.join(project_dir, 'setup.py')):\n        print('cibuildwheel: Could not find setup.py at root of project', file=sys.stderr)\n        exit(2)\n\n    if args.print_build_identifiers:\n        print_build_identifiers(platform, build_selector)\n        exit(0)\n\n    build_options = dict(\n        project_dir=project_dir,\n        output_dir=output_dir,\n        test_command=test_command,\n        test_requires=test_requires,\n        test_extras=test_extras,\n        before_build=before_build,\n        build_verbosity=build_verbosity,\n        build_selector=build_selector,\n        environment=environment,\n    )\n\n    if platform == 'linux':\n        manylinux_x86_64_image = os.environ.get('CIBW_MANYLINUX_X86_64_IMAGE', 'manylinux2010')\n        manylinux_i686_image = os.environ.get('CIBW_MANYLINUX_I686_IMAGE', 'manylinux2010')\n\n        default_manylinux_images_x86_64 = {'manylinux1': 'quay.io/pypa/manylinux1_x86_64',\n                                           'manylinux2010': 'quay.io/pypa/manylinux2010_x86_64'}\n        default_manylinux_images_i686 = {'manylinux1': 'quay.io/pypa/manylinux1_i686',\n                                         'manylinux2010': 'quay.io/pypa/manylinux2010_i686'}\n\n        build_options.update(\n            manylinux_images={'x86_64': default_manylinux_images_x86_64.get(manylinux_x86_64_image) or manylinux_x86_64_image,\n                              'i686': default_manylinux_images_i686.get(manylinux_i686_image) or manylinux_i686_image},\n        )\n    elif platform == 'macos':\n        pass\n    elif platform == 'windows':\n        pass\n\n    # Python is buffering by default when running on the CI platforms, giving problems interleaving subprocess call output with unflushed calls to 'print'\n    sys.stdout = Unbuffered(sys.stdout)\n\n    print_preamble(platform, build_options)\n\n    if not os.path.exists(output_dir):\n        os.makedirs(output_dir)\n\n    if platform == 'linux':\n        cibuildwheel.linux.build(**build_options)\n    elif platform == 'windows':\n        cibuildwheel.windows.build(**build_options)\n    elif platform == 'macos':\n        cibuildwheel.macos.build(**build_options)\n    else:\n        raise Exception('Unsupported platform')\n\n\ndef detect_obsolete_options():\n    # Check the old 'MANYLINUX1_*_IMAGE' options\n    for (deprecated, alternative) in [('CIBW_MANYLINUX1_X86_64_IMAGE', 'CIBW_MANYLINUX_X86_64_IMAGE'),\n                                      ('CIBW_MANYLINUX1_I686_IMAGE', 'CIBW_MANYLINUX_I686_IMAGE')]:\n        if deprecated in os.environ:\n            print(\"'{}' has been deprecated, and will be removed in a future release. Use the option '{}' instead.\".format(deprecated, alternative))\n            if alternative not in os.environ:\n                print(\"Using value of option '{}' as replacement for '{}'\".format(deprecated, alternative))\n                os.environ[alternative] = os.environ[deprecated]\n            else:\n                print(\"Option '{}' is not empty. Please unset '{}'\".format(alternative, deprecated))\n                exit(2)\n\n    # Check for 'manylinux1' in the 'CIBW_BUILD' and 'CIBW_SKIP' options\n    for deprecated in ['CIBW_BUILD', 'CIBW_SKIP']:\n        if deprecated in os.environ and 'manylinux1' in os.environ[deprecated]:\n            print(\"Build identifiers with 'manylinux1' been deprecated. Replacing all occurences of 'manylinux1' by 'manylinux' in the option '{}'\".format(deprecated))\n            os.environ[deprecated] = os.environ[deprecated].replace('manylinux1', 'manylinux')\n\n\ndef print_preamble(platform, build_options):\n    print(textwrap.dedent('''\n             _ _       _ _   _       _           _\n         ___|_| |_ _ _|_| |_| |_ _ _| |_ ___ ___| |\n        |  _| | . | | | | | . | | | |   | -_| -_| |\n        |___|_|___|___|_|_|___|_____|_|_|___|___|_|\n        '''))\n\n    print('cibuildwheel version %s\\n' % cibuildwheel.__version__)\n\n\n    print('Build options:')\n    print('  platform: %r' % platform)\n    for option, value in sorted(build_options.items()):\n        print('  %s: %r' % (option, value))\n\n    warnings = detect_warnings(platform, build_options)\n    if warnings:\n        print('\\nWarnings:')\n        for warning in warnings:\n            print('  ' + warning)\n\n    print('\\nHere we go!\\n')\n\n\ndef print_build_identifiers(platform, build_selector):\n    if platform == 'linux':\n        python_configurations = cibuildwheel.linux.get_python_configurations(build_selector)\n    elif platform == 'windows':\n        python_configurations = cibuildwheel.windows.get_python_configurations(build_selector)\n    elif platform == 'macos':\n        python_configurations = cibuildwheel.macos.get_python_configurations(build_selector)\n    else:\n        python_configurations = []\n\n    for config in python_configurations:\n        print(config.identifier)\n\n\ndef detect_warnings(platform, build_options):\n    warnings = []\n\n    # warn about deprecated {python} and {pip}\n    for option_name in ['test_command', 'before_build']:\n        option_value = build_options.get(option_name)\n\n        if option_value:\n            if '{python}' in option_value or '{pip}' in option_value:\n                warnings.append(option_name + \": '{python}' and '{pip}' are no longer needed, and will be removed in a future release. Simply use 'python' or 'pip' instead.\")\n\n    return warnings\n\n\nif __name__ == '__main__':\n    main()\n", "path": "cibuildwheel/__main__.py"}]}