Fix Windows support
A recent commit [1] broke Windows support by using shlex to unquote paths. The issue with shlex.split is that it doesn't work with Windows paths, treating backslashes as escape characters. We'll just replace backslashes with slashes before using shlex.split, converting them back afterwards. Closes-Bug: #1831242 [1] Id2cc32e4e40c1f834b19756e922118d8526358d3 Change-Id: Icb3abca004a35ab9760db8116fedfa96d012d0d0
This commit is contained in:
parent
c1e4225c5a
commit
a7e5c0202e
|
@ -41,6 +41,13 @@ def unquote_path(path):
|
|||
# strip the quotes off individual path components because os.walk cannot
|
||||
# handle paths like: "'i like spaces'/'another dir'", so we will pass it
|
||||
# "i like spaces/another dir" instead.
|
||||
|
||||
if os.name == 'nt':
|
||||
# shlex cannot handle paths that contain backslashes, treating those
|
||||
# as escape characters.
|
||||
path = path.replace("\\", "/")
|
||||
return "".join(shlex.split(path)).replace("/", "\\")
|
||||
|
||||
return "".join(shlex.split(path))
|
||||
|
||||
|
||||
|
|
18
pbr/util.py
18
pbr/util.py
|
@ -161,6 +161,16 @@ BOOL_FIELDS = ("use_2to3", "zip_safe", "include_package_data")
|
|||
CSV_FIELDS = ()
|
||||
|
||||
|
||||
def shlex_split(path):
|
||||
if os.name == 'nt':
|
||||
# shlex cannot handle paths that contain backslashes, treating those
|
||||
# as escape characters.
|
||||
path = path.replace("\\", "/")
|
||||
return [x.replace("/", "\\") for x in shlex.split(path)]
|
||||
|
||||
return shlex.split(path)
|
||||
|
||||
|
||||
def resolve_name(name):
|
||||
"""Resolve a name like ``module.object`` to an object and return it.
|
||||
|
||||
|
@ -373,22 +383,22 @@ def setup_cfg_to_setup_kwargs(config, script_args=()):
|
|||
for line in in_cfg_value:
|
||||
if '=' in line:
|
||||
key, value = line.split('=', 1)
|
||||
key_unquoted = shlex.split(key.strip())[0]
|
||||
key_unquoted = shlex_split(key.strip())[0]
|
||||
key, value = (key_unquoted, value.strip())
|
||||
if key in data_files:
|
||||
# Multiple duplicates of the same package name;
|
||||
# this is for backwards compatibility of the old
|
||||
# format prior to d2to1 0.2.6.
|
||||
prev = data_files[key]
|
||||
prev.extend(shlex.split(value))
|
||||
prev.extend(shlex_split(value))
|
||||
else:
|
||||
prev = data_files[key.strip()] = shlex.split(value)
|
||||
prev = data_files[key.strip()] = shlex_split(value)
|
||||
elif firstline:
|
||||
raise errors.DistutilsOptionError(
|
||||
'malformed package_data first line %r (misses '
|
||||
'"=")' % line)
|
||||
else:
|
||||
prev.extend(shlex.split(line.strip()))
|
||||
prev.extend(shlex_split(line.strip()))
|
||||
firstline = False
|
||||
if arg == 'data_files':
|
||||
# the data_files value is a pointlessly different structure
|
||||
|
|
Loading…
Reference in New Issue