mirror of
https://github.com/python/cpython.git
synced 2025-07-24 03:35:53 +00:00
bpo-45221: Fix handling of LDFLAGS and CPPFLAGS options in setup.py (GH-29031)
This commit is contained in:
parent
034f607906
commit
6a533a4238
2 changed files with 15 additions and 0 deletions
12
setup.py
12
setup.py
|
@ -801,6 +801,18 @@ class PyBuildExt(build_ext):
|
|||
if env_val:
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument(arg_name, dest="dirs", action="append")
|
||||
|
||||
# To prevent argparse from raising an exception about any
|
||||
# options in env_val that it mistakes for known option, we
|
||||
# strip out all double dashes and any dashes followed by a
|
||||
# character that is not for the option we are dealing with.
|
||||
#
|
||||
# Please note that order of the regex is important! We must
|
||||
# strip out double-dashes first so that we don't end up with
|
||||
# substituting "--Long" to "-Long" and thus lead to "ong" being
|
||||
# used for a library directory.
|
||||
env_val = re.sub(r'(^|\s+)-(-|(?!%s))' % arg_name[1],
|
||||
' ', env_val)
|
||||
options, _ = parser.parse_known_args(env_val.split())
|
||||
if options.dirs:
|
||||
for directory in reversed(options.dirs):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue