MCPcopy Index your code
hub / github.com/python/cpython / main

Function main

Lib/test/test_cext/setup.py:58–134  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

56
57
58def main():
59 std = os.environ.get("CPYTHON_TEST_STD", "")
60 module_name = os.environ["CPYTHON_TEST_EXT_NAME"]
61 limited = bool(os.environ.get("CPYTHON_TEST_LIMITED", ""))
62 abi3t = bool(os.environ.get("CPYTHON_TEST_ABI3T", ""))
63 internal = bool(int(os.environ.get("TEST_INTERNAL_C_API", "0")))
64
65 sources = [SOURCE]
66
67 if not internal:
68 cflags = list(PUBLIC_CFLAGS)
69 else:
70 cflags = list(INTERNAL_CFLAGS)
71 cflags.append(f'-DMODULE_NAME={module_name}')
72
73 # Add -std=STD or /std:STD (MSVC) compiler flag
74 if std:
75 if support.MS_WINDOWS:
76 cflags.append(f'/std:{std}')
77 else:
78 cflags.append(f'-std={std}')
79
80 # Remove existing -std or /std options from CC command line.
81 # Python adds -std=c11 option.
82 cmd = (sysconfig.get_config_var('CC') or '')
83 if cmd is not None:
84 if support.MS_WINDOWS:
85 std_prefix = '/std'
86 else:
87 std_prefix = '-std'
88 cmd = shlex.split(cmd)
89 cmd = [arg for arg in cmd if not arg.startswith(std_prefix)]
90 cmd = shlex.join(cmd)
91 # CC env var overrides sysconfig CC variable in setuptools
92 os.environ['CC'] = cmd
93
94 # Define opt-in macros
95 if limited:
96 cflags.append(f'-DPy_LIMITED_API={sys.hexversion:#x}')
97
98 if abi3t:
99 cflags.append(f'-DPy_TARGET_ABI3T={sys.hexversion:#x}')
100
101 if internal:
102 cflags.append('-DTEST_INTERNAL_C_API=1')
103
104 # On Windows, add PCbuild\amd64\ to include and library directories
105 include_dirs = []
106 library_dirs = []
107 if support.MS_WINDOWS:
108 srcdir = sysconfig.get_config_var('srcdir')
109 machine = platform.uname().machine
110 pcbuild = os.path.join(srcdir, 'PCbuild', machine)
111 if os.path.exists(pcbuild):
112 # pyconfig.h is generated in PCbuild\amd64\
113 include_dirs.append(pcbuild)
114 # python313.lib is generated in PCbuild\amd64\
115 library_dirs.append(pcbuild)

Callers 4

setup.pyFile · 0.70
test_create_autospecMethod · 0.50

Calls 8

listClass · 0.85
setupFunction · 0.50
getMethod · 0.45
appendMethod · 0.45
splitMethod · 0.45
startswithMethod · 0.45
joinMethod · 0.45
existsMethod · 0.45

Tested by 3

test_create_autospecMethod · 0.40

Used in the wild real call sites across dependent graphs

searching dependent graphs…