=== modified file 'twisted/topfiles/setup.py'
|
|
|
|
| 19 | 19 | from twisted.python.dist import getPackages, getDataFiles, getScripts |
| 20 | 20 | from twisted.python.dist import twisted_subprojects |
| 21 | 21 | |
| | 22 | import platform |
| | 23 | |
| | 24 | |
| | 25 | def _isCPython(): |
| | 26 | try: |
| | 27 | return platform.python_implementation() == "CPython" |
| | 28 | except AttributeError: |
| | 29 | # For 2.5: |
| | 30 | try: |
| | 31 | implementation, _, _ = sys.subversion |
| | 32 | return implementation == "CPython" |
| | 33 | except AttributeError: |
| | 34 | pass |
| | 35 | |
| | 36 | # Pythons older than 2.5 require us to try and guess by |
| | 37 | # elimination. If you're on such an old, obscure version of |
| | 38 | # Python, I can't help you. |
| | 39 | |
| | 40 | # Are we on Pypy? |
| | 41 | if "__pypy__" in sys.modules: |
| | 42 | return False |
| | 43 | |
| | 44 | # Guess not. Are we on Jython? |
| | 45 | try: |
| | 46 | platform.java_ver |
| | 47 | return False |
| | 48 | except AttributeError: |
| | 49 | pass |
| | 50 | |
| | 51 | # Guess not. Are we on IronPython? |
| | 52 | try: |
| | 53 | import clr |
| | 54 | return False |
| | 55 | except ImportError: |
| | 56 | pass |
| | 57 | |
| | 58 | # Well, then we're *probably* on CPython. |
| | 59 | return True |
| | 60 | |
| | 61 | |
| | 62 | isCPython = _isCPython() |
| | 63 | |
| | 64 | |
| | 65 | def hasEpoll(builder): |
| | 66 | builder._check_header("sys/epoll.h") |
| 22 | 67 | |
| 23 | 68 | |
| 24 | 69 | extensions = [ |
| 25 | 70 | Extension("twisted.test.raiser", |
| 26 | | ["twisted/test/raiser.c"]), |
| | 71 | ["twisted/test/raiser.c"], |
| | 72 | condition=lambda _: isCPython), |
| 27 | 73 | |
| 28 | 74 | Extension("twisted.python._epoll", |
| 29 | 75 | ["twisted/python/_epoll.c"], |
| 30 | | condition=lambda builder: builder._check_header("sys/epoll.h")), |
| | 76 | condition=lambda builder: isCPython and hasEpoll(builder)), |
| 31 | 77 | |
| 32 | 78 | Extension("twisted.internet.iocpreactor.iocpsupport", |
| 33 | 79 | ["twisted/internet/iocpreactor/iocpsupport/iocpsupport.c", |
| 34 | 80 | "twisted/internet/iocpreactor/iocpsupport/winsock_pointers.c"], |
| 35 | 81 | libraries=["ws2_32"], |
| 36 | | condition=lambda builder: sys.platform == "win32"), |
| | 82 | condition=lambda _: isCPython and sys.platform == "win32"), |
| 37 | 83 | |
| 38 | 84 | Extension("twisted.python._initgroups", |
| 39 | 85 | ["twisted/python/_initgroups.c"]), |
| 40 | 86 | Extension("twisted.internet._sigchld", |
| 41 | 87 | ["twisted/internet/_sigchld.c"], |
| 42 | | condition=lambda builder: sys.platform != "win32"), |
| | 88 | condition=lambda _: sys.platform != "win32"), |
| 43 | 89 | ] |
| 44 | 90 | |
| 45 | 91 | # Figure out which plugins to include: all plugins except subproject ones |