MCPcopy Index your code
hub / github.com/couchbase/couchbase-python-client / process_build_env_vars

Function process_build_env_vars

pycbc_build_setup.py:53–124  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

51
52
53def process_build_env_vars(): # noqa: C901
54 # Set debug or release
55 build_type = os.getenv('PYCBC_BUILD_TYPE', 'Release')
56 if build_type == 'Debug':
57 # @TODO: extra Windows debug args?
58 if platform.system() != "Windows":
59 debug_flags = ' '.join(['-O0', '-g3'])
60 c_flags = os.getenv('CFLAGS', '')
61 cxx_flags = os.getenv('CXXFLAGS', '')
62 os.environ['CFLAGS'] = f'{c_flags} {debug_flags}'
63 os.environ['CXXFLAGS'] = f'{cxx_flags} {debug_flags}'
64 os.environ['PYCBC_BUILD_TYPE'] = build_type
65 cmake_extra_args = []
66
67 # Allows us to set the location of OpenSSL for the build.
68 ssl_dir = os.getenv('PYCBC_OPENSSL_DIR', None)
69 if ssl_dir is not None:
70 cmake_extra_args += [f'-DOPENSSL_ROOT_DIR={ssl_dir}']
71
72 # We use OpenSSL by default if building the SDK; however, starting with v4.1.9 we build our wheels using BoringSSL.
73 pycbc_use_openssl = os.getenv('PYCBC_USE_OPENSSL', 'true').lower() in ENV_TRUE
74 pycbc_use_opensslv1_1 = os.getenv('PYCBC_USE_OPENSSLV1_1', 'false').lower() in ENV_TRUE
75 if pycbc_use_openssl is True or pycbc_use_opensslv1_1:
76 cmake_extra_args += ['-DUSE_STATIC_BORINGSSL:BOOL=OFF']
77 ssl_version = os.getenv('PYCBC_OPENSSL_VERSION', None)
78 if pycbc_use_opensslv1_1 is True:
79 cmake_extra_args += ['-DUSE_OPENSSLV1_1:BOOL=ON']
80 if not ssl_version:
81 # lastest 1.1 version: https://github.com/openssl/openssl/releases/tag/OpenSSL_1_1_1w
82 ssl_version = '1.1.1w'
83 elif not ssl_version:
84 # lastest 3.x version: https://github.com/openssl/openssl/releases/tag/openssl-3.5.2
85 ssl_version = '3.5.2'
86 cmake_extra_args += [f'-DOPENSSL_VERSION={ssl_version}']
87
88 else:
89 cmake_extra_args += ['-DUSE_STATIC_BORINGSSL:BOOL=ON']
90
91 # v4.1.9: building with static stdlibc++ must be opted-in by user
92 use_static_stdlib = os.getenv('PYCBC_USE_STATIC_STDLIB', 'false').lower() in ENV_TRUE
93 if use_static_stdlib is True:
94 cmake_extra_args += ['-DUSE_STATIC_STDLIB:BOOL=ON']
95 else:
96 cmake_extra_args += ['-DUSE_STATIC_STDLIB:BOOL=OFF']
97
98 # v4.3.4: Allow user to specify if the C++ core will download Mozilla CA bundle during build.
99 # Defaults to ON unless the CPM Cache is being used then we use the certs from the cache
100 download_mozilla_ca_bundle = os.getenv('PYCBC_DOWNLOAD_MOZILLA_CA_BUNDLE', None)
101 if download_mozilla_ca_bundle is not None:
102 if download_mozilla_ca_bundle.lower() in ENV_TRUE:
103 cmake_extra_args += ['-DDOWNLOAD_MOZILLA_CA_BUNDLE:BOOL=ON']
104 else:
105 cmake_extra_args += ['-DDOWNLOAD_MOZILLA_CA_BUNDLE:BOOL=OFF']
106
107 sanitizers = os.getenv('PYCBC_SANITIZERS', None)
108 if sanitizers:
109 for x in sanitizers.split(','):
110 cmake_extra_args += [f'-DENABLE_SANITIZER_{x.upper()}=ON']

Callers 2

runMethod · 0.85
build_extensionMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected