1 |
commit: 5768d9b9d2a0fbe1c91e5e24f02448e127b2921d |
2 |
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org> |
3 |
AuthorDate: Fri Jun 7 14:42:27 2013 +0000 |
4 |
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com> |
5 |
CommitDate: Thu Nov 21 09:00:11 2013 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=5768d9b9 |
7 |
|
8 |
Streamline data_files generation with additional keys |
9 |
|
10 |
* Move data_file generation out of setup(). |
11 |
* Return per-directory keys, since distutils only uses the directory |
12 |
key and value filename (not the value path) when installing |
13 |
data_files. |
14 |
* Use relative key paths for more flexible installation. |
15 |
* Raise NotImplementedError if os.path.sep is not '/', which allows |
16 |
for simpler path handling. |
17 |
|
18 |
--- |
19 |
setup.py | 34 +++++++++++++++++----------------- |
20 |
1 file changed, 17 insertions(+), 17 deletions(-) |
21 |
|
22 |
diff --git a/setup.py b/setup.py |
23 |
index f585b99..6bc4a06 100755 |
24 |
--- a/setup.py |
25 |
+++ b/setup.py |
26 |
@@ -22,7 +22,6 @@ from __future__ import print_function |
27 |
|
28 |
import codecs as _codecs |
29 |
from distutils.core import setup as _setup, Command as _Command |
30 |
-import itertools as _itertools |
31 |
import os as _os |
32 |
|
33 |
from catalyst import __version__ |
34 |
@@ -35,7 +34,10 @@ package_name = 'catalyst' |
35 |
tag = '{0}-{1}'.format(package_name, __version__) |
36 |
|
37 |
|
38 |
-def files(root): |
39 |
+if _os.path.sep != '/': |
40 |
+ raise NotImplementedError('Non-POSIX paths are not supported') |
41 |
+ |
42 |
+def files(root, target): |
43 |
"""Iterate through all the file paths under `root` |
44 |
|
45 |
Distutils wants all paths to be written in the Unix convention |
46 |
@@ -44,11 +46,18 @@ def files(root): |
47 |
[1]: http://docs.python.org/2/distutils/setupscript.html#writing-the-setup-script |
48 |
""" |
49 |
for dirpath, dirnames, filenames in _os.walk(root): |
50 |
- for filename in filenames: |
51 |
- path = _os.path.join(dirpath, filename) |
52 |
- if _os.path.sep != '/': |
53 |
- path = path.replace(_os.path.sep, '/') |
54 |
- yield path |
55 |
+ key = _os.path.join(target, dirpath) |
56 |
+ filepaths = [_os.path.join(dirpath, filename) |
57 |
+ for filename in filenames] |
58 |
+ yield (key, filepaths) |
59 |
+ |
60 |
+ |
61 |
+_data_files = [('/etc/catalyst', ['etc/catalyst.conf','etc/catalystrc']), |
62 |
+ ('/usr/share/man/man1', ['files/catalyst.1']), |
63 |
+ ('/usr/share/man/man5', ['files/catalyst-config.5', 'files/catalyst-spec.5']) |
64 |
+ ] |
65 |
+_data_files.extend(files('livecd', 'lib/catalyst/')) |
66 |
+_data_files.extend(files('targets', 'lib/catalyst/')) |
67 |
|
68 |
|
69 |
class set_version(_Command): |
70 |
@@ -106,16 +115,7 @@ _setup( |
71 |
'{0}.base'.format(package_name), |
72 |
'{0}.targets'.format(package_name), |
73 |
], |
74 |
- data_files=[ |
75 |
- ('/etc/catalyst', [ |
76 |
- 'etc/catalyst.conf', |
77 |
- 'etc/catalystrc', |
78 |
- ]), |
79 |
- ('lib/catalyst/', list(_itertools.chain( |
80 |
- files('livecd'), |
81 |
- files('targets'), |
82 |
- ))), |
83 |
- ], |
84 |
+ data_files=_data_files, |
85 |
provides=[package_name], |
86 |
cmdclass={ |
87 |
'set_version': set_version |