diff options
author | Jason Madden <jamadden@gmail.com> | 2021-11-02 16:41:54 -0500 |
---|---|---|
committer | Jason Madden <jamadden@gmail.com> | 2021-11-02 16:41:54 -0500 |
commit | 1865d4ff1007e17ef7a059eace8b2d06fb11ddd0 (patch) | |
tree | bae74f9fa422d71f1378a58cbbe6e3defbc62d30 /setup.py | |
parent | 0aa442e94a2dca04089f5201eecd9fe5cc2763ac (diff) | |
parent | 29020817a8f3b8b55b497e4aef641e160d0778f6 (diff) | |
download | greenlet-1865d4ff1007e17ef7a059eace8b2d06fb11ddd0.tar.gz |
Merge branch 'object_ownership'
Diffstat (limited to 'setup.py')
-rwxr-xr-x | setup.py | 67 |
1 files changed, 51 insertions, 16 deletions
@@ -1,5 +1,5 @@ #! /usr/bin/env python - +from __future__ import print_function import sys import os import glob @@ -16,6 +16,9 @@ global_compile_args = [] # Extra compiler arguments passed to C++ extensions cpp_compile_args = [] +# Extra linker arguments passed to C++ extensions +cpp_link_args = [] + # Extra compiler arguments passed to the main extension main_compile_args = [] @@ -38,10 +41,39 @@ if sys.platform == 'darwin': cpp_compile_args.append("--std=gnu++11") elif sys.platform == 'win32': # Older versions of MSVC (Python 2.7) don't handle C++ exceptions - # correctly by default. "/EH" == exception handling. "s" == standard C++, - # "c" == extern C doesn't throw - cpp_compile_args.append("/EHsc") - + # correctly by default. While newer versions do handle exceptions by default, + # they don't do it fully correctly. So we need an argument on all versions. + #"/EH" == exception handling. + # "s" == standard C++, + # "c" == extern C functions don't throw + # OR + # "a" == standard C++, and Windows SEH; anything may throw, compiler optimizations + # around try blocks are less aggressive. + # /EHsc is suggested, as /EHa isn't supposed to be linked to other things not built + # with it. + # See https://docs.microsoft.com/en-us/cpp/build/reference/eh-exception-handling-model?view=msvc-160 + handler = "/EHsc" + cpp_compile_args.append(handler) + # To disable most optimizations: + #cpp_compile_args.append('/Od') + + # To enable assertions: + #cpp_compile_args.append('/UNDEBUG') + + # To enable more compile-time warnings (/Wall produces a mountain of output). + #cpp_compile_args.append('/W4') + + # To link with the debug C runtime...except we can't because we need + # the Python debug lib too, and they're not around by default + # cpp_compile_args.append('/MDd') + + # Support fiber-safe thread-local storage: "the compiler mustn't + # cache the address of the TLS array, or optimize it as a common + # subexpression across a function call." This would probably solve + # some of the issues we had with MSVC caching the thread local + # variables on the stack, leading to having to split some + # functions up. Revisit those. + cpp_compile_args.append("/GT") def readfile(filename): with open(filename, 'r') as f: # pylint:disable=unspecified-encoding @@ -88,6 +120,7 @@ else: language='c++', extra_objects=extra_objects, extra_compile_args=global_compile_args + main_compile_args + cpp_compile_args, + extra_link_args=cpp_link_args, depends=[ GREENLET_HEADER, GREENLET_SRC_DIR + 'slp_platformselect.h', @@ -107,19 +140,16 @@ else: include_dirs=[GREENLET_HEADER_DIR], extra_compile_args=global_compile_args, ), + Extension( + name='greenlet.tests._test_extension_cpp', + sources=[GREENLET_TEST_DIR + '_test_extension_cpp.cpp'], + language="c++", + include_dirs=[GREENLET_HEADER_DIR], + extra_compile_args=global_compile_args + cpp_compile_args, + extra_link_args=cpp_link_args, + ), ] - if os.environ.get('GREENLET_TEST_CPP', 'yes').lower() not in ('0', 'no', 'false'): - ext_modules.append( - Extension( - name='greenlet.tests._test_extension_cpp', - sources=[GREENLET_TEST_DIR + '_test_extension_cpp.cpp'], - language="c++", - include_dirs=[GREENLET_HEADER_DIR], - extra_compile_args=global_compile_args + cpp_compile_args, - ) - ) - def get_greenlet_version(): with open('src/greenlet/__init__.py') as f: # pylint:disable=unspecified-encoding @@ -177,8 +207,13 @@ setup( extras_require={ 'docs': [ 'Sphinx', + # 0.18b1 breaks sphinx 1.8.5 which is the latest version that runs + # on Python 2. The version pin sphinx itself contains isn't specific enough. + 'docutils < 0.18; python_version < "3"', ], 'test': [ + 'objgraph', + 'faulthandler; python_version == "2.7" and platform_python_implementation == "CPython"', ], }, python_requires=">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*", |