summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2019-06-17 18:19:29 +0000
committerGerrit Code Review <review@openstack.org>2019-06-17 18:19:29 +0000
commite4c7dba0bd9b5fdb8c387ff0062e28a3df5391e5 (patch)
tree87efa9cf813ed3aad813f02040e5dc08f60c9e94
parent884899b4325cd405179918daaeaee74b0e0ba308 (diff)
parenta7e5c0202ea00aab29c009f7adef6cea51ac6e25 (diff)
downloadpbr-e4c7dba0bd9b5fdb8c387ff0062e28a3df5391e5.tar.gz
Merge "Fix Windows support"5.3.1
-rw-r--r--pbr/hooks/files.py7
-rw-r--r--pbr/util.py18
2 files changed, 21 insertions, 4 deletions
diff --git a/pbr/hooks/files.py b/pbr/hooks/files.py
index 0fe0df5..c44af7c 100644
--- a/pbr/hooks/files.py
+++ b/pbr/hooks/files.py
@@ -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))
diff --git a/pbr/util.py b/pbr/util.py
index 323747e..6b2e87d 100644
--- a/pbr/util.py
+++ b/pbr/util.py
@@ -162,6 +162,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.
@@ -374,22 +384,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