From a19402c4148154399ad316fa36e6b222c5a08ec3 Mon Sep 17 00:00:00 2001 From: Brian Dolbec Date: Fri, 7 Jun 2013 07:42:27 -0700 Subject: [PATCH] fix lib_files generation Move data_file generation out of setup(). Rework file() to yield the files in the correct form. wking: Use dirpath directly. wking: Remove unneeded list() use. wking: Use relative paths. --- setup.py | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/setup.py b/setup.py index fe05d067..f3aa7b43 100755 --- a/setup.py +++ b/setup.py @@ -34,7 +34,7 @@ package_name = 'catalyst' tag = '{0}-{1}'.format(package_name, __version__) -def files(root): +def files(root, target): """Iterate through all the file paths under `root` Distutils wants all paths to be written in the Unix convention @@ -42,12 +42,29 @@ def files(root): [1]: http://docs.python.org/2/distutils/setupscript.html#writing-the-setup-script """ + def ensure_slash(path): + if _os.path.sep != '/': + path.replace(_os.path.sep, '/') + return path + filedict = {} for dirpath, dirnames, filenames in _os.walk(root): - for filename in filenames: - path = _os.path.join(dirpath, filename) - if _os.path.sep != '/': - path = path.replace(_os.path.sep, '/') - yield path + key = _os.path.join(target, dirpath) + filepaths = [] + for _file in filenames: + _filepath = ensure_slash(_os.path.join(dirpath, _file)) + filepaths.append(_filepath) + filedict[key] = filepaths + for key in sorted(filedict): + if len(filedict[key]): + yield (key, filedict[key]) + + +_data_files = [('/etc/catalyst', ['etc/catalyst.conf','etc/catalystrc']), + ('/usr/share/man/man1', ['files/catalyst.1']), + ('/usr/share/man/man5', ['files/catalyst-config.5', 'files/catalyst-spec.5']) + ] +_data_files.extend(files('livecd', 'lib/catalyst/')) +_data_files.extend(files('targets', 'lib/catalyst/')) class set_version(Command): @@ -105,16 +122,7 @@ _setup( '{0}.base'.format(package_name), '{0}.targets'.format(package_name), ], - data_files=[ - ('/etc/catalyst', [ - 'etc/catalyst.conf', - 'etc/catalystrc', - ]), - ('lib/catalyst/', list(_itertools.chain( - files('livecd'), - files('targets'), - ))), - ], + data_files=_data_files, provides=[package_name], cmdclass = { 'set_version': set_version -- 2.26.2