Changeset 3017
- Timestamp:
- 06/21/08 13:25:07 (5 years ago)
- Files:
-
- 1 modified
-
branch/UmitPlugins/umitPlugin/Containers.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branch/UmitPlugins/umitPlugin/Containers.py
r3012 r3017 31 31 from xml.dom.minidom import parseString, getDOMImplementation 32 32 from tempfile import mkstemp 33 34 # For setup functionality 35 from distutils.dist import Distribution 36 from distutils.core import setup as dist_setup 37 from distutils.command.install import install as installcmd 38 from distutils.command.install_lib import install_lib as install_libcmd 39 from distutils.command.install_egg_info import install_egg_info as install_egginfocmd 40 41 # For removing directory trees we need 42 import shutil 33 43 34 44 # FIXME: add others fields … … 156 166 157 167 class PluginWriter(object): 158 def __init__(self, out_file,fields):168 def __init__(self, **fields): 159 169 # Set to None and filter out the unused fields 160 170 … … 170 180 171 181 dirs = { 172 'sources' : '*', 173 'dist' : '*' 182 'bin' : '*', 183 'data' : '*', 184 'lib' : '*' 174 185 } 175 186 176 self.file = ZipFile( out_file, "w")187 self.file = ZipFile(fields['output'], "w") 177 188 178 189 for i in dirs: 179 self.dir_foreach( i, dirs[i])190 self.dir_foreach(os.path.join('output', i), dirs[i]) 180 191 181 192 self.file.writestr("Manifest.xml", self.create_manifest()) 182 193 self.file.close() 183 194 184 print "Plugin %s created." % out_file 185 print "" 195 print ">> Plugin %s created." % fields['output'] 186 196 187 197 def dir_foreach(self, dir, pattern): … … 199 209 200 210 self.file.write(os.path.join(path, file), 201 os.path.join( path, file))211 os.path.join(os.path.basename(path), file)) 202 212 203 213 def create_manifest(self): … … 217 227 return doc.toxml() 218 228 219 def setup(name, fields): 229 230 # 231 # distutils related class 232 233 class PlugLibInstaller(install_libcmd): 234 def finalize_options(self): 235 self.install_dir = 'output/lib' 236 install_libcmd.finalize_options(self) 237 238 class PlugInstaller(installcmd): 239 def finalize_options(self): 240 self.home = 'output' 241 installcmd.finalize_options(self) 242 243 def run(self): 244 installcmd.run(self) 245 246 class PlugEggInstaller(install_egginfocmd): 247 def run(self): 248 pass 249 250 class PlugDistribution(Distribution): 251 def __init__(self, *attrs): 252 Distribution.__init__(self, *attrs) 253 self.cmdclass['install'] = PlugInstaller 254 self.cmdclass['install_lib'] = PlugLibInstaller 255 self.cmdclass['install_egg_info'] = PlugEggInstaller 256 257 258 def setup(**attrs): 220 259 "Called to create a plugin like the dist-tools setup function" 221 260 222 # TODO: add the compile flag 223 PluginWriter("%s.ump" % name, fields) 224 225 if __name__ == "__main__": 226 PluginWriter("test/out.ump", 227 { 228 "start-file" : "main.py", 229 "url": "http://test.org", 230 "unz": "non-valid-entry" 231 } 232 ) 261 print ">> Running setup()" 262 attrs['distclass'] = PlugDistribution 263 dist_setup(**attrs) 264 265 print ">> Creating plugin" 266 PluginWriter(**attrs) 267 268 print ">> Cleaning up" 269 shutil.rmtree('build') 270 shutil.rmtree('output')
