|
@@ -147,8 +147,9 @@ def create_cmdclass(prerelease_cmd=None, package_data_spec=None,
|
|
|
A dictionary whose keys are the dotted package names and
|
|
|
whose values are a list of glob patterns.
|
|
|
data_files_spec: list, optional
|
|
|
- A list of (path, patterns) tuples where the path is the
|
|
|
- `data_files` install path and the patterns are glob patterns.
|
|
|
+ A list of (path, dname, pattern) tuples where the path is the
|
|
|
+ `data_files` install path, dname is the source directory, and the
|
|
|
+ pattern is a glob pattern.
|
|
|
|
|
|
Notes
|
|
|
-----
|
|
@@ -160,9 +161,12 @@ def create_cmdclass(prerelease_cmd=None, package_data_spec=None,
|
|
|
name.
|
|
|
e.g. `dict(foo=['./bar/*', './baz/**'])`
|
|
|
|
|
|
- The data files glob patterns should be absolute paths or relative paths
|
|
|
- from the root directory of the repository.
|
|
|
- e.g. `('share/foo/bar', ['pkgname/bizz/*', 'pkgname/baz/**'])`
|
|
|
+ The data files directories should be absolute paths or relative paths
|
|
|
+ from the root directory of the repository. Data files are specified
|
|
|
+ differently from `package_data` because we need a separate path entry
|
|
|
+ for each nested folder in `data_files`, and this makes it easier to
|
|
|
+ parse.
|
|
|
+ e.g. `('share/foo/bar', 'pkgname/bizz, '*')`
|
|
|
"""
|
|
|
wrapped = [prerelease_cmd] if prerelease_cmd else []
|
|
|
if package_data_spec or data_files_spec:
|
|
@@ -494,24 +498,18 @@ def _get_file_handler(package_data_spec, data_files_spec):
|
|
|
for (path, files) in self.distribution.data_files or []:
|
|
|
file_data[path] = files
|
|
|
|
|
|
- for (path, dname) in data_spec:
|
|
|
- for root, subdirs, fnames in os.walk(dname):
|
|
|
- # Don't recurse into node_modules
|
|
|
- if 'node_modules' in subdirs:
|
|
|
- subdirs.remove('node_modules')
|
|
|
-
|
|
|
- # Bail if there are no files.
|
|
|
- if not fnames:
|
|
|
- continue
|
|
|
+ # Extract the files and assign them to the proper data
|
|
|
+ # files path.
|
|
|
+ for (key, dname, pattern) in data_spec:
|
|
|
+ dname = dname.replace(os.sep, '/')
|
|
|
+ offset = len(dname) + 1
|
|
|
|
|
|
+ files = _get_files(pjoin(dname, pattern))
|
|
|
+ for fname in files:
|
|
|
# Normalize the path.
|
|
|
- root = root.replace(os.sep, '/')
|
|
|
- offset = len(dname) + 1
|
|
|
- full_path = pjoin(path, root[offset:])
|
|
|
-
|
|
|
- # Add the files.
|
|
|
- files = ['%s/%s' % (root, f) for f in fnames]
|
|
|
- file_data[full_path].extend(files)
|
|
|
+ root = os.path.dirname(fname)
|
|
|
+ full_path = pjoin(dname, root[offset:])
|
|
|
+ file_data[full_path].append(fname)
|
|
|
|
|
|
# Construct the data files spec.
|
|
|
data_files = []
|
|
@@ -657,7 +655,7 @@ def _translate_glob_part(pat):
|
|
|
res = []
|
|
|
while i < n:
|
|
|
c = pat[i]
|
|
|
- i = i+1
|
|
|
+ i = i + 1
|
|
|
if c == '*':
|
|
|
# Match anything but path separators:
|
|
|
res.append('[^%s]*' % SEPARATORS)
|
|
@@ -666,16 +664,16 @@ def _translate_glob_part(pat):
|
|
|
elif c == '[':
|
|
|
j = i
|
|
|
if j < n and pat[j] == '!':
|
|
|
- j = j+1
|
|
|
+ j = j + 1
|
|
|
if j < n and pat[j] == ']':
|
|
|
- j = j+1
|
|
|
+ j = j + 1
|
|
|
while j < n and pat[j] != ']':
|
|
|
- j = j+1
|
|
|
+ j = j + 1
|
|
|
if j >= n:
|
|
|
res.append('\\[')
|
|
|
else:
|
|
|
stuff = pat[i:j].replace('\\', '\\\\')
|
|
|
- i = j+1
|
|
|
+ i = j + 1
|
|
|
if stuff[0] == '!':
|
|
|
stuff = '^' + stuff[1:]
|
|
|
elif stuff[0] == '^':
|