Skip to content

Commit d1655f9

Browse files
committed
Move setting of the compiler and linker flags to a function.
1 parent d7ebc21 commit d1655f9

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

setup.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,16 @@
1818

1919
cross_compiling = "_PYTHON_HOST_PLATFORM" in os.environ
2020

21-
# Add special CFLAGS reserved for building the interpreter and the stdlib
22-
# modules (Issue #21121).
23-
cflags = sysconfig.get_config_var('CFLAGS')
24-
py_cflags_nodist = sysconfig.get_config_var('PY_CFLAGS_NODIST')
25-
sysconfig.get_config_vars()['CFLAGS'] = cflags + ' ' + py_cflags_nodist
26-
27-
# Add special LDFLAGS reserved for building the interpreter and the stdlib
28-
# modules (bpo-35257).
29-
ldflags = sysconfig.get_config_var('LDFLAGS')
30-
py_ldflags_nodist = sysconfig.get_config_var('PY_LDFLAGS_NODIST')
31-
sysconfig.get_config_vars()['LDFLAGS'] = ldflags + ' ' + py_ldflags_nodist
21+
# Set common compiler and linker flags derived from the Makefile,
22+
# reserved for building the interpreter and the stdlib modules.
23+
# See bpo-21121 and bpo-35257
24+
def set_compiler_flags(compiler_flags, compiler_py_flags_nodist):
25+
flags = sysconfig.get_config_var(compiler_flags)
26+
py_flags_nodist = sysconfig.get_config_var(compiler_py_flags_nodist)
27+
sysconfig.get_config_vars()[compiler_flags] = flags + ' ' + py_flags_nodist
28+
29+
set_compiler_flags('CFLAGS', 'PY_CFLAGS_NODIST')
30+
set_compiler_flags('LDFLAGS', 'PY_LDFLAGS_NODIST')
3231

3332
class Dummy:
3433
"""Hack for parallel build"""

0 commit comments

Comments
 (0)