|
3 | 3 | import re
|
4 | 4 | import sys
|
5 | 5 | from setuptools import setup, find_packages, Extension
|
| 6 | +from distutils.errors import (CCompilerError, DistutilsExecError, |
| 7 | + DistutilsPlatformError) |
| 8 | +from distutils.command.build_ext import build_ext |
6 | 9 |
|
7 | 10 |
|
8 | 11 | try:
|
|
21 | 24 | extensions = cythonize(extensions)
|
22 | 25 |
|
23 | 26 |
|
| 27 | +class BuildFailed(Exception): |
| 28 | + pass |
| 29 | + |
| 30 | + |
| 31 | +class ve_build_ext(build_ext): |
| 32 | + # This class allows C extension building to fail. |
| 33 | + |
| 34 | + def run(self): |
| 35 | + try: |
| 36 | + build_ext.run(self) |
| 37 | + except DistutilsPlatformError: |
| 38 | + raise BuildFailed() |
| 39 | + |
| 40 | + def build_extension(self, ext): |
| 41 | + try: |
| 42 | + build_ext.build_extension(self, ext) |
| 43 | + except (CCompilerError, DistutilsExecError, DistutilsPlatformError): |
| 44 | + raise BuildFailed() |
| 45 | + |
| 46 | + |
24 | 47 | with codecs.open(os.path.join(os.path.abspath(os.path.dirname(
|
25 | 48 | __file__)), 'aiohttp', '__init__.py'), 'r', 'latin1') as fp:
|
26 | 49 | try:
|
|
40 | 63 | def read(f):
|
41 | 64 | return open(os.path.join(os.path.dirname(__file__), f)).read().strip()
|
42 | 65 |
|
| 66 | +args = dict( |
| 67 | + name='aiohttp', |
| 68 | + version=version, |
| 69 | + description=('http client/server for asyncio'), |
| 70 | + long_description='\n\n'.join((read('README.rst'), read('CHANGES.txt'))), |
| 71 | + classifiers=[ |
| 72 | + 'License :: OSI Approved :: Apache Software License', |
| 73 | + 'Intended Audience :: Developers', |
| 74 | + 'Programming Language :: Python', |
| 75 | + 'Programming Language :: Python :: 3', |
| 76 | + 'Programming Language :: Python :: 3.3', |
| 77 | + 'Programming Language :: Python :: 3.4', |
| 78 | + 'Topic :: Internet :: WWW/HTTP'], |
| 79 | + author='Nikolay Kim', |
| 80 | + |
| 81 | + url='https://github.com/KeepSafe/aiohttp/', |
| 82 | + license='Apache 2', |
| 83 | + packages=find_packages(), |
| 84 | + install_requires=install_requires, |
| 85 | + tests_require=tests_require, |
| 86 | + test_suite='nose.collector', |
| 87 | + include_package_data=True, |
| 88 | + ext_modules=extensions, |
| 89 | + cmdclass=dict(build_ext=ve_build_ext)) |
43 | 90 |
|
44 |
| -setup(name='aiohttp', |
45 |
| - version=version, |
46 |
| - description=('http client/server for asyncio'), |
47 |
| - long_description='\n\n'.join((read('README.rst'), read('CHANGES.txt'))), |
48 |
| - classifiers=[ |
49 |
| - 'License :: OSI Approved :: Apache Software License', |
50 |
| - 'Intended Audience :: Developers', |
51 |
| - 'Programming Language :: Python', |
52 |
| - 'Programming Language :: Python :: 3', |
53 |
| - 'Programming Language :: Python :: 3.3', |
54 |
| - 'Programming Language :: Python :: 3.4', |
55 |
| - 'Topic :: Internet :: WWW/HTTP'], |
56 |
| - author='Nikolay Kim', |
57 |
| - |
58 |
| - url='https://github.com/KeepSafe/aiohttp/', |
59 |
| - license='Apache 2', |
60 |
| - packages=find_packages(), |
61 |
| - install_requires=install_requires, |
62 |
| - tests_require=tests_require, |
63 |
| - test_suite='nose.collector', |
64 |
| - include_package_data=True, |
65 |
| - ext_modules=extensions) |
| 91 | +try: |
| 92 | + setup(**args) |
| 93 | +except BuildFailed: |
| 94 | + print("*************************************************************") |
| 95 | + print("Cannot compile C accellerator module, use pure python version") |
| 96 | + print("*************************************************************") |
| 97 | + del args['ext_modules'] |
| 98 | + del args['cmdclass'] |
| 99 | + setup(**args) |
0 commit comments