Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
09b2bece
Commit
09b2bece
authored
Jul 11, 2018
by
Chih-Hsuan Yen
Committed by
INADA Naoki
Jul 11, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-29442: Replace optparse with argparse in setup.py (GH-139)
parent
d5c875bb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
19 deletions
+5
-19
Misc/NEWS.d/next/Build/2017-09-26-23-08-27.bpo-29442.fD8YTi.rst
...EWS.d/next/Build/2017-09-26-23-08-27.bpo-29442.fD8YTi.rst
+1
-0
setup.py
setup.py
+4
-19
No files found.
Misc/NEWS.d/next/Build/2017-09-26-23-08-27.bpo-29442.fD8YTi.rst
0 → 100644
View file @
09b2bece
Replace optparse with argparse in setup.py
setup.py
View file @
09b2bece
# Autodetecting setup.py script for building the Python extensions
#
import
sys
,
os
,
importlib
.
machinery
,
re
,
opt
parse
import
sys
,
os
,
importlib
.
machinery
,
re
,
arg
parse
from
glob
import
glob
import
importlib._bootstrap
import
importlib.util
...
...
@@ -560,24 +560,9 @@ class PyBuildExt(build_ext):
(
'CPPFLAGS'
,
'-I'
,
self
.
compiler
.
include_dirs
)):
env_val
=
sysconfig
.
get_config_var
(
env_var
)
if
env_val
:
# To prevent optparse from raising an exception about any
# options in env_val that it doesn't know about 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)
parser = optparse.OptionParser()
# Make sure that allowing args interspersed with options is
# allowed
parser.allow_interspersed_args = True
parser.error = lambda msg: None
parser.add_option(arg_name, dest="dirs", action="append")
options = parser.parse_args(env_val.split())[0]
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
arg_name
,
dest
=
"dirs"
,
action
=
"append"
)
options
,
_
=
parser
.
parse_known_args
(
env_val
.
split
())
if
options
.
dirs
:
for
directory
in
reversed
(
options
.
dirs
):
add_dir_to_list
(
dir_list
,
directory
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment