Package logilab-common-0 ::
Package 36 ::
Package 1 ::
Module twisted_distutils
|
|
1 """Distutils extensions for twisted framework.
2
3 This module enables the installation of plugins.tml files using standard
4 distutils syntax. It adds the following commands to the standard
5 setup.py commands:
6 - build_twisted_plugins: build (i.e. copy) plugins
7 - install_twisted_plugins: install plugins
8
9 Additionally, the following commands have been modified to deal with
10 plugins files:
11 - sdist
12 - build
13 - install
14
15 To use these extenstion, you should import the setup fonction from this
16 module, and use it normally. To list the plugins.tml files, use the
17 twisted_plugins keyword argument to the setup function::
18
19 from twisted_distutils import setup # you can also import Extension if needed
20
21 if __name__ == '__main__':
22 setup(name='my_twisted_app',
23 version='1.0',
24 author='me',
25 packages=['my_package'],
26 twisted_plugins = ['my_package/plugins.tml'])
27
28 Note that you can use this to install files that are not twisted plugins in any
29 package directory of your application.
30
31 :copyright: 2000-2008 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
32 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
33 :license: General Public License version 2 - http://www.gnu.org/licenses
34 """
35 __docformat__ = "restructuredtext en"
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50 from warnings import warn
51 warn('this module is deprecated and will disappear in a near release',
52 DeprecationWarning, stacklevel=1)
53
54 from distutils.core import Distribution, Command
55 from distutils.command.install import install
56 from distutils.command.build import build
57 from distutils.command.sdist import sdist
58 from distutils.dep_util import newer
59 from distutils.util import convert_path
60 import os
61
68
80
81
93
95
96 description = "\"build\" twisted plugins (copy)"
97
98 user_options = [
99 ('build-dir=', 'd', "directory to \"build\" (copy) to"),
100 ('force', 'f', "forcibly build everything (ignore file timestamps"),
101 ]
102
103 boolean_options = ['force']
104
105
107 self.build_dir = None
108 self.twisted_plugins = None
109 self.force = None
110 self.outfiles = None
111
113 return self.twisted_plugins
114
116 self.set_undefined_options('build',
117 ('build_lib', 'build_dir'),
118 ('force', 'force'))
119 self.twisted_plugins = self.distribution.twisted_plugins
120
121
126
127
129 """Copy each plugin listed in 'self.twisted_plugins'.
130 """
131 self.mkpath(self.build_dir)
132 for plugin in self.twisted_plugins:
133 adjust = 0
134 plugin = convert_path(plugin)
135 outfile = os.path.join(self.build_dir, plugin)
136 if not self.force and not newer(plugin, outfile):
137 self.announce("not copying %s (up-to-date)" % plugin)
138 continue
139
140
141
142
143 try:
144 f = open(plugin, "r")
145 except IOError:
146 if not self.dry_run:
147 raise
148 f = None
149 else:
150 f.close()
151 self.copy_file(plugin, outfile)
152
153
155
156 description = "install twisted plugins"
157
158 user_options = [
159 ('install-dir=', 'd', "directory to install scripts to"),
160 ('build-dir=','b', "build directory (where to install from)"),
161 ('force', 'f', "force installation (overwrite existing files)"),
162 ('skip-build', None, "skip the build steps"),
163 ]
164
165 boolean_options = ['force', 'skip-build']
166
167
169 self.install_dir = None
170 self.force = 0
171 self.build_dir = None
172 self.skip_build = None
173
175 self.set_undefined_options('build', ('build_lib', 'build_dir'))
176 self.set_undefined_options('install',
177 ('install_lib', 'install_dir'),
178 ('force', 'force'),
179 ('skip_build', 'skip_build'),
180 )
181
183 if not self.skip_build:
184 self.run_command('build_twisted_plugins')
185 self.outfiles = self.copy_tree(self.build_dir, self.install_dir)
186
189
191 return self.outfiles or []
192
193
194
205
207 return self.twisted_plugins and len(self.twisted_plugins) > 0
208
209
214