From 5684c436d6b2ae45b92fd8c49cf6bf0e7e15a9fa Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Sat, 8 Jun 2019 14:59:22 +0300 Subject: [PATCH] Disable implicit switch-back to pure python mode. (#3828) * Disable implicit switch-back to pure python mode. The build fails loudly if aiohttp cannot be compiled with C Accellerators. Use AIOHTTP_NO_EXTENSIONS=1 to explicitly disable C Extensions complication and switch to Pure-Python mode. Note that Pure-Python mode is significantly slower than compiled one. --- .travis.yml | 9 ++++----- CHANGES/3828.feature | 4 ++++ setup.py | 26 ++++++++++++++++---------- 3 files changed, 24 insertions(+), 15 deletions(-) create mode 100644 CHANGES/3828.feature diff --git a/.travis.yml b/.travis.yml index a7d55e27b6..1dc46eebfd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -156,7 +156,7 @@ jobs: install: - *upgrade_python_toolset - pip install -r requirements/cython.txt - - pip install -r requirements/ci.txt + - AIOHTTP_NO_EXTENSIONS=1 pip install -r requirements/ci.txt - pip install -r requirements/towncrier.txt script: - towncrier --yes @@ -174,7 +174,7 @@ jobs: install: - *upgrade_python_toolset - pip install -r requirements/cython.txt - - pip install -r requirements/ci.txt + - AIOHTTP_NO_EXTENSIONS=1 pip install -r requirements/ci.txt script: - mypy aiohttp @@ -182,10 +182,9 @@ jobs: name: Verifying distribution package metadata install: - *upgrade_python_toolset - - pip install -r requirements/cython.txt - - pip install -r requirements/ci.txt -r requirements/doc.txt + - AIOHTTP_NO_EXTENSIONS=1 pip install -r requirements/ci.txt -r requirements/doc.txt script: - - python setup.py check --metadata --restructuredtext --strict --verbose sdist bdist_wheel + - AIOHTTP_NO_EXTENSIONS=1 python setup.py --verbose sdist bdist_wheel - twine check dist/* - <<: *_lint_base diff --git a/CHANGES/3828.feature b/CHANGES/3828.feature new file mode 100644 index 0000000000..7d31a2bb24 --- /dev/null +++ b/CHANGES/3828.feature @@ -0,0 +1,4 @@ +Disable implicit switch-back to pure python mode. The build fails loudly if aiohttp +cannot be compiled with C Accellerators. Use AIOHTTP_NO_EXTENSIONS=1 to explicitly +disable C Extensions complication and switch to Pure-Python mode. Note that Pure-Python +mode is significantly slower than compiled one. diff --git a/setup.py b/setup.py index 8c2deaf201..c7a0c675cb 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,5 @@ import codecs +import os import pathlib import re import sys @@ -12,6 +13,10 @@ if sys.version_info < (3, 5, 3): raise RuntimeError("aiohttp 3.x requires Python 3.5.3+") + +NO_EXTENSIONS = bool(os.environ.get('AIOHTTP_NO_EXTENSIONS')) # type: bool + + here = pathlib.Path(__file__).parent @@ -132,16 +137,17 @@ def read(f): ], }, include_package_data=True, - ext_modules=extensions, - cmdclass=dict(build_ext=ve_build_ext), ) -try: - setup(**args) -except BuildFailed: - print("************************************************************") - print("Cannot compile C accelerator module, use pure python version") - print("************************************************************") - del args['ext_modules'] - del args['cmdclass'] +if not NO_EXTENSIONS: + print("**********************") + print("* Accellerated build *") + print("**********************") + setup(ext_modules=extensions, + cmdclass=dict(build_ext=ve_build_ext), + **args) +else: + print("*********************") + print("* Pure Python build *") + print("*********************") setup(**args)