From 23291d06b2aa0e2a7a8e9989a011909db2dc0954 Mon Sep 17 00:00:00 2001 From: Ram Rachum Date: Fri, 31 Jul 2009 18:53:53 +0300 Subject: [PATCH] Added doc to almostimportstdlib --- src/almostimportstdlib/__init__.py | 9 +++++ src/almostimportstdlib/almostimportstdlib.py | 5 +++ .../almostimportstdlibmaker.py | 35 ++++++++++++++++--- 3 files changed, 44 insertions(+), 5 deletions(-) diff --git a/src/almostimportstdlib/__init__.py b/src/almostimportstdlib/__init__.py index 7cb560c..0203dfd 100644 --- a/src/almostimportstdlib/__init__.py +++ b/src/almostimportstdlib/__init__.py @@ -1,2 +1,11 @@ +""" +This small package makes py2exe pack the entire Python 2.6.2 stdlib. +It does so by "almost" importing the entire stdlib. +To use it, just import it, and that's it: +py2exe will pack the entire stdlib with your executable. +If you want to change the list of modules, dig in +the code, it's very short. +""" + from almostimportstdlib import * from almostimportstdlibmaker import * \ No newline at end of file diff --git a/src/almostimportstdlib/almostimportstdlib.py b/src/almostimportstdlib/almostimportstdlib.py index bfdeac5..7d82391 100644 --- a/src/almostimportstdlib/almostimportstdlib.py +++ b/src/almostimportstdlib/almostimportstdlib.py @@ -1,3 +1,8 @@ +""" +To understand this module, +please refer to the containing pacakge's documentation. +""" + if False: import AutoComplete import AutoCompleteWindow diff --git a/src/almostimportstdlib/almostimportstdlibmaker.py b/src/almostimportstdlib/almostimportstdlibmaker.py index c5d6ffa..5415540 100644 --- a/src/almostimportstdlib/almostimportstdlibmaker.py +++ b/src/almostimportstdlib/almostimportstdlibmaker.py @@ -1,14 +1,39 @@ """ -stuff is supposed to be a list of all the modules of stdlib of Python 2.6.2. -Created with pkgutil.iter_modules() on a clean install of Python in a virtual machine. -Currently, submodules are not included (i.e. email.errors). -But it seems py2exe is careful enough to include them in the package. +This module creates a file called almostimportstdlib.py, which "almost" imports +the entire Python stdlib. (i.e., if False: import...) +Invoke `make()` to generate that file (if it's not generated already.) + +`modules` is supposed to be a list of all the modules of stdlib of Python 2.6.2. +It was created like this: + +print [thing[1] for thing in pkgutil.iter_modules()] +(on a virtual machine with a clean installation of Python 2.6.2.) + +Then copy-pasted into this file. +If you are interesting in import the stdlib of a different version of Python, +feel free to do the same procedure with the virtual machine and replace +`modules` in this file. (Please note this in this comment if you do.) + +Submodules (i.e. email.errors) are not included in `modules`, +But it seems py2exe is careful enough to include them in the package anyway, +just because their parent module might be imported. """ def make(): + """ + Generates the file almostimportstdlib.py which almost imports the stdlib. + See the documentations of the containing package and module. + """ modules=['AutoComplete', 'AutoCompleteWindow', 'AutoExpand', 'BaseHTTPServer', 'Bastion', 'Bindings', 'CGIHTTPServer', 'CallTipWindow', 'CallTips', 'Canvas', 'ClassBrowser', 'CodeContext', 'ColorDelegator', 'ConfigParser', 'Cookie', 'Debugger', 'Delegator', 'Dialog', 'DocXMLRPCServer', 'EditorWindow', 'FileDialog', 'FileList', 'FixTk', 'FormatParagraph', 'GrepDialog', 'HTMLParser', 'HyperParser', 'IOBinding', 'IdleHistory', 'MimeWriter', 'MultiCall', 'MultiStatusBar', 'ObjectBrowser', 'OutputWindow', 'ParenMatch', 'PathBrowser', 'Percolator', 'PyParse', 'PyShell', 'Queue', 'RemoteDebugger', 'RemoteObjectBrowser', 'ReplaceDialog', 'ScriptBinding', 'ScrolledList', 'ScrolledText', 'SearchDialog', 'SearchDialogBase', 'SearchEngine', 'SimpleDialog', 'SimpleHTTPServer', 'SimpleXMLRPCServer', 'SocketServer', 'StackViewer', 'StringIO', 'Tix', 'Tkconstants', 'Tkdnd', 'Tkinter', 'ToolTip', 'TreeWidget', 'UndoDelegator', 'UserDict', 'UserList', 'UserString', 'WidgetRedirector', 'WindowList', 'ZoomHeight', '_LWPCookieJar', '_MozillaCookieJar', '__future__', '_abcoll', '_bsddb', '_ctypes', '_ctypes_test', '_elementtree', '_hashlib', '_msi', '_multiprocessing', '_socket', '_sqlite3', '_ssl', '_strptime', '_testcapi', '_threading_local', '_tkinter', 'abc', 'aboutDialog', 'aifc', 'anydbm', 'ast', 'asynchat', 'asyncore', 'atexit', 'audiodev', 'base64', 'bdb', 'binhex', 'bisect', 'bsddb', 'bz2', 'cProfile', 'calendar', 'cgi', 'cgitb', 'chunk', 'cmd', 'code', 'codecs', 'codeop', 'collections', 'colorsys', 'commands', 'compileall', 'compiler', 'configDialog', 'configHandler', 'configHelpSourceEdit', 'configSectionNameDialog', 'contextlib', 'cookielib', 'copy', 'copy_reg', 'csv', 'ctypes', 'curses', 'dbhash', 'decimal', 'difflib', 'dircache', 'dis', 'distutils', 'doctest', 'dumbdbm', 'dummy_thread', 'dummy_threading', 'dynOptionMenuWidget', 'email', 'encodings', 'filecmp', 'fileinput', 'fnmatch', 'formatter', 'fpformat', 'fractions', 'ftplib', 'functools', 'genericpath', 'getopt', 'getpass', 'gettext', 'glob', 'gzip', 'hashlib', 'heapq', 'hmac', 'hotshot', 'htmlentitydefs', 'htmllib', 'httplib', 'idle', 'idlelib', 'idlever', 'ihooks', 'imaplib', 'imghdr', 'imputil', 'inspect', 'io', 'json', 'keybindingDialog', 'keyword', 'lib2to3', 'linecache', 'locale', 'logging', 'macosxSupport', 'macpath', 'macurl2path', 'mailbox', 'mailcap', 'markupbase', 'md5', 'mhlib', 'mimetools', 'mimetypes', 'mimify', 'modulefinder', 'msilib', 'multifile', 'multiprocessing', 'mutex', 'netrc', 'new', 'nntplib', 'ntpath', 'nturl2path', 'numbers', 'opcode', 'optparse', 'os', 'os2emxpath', 'pdb', 'pickle', 'pickletools', 'pipes', 'pkgutil', 'platform', 'plistlib', 'popen2', 'poplib', 'posixfile', 'posixpath', 'pprint', 'profile', 'pstats', 'pty', 'py_compile', 'pyclbr', 'pydoc', 'pydoc_topics', 'pyexpat', 'quopri', 'random', 're', 'repr', 'rexec', 'rfc822', 'rlcompleter', 'robotparser', 'rpc', 'run', 'runpy', 'sched', 'select', 'sets', 'sgmllib', 'sha', 'shelve', 'shlex', 'shutil', 'site', 'smtpd', 'smtplib', 'sndhdr', 'socket', 'sqlite3', 'sre', 'sre_compile', 'sre_constants', 'sre_parse', 'ssl', 'stat', 'statvfs', 'string', 'stringold', 'stringprep', 'struct', 'subprocess', 'sunau', 'sunaudio', 'symbol', 'symtable', 'tabbedpages', 'tabnanny', 'tarfile', 'telnetlib', 'tempfile', 'test', 'testcode', 'textView', 'textwrap', 'this', 'threading', 'timeit', 'tkColorChooser', 'tkCommonDialog', 'tkFileDialog', 'tkFont', 'tkMessageBox', 'tkSimpleDialog', 'toaiff', 'token', 'tokenize', 'trace', 'traceback', 'tty', 'turtle', 'types', 'unicodedata', 'unittest', 'urllib', 'urllib2', 'urlparse', 'user', 'uu', 'uuid', 'warnings', 'wave', 'weakref', 'webbrowser', 'whichdb', 'winsound', 'wsgiref', 'xdrlib', 'xml', 'xmllib', 'xmlrpclib', 'zipfile'] import_modules=[(" import " + module) for module in modules] - str="if False:\n" + "\n".join(import_modules) + prologue="""\"\"\" +To understand this module, +please refer to the containing pacakge's documentation. +\"\"\" + +if False: +""" + str = prologue + "\n".join(import_modules) f = open("almostimportstdlib.py","w") f.write(str) f.close()