Skip to content

Commit

Permalink
Disable implicit switch-back to pure python mode. (#3828)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
asvetlov committed Jun 8, 2019
1 parent 981cb37 commit 5684c43
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 15 deletions.
9 changes: 4 additions & 5 deletions .travis.yml
Expand Up @@ -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
Expand All @@ -174,18 +174,17 @@ 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

- <<: *_lint_base
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
Expand Down
4 changes: 4 additions & 0 deletions 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.
26 changes: 16 additions & 10 deletions setup.py
@@ -1,4 +1,5 @@
import codecs
import os
import pathlib
import re
import sys
Expand All @@ -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


Expand Down Expand Up @@ -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)

0 comments on commit 5684c43

Please sign in to comment.