generate-manifest-2.5.py: generate python-modules package
[openembedded.git] / contrib / python / generate-manifest-2.5.py
1 #!/usr/bin/env python
2
3 # generate Python Manifest for the OpenEmbedded build system
4 # (C) 2002-2008 Michael 'Mickey' Lauer <mlauer@vanille-media.de>
5 # (C) 2007 Jeremy Laine
6 # licensed under MIT, see COPYING.MIT
7
8 import os
9 import sys
10 import time
11
12 VERSION = "2.5.2"
13 BASEREV = 0
14
15 __author__ = "Michael 'Mickey' Lauer <mlauer@vanille-media.de>"
16 __version__ = "20081102"
17
18 class MakefileMaker:
19
20     def __init__( self, outfile ):
21         """initialize"""
22         self.packages = {}
23         self.targetPrefix = "${libdir}/python%s/" % VERSION[:3]
24         self.output = outfile
25         self.out( """\
26 # WARNING: This file is AUTO GENERATED: Manual edits will be lost next time I regenerate the file.
27 # Generator: '%s' Version %s (C) 2002-2008 Michael 'Mickey' Lauer <mlauer@vanille-media.de>
28 # Visit the Python for Embedded Systems Site => http://www.Vanille.de/projects/python.spy
29 """ % ( sys.argv[0], __version__ ) )
30
31     #
32     # helper functions
33     #
34
35     def out( self, data ):
36         """print a line to the output file"""
37         self.output.write( "%s\n" % data )
38
39     def setPrefix( self, targetPrefix ):
40         """set a file prefix for addPackage files"""
41         self.targetPrefix = targetPrefix
42
43     def doProlog( self ):
44         self.out( """ """ )
45         self.out( "" )
46
47     def addPackage( self, revision, name, description, dependencies, filenames ):
48         """add a package to the Makefile"""
49         if type( filenames ) == type( "" ):
50             filenames = filenames.split()
51         fullFilenames = []
52         for filename in filenames:
53             if filename[0] != "$":
54                 fullFilenames.append( "%s%s" % ( self.targetPrefix, filename ) )
55             else:
56                 fullFilenames.append( filename )
57         self.packages[name] = revision, description, dependencies, fullFilenames
58
59     def doBody( self ):
60         """generate body of Makefile"""
61
62         global VERSION
63
64         #
65         # generate provides line
66         # 
67  
68         provideLine = 'PROVIDES+="'
69         for name in self.packages:
70             provideLine += "%s " % name
71         provideLine += '"'
72
73         self.out( provideLine )
74         self.out( "" )       
75
76         #
77         # generate package line
78         #
79
80         packageLine = 'PACKAGES="'
81         for name in self.packages:
82             packageLine += "%s " % name
83         packageLine += ' python-modules"'
84
85         self.out( packageLine )
86         self.out( "" )
87
88         #
89         # generate package variables
90         #
91
92         for name, data in self.packages.iteritems():
93             rev, desc, deps, files = data
94
95             #
96             # write out the description, revision and dependencies
97             #
98             self.out( 'DESCRIPTION_%s="%s"' % ( name, desc ) )
99             self.out( 'PR_%s="ml%d"' % ( name, rev + BASEREV ) )
100             self.out( 'RDEPENDS_%s="%s"' % ( name, deps ) )
101
102             line = 'FILES_%s="' % name
103
104             #
105             # check which directories to make in the temporary directory
106             #
107
108             dirset = {} # if python had a set-datatype this would be sufficient. for now, we're using a dict instead.
109             for target in files:
110                 dirset[os.path.dirname( target )] = True
111
112             #
113             # generate which files to copy for the target (-dfR because whole directories are also allowed)
114             #
115
116             for target in files:
117                 line += "%s " % target
118
119             line += '"'
120             self.out( line )
121             self.out( "" )
122
123         self.out( 'DESCRIPTION_python-modules="All Python modules"' )
124         line = 'RDEPENDS_python-modules="'
125
126         for name, data in self.packages.iteritems():
127             if name != 'python-core-dbg':
128                 line += "%s " % name
129
130         self.out( "%s \"" % line )
131         self.out( 'ALLOW_EMPTY_python-modules = "1"' )
132
133     def doEpilog( self ):
134         self.out( """""" )
135         self.out( "" )
136
137     def make( self ):
138         self.doProlog()
139         self.doBody()
140         self.doEpilog()
141
142 if __name__ == "__main__":
143
144     if len( sys.argv ) > 1:
145         os.popen( "rm -f ./%s" % sys.argv[1] )
146         outfile = file( sys.argv[1], "w" )
147     else:
148         outfile = sys.stdout
149
150     m = MakefileMaker( outfile )
151
152     # Add packages here. Only specify dlopen-style library dependencies here, no ldd-style dependencies!
153     # Parameters: revision, name, description, dependencies, filenames
154     #
155
156     m.addPackage( 0, "python-core", "Python Interpreter and core modules (needed!)", "",
157     "__future__.* copy.* copy_reg.* ConfigParser.* " +
158     "getopt.* linecache.* new.* " +
159     "os.* posixpath.* struct.* " +
160     "warnings.* site.* stat.* " +
161     "UserDict.* UserList.* UserString.* " +
162     "lib-dynload/binascii.so lib-dynload/_struct.so lib-dynload/time.so " +
163     "lib-dynload/xreadlines.so types.* ${bindir}/python*" )
164
165     m.addPackage( 0, "python-core-dbg", "Python core module debug information", "python-core",
166     "lib-dynload/.debug ${bindir}/.debug ${libdir}/.debug" )
167
168     m.addPackage( 0, "python-devel", "Python Development Package", "python-core",
169     "${includedir} config" ) # package
170
171     m.addPackage( 0, "python-idle", "Python Integrated Development Environment", "python-core python-tkinter",
172     "${bindir}/idle idlelib" ) # package
173
174     m.addPackage( 0, "python-pydoc", "Python Interactive Help Support", "python-core python-lang python-stringold python-re",
175     "${bindir}/pydoc pydoc.*" )
176
177     m.addPackage( 0, "python-smtpd", "Python Simple Mail Transport Daemon", "python-core python-netserver python-email python-mime",
178     "${bindir}/smtpd.*" )
179
180     m.addPackage( 0, "python-audio", "Python Audio Handling", "python-core",
181     "wave.* chunk.* sndhdr.* lib-dynload/ossaudiodev.so lib-dynload/audioop.so" )
182
183     m.addPackage( 0, "python-bsddb", "Python Berkeley Database Bindings", "python-core",
184     "bsddb lib-dynload/_bsddb.so" ) # package
185
186     m.addPackage( 0, "python-codecs", "Python Codecs, Encodings & i18n Support", "python-core python-lang",
187     "codecs.* encodings gettext.* locale.* lib-dynload/_locale.so lib-dynload/unicodedata.so stringprep.* xdrlib.*" )
188
189     m.addPackage( 0, "python-compile", "Python Bytecode Compilation Support", "python-core",
190     "py_compile.* compileall.*" )
191
192     m.addPackage( 0, "python-compiler", "Python Compiler Support", "python-core",
193     "compiler" ) # package
194
195     m.addPackage( 0, "python-compression", "Python High Level Compression Support", "python-core python-zlib",
196     "gzip.* zipfile.* tarfile.*" )
197
198     m.addPackage( 0, "python-crypt", "Python Basic Cryptographic and Hashing Support", "python-core",
199     "hashlib.* md5.* sha.* lib-dynload/crypt.so lib-dynload/_hashlib.so lib-dynload/_sha256.so lib-dynload/_sha512.so" )
200
201     m.addPackage( 0, "python-textutils", "Python Option Parsing, Text Wrapping and Comma-Separated-Value Support", "python-core python-io python-re python-stringold",
202     "lib-dynload/_csv.so csv.* optparse.* textwrap.*" )
203
204     m.addPackage( 0, "python-curses", "Python Curses Support", "python-core",
205     "curses lib-dynload/_curses.so lib-dynload/_curses_panel.so" ) # directory + low level module
206
207     m.addPackage( 0, "python-ctypes", "Python C Types Support", "python-core",
208     "ctypes lib-dynload/_ctypes.so" ) # directory + low level module
209
210     m.addPackage( 0, "python-datetime", "Python Calendar and Time support", "python-core python-codecs",
211     "_strptime.* calendar.* lib-dynload/datetime.so" )
212
213     m.addPackage( 0, "python-db", "Python File-Based Database Support", "python-core",
214     "anydbm.* dumbdbm.* whichdb.* " )
215
216     m.addPackage( 0, "python-debugger", "Python Debugger", "python-core python-io python-lang python-re python-stringold python-shell python-pprint",
217     "bdb.* pdb.*" )
218
219     m.addPackage( 0, "python-difflib", "Python helpers for computing deltas between objects.", "python-lang python-re",
220     "difflib.*" )
221
222     m.addPackage( 0, "python-distutils", "Python Distribution Utilities", "python-core",
223     "config distutils" ) # package
224
225     m.addPackage( 0, "python-doctest", "Python framework for running examples in docstrings.", "python-core python-lang python-io python-re python-unittest python-debugger python-difflib",
226     "doctest.*" )
227
228     m.addPackage( 0, "python-email", "Python Email Support", "python-core python-io python-re python-mime python-audio python-image",
229     "email" ) # package
230
231     m.addPackage( 0, "python-fcntl", "Python's fcntl Interface", "python-core",
232     "lib-dynload/fcntl.so" )
233
234     m.addPackage( 0, "python-hotshot", "Python Hotshot Profiler", "python-core",
235     "hotshot lib-dynload/_hotshot.so" )
236
237     m.addPackage( 0, "python-html", "Python HTML Processing", "python-core",
238     "formatter.* htmlentitydefs.* htmllib.* markupbase.* sgmllib.* " )
239
240     m.addPackage( 0, "python-gdbm", "Python GNU Database Support", "python-core",
241     "lib-dynload/gdbm.so" )
242
243     m.addPackage( 0, "python-image", "Python Graphical Image Handling", "python-core",
244     "colorsys.* imghdr.* lib-dynload/imageop.so lib-dynload/rgbimg.so" )
245
246     m.addPackage( 0, "python-io", "Python Low-Level I/O", "python-core python-math",
247     "lib-dynload/_socket.so lib-dynload/_ssl.so lib-dynload/select.so lib-dynload/termios.so lib-dynload/cStringIO.so "
248     "pipes.* socket.* tempfile.* StringIO.* " )
249
250     m.addPackage( 0, "python-lang", "Python Low-Level Language Support", "python-core",
251     "lib-dynload/array.so lib-dynload/parser.so lib-dynload/operator.so lib-dynload/_weakref.so " +
252     "lib-dynload/itertools.so lib-dynload/collections.so lib-dynload/_bisect.so lib-dynload/_heapq.so " +
253     "atexit.* bisect.* code.* codeop.* dis.* heapq.* inspect.* keyword.* opcode.* symbol.* repr.* token.* " +
254     " tokenize.* traceback.* linecache.* weakref.*" )
255
256     m.addPackage( 0, "python-logging", "Python Logging Support", "python-core python-io python-lang python-pickle python-stringold",
257     "logging" ) # package
258
259     m.addPackage( 0, "python-tkinter", "Python Tcl/Tk Bindings", "python-core",
260     "lib-dynload/_tkinter.so lib-tk" ) # package
261
262     m.addPackage( 0, "python-math", "Python Math Support", "python-core",
263     "lib-dynload/cmath.so lib-dynload/math.so lib-dynload/_random.so random.* sets.*" )
264
265     m.addPackage( 0, "python-mime", "Python MIME Handling APIs", "python-core python-io",
266     "mimetools.* uu.* quopri.* rfc822.*" )
267
268     m.addPackage( 0, "python-mmap", "Python Memory-Mapped-File Support", "python-core python-io",
269     "lib-dynload/mmap.so " )
270
271     m.addPackage( 0, "python-unixadmin", "Python Unix Administration Support", "python-core",
272     "lib-dynload/nis.so lib-dynload/grp.so lib-dynload/pwd.so getpass.*" )
273
274     m.addPackage( 0, "python-netclient", "Python Internet Protocol Clients", "python-core python-crypt python-datetime python-io python-lang python-logging python-mime",
275     "*Cookie*.* " + 
276     "base64.* cookielib.* ftplib.* gopherlib.* hmac.* httplib.* mimetypes.* nntplib.* poplib.* smtplib.* telnetlib.* urllib.* urllib2.* urlparse.*" )
277
278     m.addPackage( 0, "python-netserver", "Python Internet Protocol Servers", "python-core python-netclient",
279     "cgi.* BaseHTTPServer.* SimpleHTTPServer.* SocketServer.*" )
280
281     m.addPackage( 0, "python-pickle", "Python Persistence Support", "python-core python-codecs python-io python-re",
282     "pickle.* shelve.* lib-dynload/cPickle.so" )
283
284     m.addPackage( 0, "python-pkgutil", "Python Package Extension Utility Support", "python-core",
285     "pkgutil.*")
286
287     m.addPackage( 0, "python-pprint", "Python Pretty-Print Support", "python-core",
288     "pprint.*" )
289
290     m.addPackage( 0, "python-profile", "Python Basic Profiling Support", "python-core python-textutils",
291     "profile.* pstats.* cProfile.* lib-dynload/_lsprof.so" )
292
293     m.addPackage( 0, "python-re", "Python Regular Expression APIs", "python-core",
294     "re.* sre.* sre_compile.* sre_constants* sre_parse.*" ) # _sre is builtin
295
296     m.addPackage( 0, "python-readline", "Python Readline Support", "python-core",
297     "lib-dynload/readline.so rlcompleter.*" )
298
299     m.addPackage( 0, "python-resource", "Python Resource Control Interface", "python-core",
300     "lib-dynload/resource.so" )
301
302     m.addPackage( 0, "python-shell", "Python Shell-Like Functionality", "python-core python-re",
303     "cmd.* commands.* dircache.* fnmatch.* glob.* popen2.* shlex.* shutil.*" )
304
305     m.addPackage( 0, "python-robotparser", "Python robots.txt parser", "python-core python-netclient",
306     "robotparser.*")
307
308     m.addPackage( 0, "python-subprocess", "Python Subprocess Support", "python-core python-io python-re python-fcntl python-pickle",
309     "subprocess.*" )
310
311     m.addPackage( 2, "python-sqlite3", "Python Sqlite3 Database Support", "python-core python-datetime python-lang python-crypt python-io python-threading python-zlib",
312     "lib-dynload/_sqlite3.so sqlite3/dbapi2.* sqlite3/__init__.*" )
313
314     m.addPackage( 0, "python-sqlite3-tests", "Python Sqlite3 Database Support Tests", "python-core python-sqlite3",
315     "sqlite3/test" )
316
317     m.addPackage( 0, "python-stringold", "Python String APIs [deprecated]", "python-core python-re",
318     "lib-dynload/strop.so string.*" )
319
320     m.addPackage( 0, "python-syslog", "Python's Syslog Interface", "python-core",
321     "lib-dynload/syslog.so" )
322
323     m.addPackage( 0, "python-terminal", "Python Terminal Controlling Support", "python-core python-io",
324     "pty.* tty.*" )
325
326     m.addPackage( 0, "python-tests", "Python Tests", "python-core",
327     "test" ) # package
328
329     m.addPackage( 0, "python-threading", "Python Threading & Synchronization Support", "python-core python-lang",
330     "_threading_local.* dummy_thread.* dummy_threading.* mutex.* threading.* Queue.*" )
331
332     m.addPackage( 0, "python-unittest", "Python Unit Testing Framework", "python-core python-stringold python-lang",
333     "unittest.*" )
334
335     m.addPackage( 0, "python-xml", "Python basic XML support.", "python-core python-re",
336     "lib-dynload/pyexpat.so xml xmllib.*" ) # package
337
338     m.addPackage( 0, "python-xmlrpc", "Python XMLRPC Support", "python-core python-xml python-netserver python-lang",
339     "xmlrpclib.* SimpleXMLRPCServer.*" )
340
341     m.addPackage( 0, "python-zlib", "Python zlib Support.", "python-core",
342     "lib-dynload/zlib.so" )
343
344     m.addPackage( 0, "python-mailbox", "Python Mailbox Format Support", "python-core python-mime",
345     "mailbox.*" )
346
347     # FIXME consider adding to python-compression
348     m.addPackage( 0, "python-bzip2", "Python bzip2 support", "python-core",
349     "lib-dynload/bz2.so" )
350
351     # FIXME consider adding to some higher level package
352     m.addPackage( 0, "python-elementtree", "Python elementree", "python-core",
353     "lib-dynload/_elementtree.so" )
354
355     m.make()