Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
setuptools
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
setuptools
Commits
b1615d12
Commit
b1615d12
authored
Jan 26, 2019
by
Jason R. Coombs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adopt distutils.dist.Distribution._set_command_options to support better string detection.
parent
80082fac
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
0 deletions
+48
-0
setuptools/dist.py
setuptools/dist.py
+48
-0
No files found.
setuptools/dist.py
View file @
b1615d12
...
...
@@ -14,6 +14,7 @@ import distutils.dist
from
distutils.errors
import
DistutilsOptionError
from
distutils.util
import
strtobool
from
distutils.debug
import
DEBUG
from
distutils.fancy_getopt
import
translate_longopt
import
itertools
from
collections
import
defaultdict
...
...
@@ -626,6 +627,53 @@ class Distribution(_Distribution):
except
ValueError
as
msg
:
raise
DistutilsOptionError
(
msg
)
def
_set_command_options
(
self
,
command_obj
,
option_dict
=
None
):
"""
Set the options for 'command_obj' from 'option_dict'. Basically
this means copying elements of a dictionary ('option_dict') to
attributes of an instance ('command').
'command_obj' must be a Command instance. If 'option_dict' is not
supplied, uses the standard option dictionary for this command
(from 'self.command_options').
(Adopted from distutils.dist.Distribution._set_command_options)
"""
command_name
=
command_obj
.
get_command_name
()
if
option_dict
is
None
:
option_dict
=
self
.
get_option_dict
(
command_name
)
if
DEBUG
:
self
.
announce
(
" setting options for '%s' command:"
%
command_name
)
for
(
option
,
(
source
,
value
))
in
option_dict
.
items
():
if
DEBUG
:
self
.
announce
(
" %s = %s (from %s)"
%
(
option
,
value
,
source
))
try
:
bool_opts
=
[
translate_longopt
(
o
)
for
o
in
command_obj
.
boolean_options
]
except
AttributeError
:
bool_opts
=
[]
try
:
neg_opt
=
command_obj
.
negative_opt
except
AttributeError
:
neg_opt
=
{}
try
:
is_string
=
isinstance
(
value
,
str
)
if
option
in
neg_opt
and
is_string
:
setattr
(
command_obj
,
neg_opt
[
option
],
not
strtobool
(
value
))
elif
option
in
bool_opts
and
is_string
:
setattr
(
command_obj
,
option
,
strtobool
(
value
))
elif
hasattr
(
command_obj
,
option
):
setattr
(
command_obj
,
option
,
value
)
else
:
raise
DistutilsOptionError
(
"error in %s: command '%s' has no such option '%s'"
%
(
source
,
command_name
,
option
))
except
ValueError
as
msg
:
raise
DistutilsOptionError
(
msg
)
def
parse_config_files
(
self
,
filenames
=
None
,
ignore_option_errors
=
False
):
"""Parses configuration files from various levels
and loads configuration.
...
...
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