+ EDK II Python\r
+ ReadMe\r
+ Beta Release\r
+ 23 Mar. 2012\r
+\r
+\r
+1. OVERVIEW\r
+===========\r
+This document is devoted to general information on building and setup of the\r
+Python environment for UEFI 2.3, the invocation of the interpreter, and things\r
+that make working with Python easier.\r
+\r
+It is assumed that you already have either UDK2010 or a current snapshot of\r
+the EDK II sources from www.tianocore.org, and that you can successfully build\r
+packages within that distribution.\r
+\r
+2. Release Notes\r
+================\r
+ 1) There is no input line editing. Backspace, ^C, etc. do not work.\r
+ 2) All C extension modules must be statically linked (built in)\r
+ 3) The site and os modules must exist as discrete files in ...\lib\python.27\r
+\r
+3. Getting and Building the latest version of Python\r
+======================================================\r
+ 3.1 Getting Python\r
+ ==================\r
+ Currently only version 2.7.2 of the CPython distribution is supported. The\r
+ source code can be downloaded from http://www.python.org/download/source/.\r
+\r
+ A. Within your EDK II development tree, extract the Python distribution into\r
+ AppPkg/Applications/Python. This should create the\r
+ AppPkg/Applications/Python/Python-2.7.2 directory.\r
+\r
+ B. Copy the files from PyMod-2.7.2 into the corresponding directories within\r
+ the Python-2.7.2 tree. This will overwrite existing files with files\r
+ modified for UEFI usage.\r
+\r
+ 3.2 Building Python\r
+ ===================\r
+ A. Edit Efi/config.c to enable the built-in modules you need.\r
+ Mandatory Built-in Modules:\r
+ edk2 errno imp marshal\r
+\r
+ Additional built-in modules which are required to use the help()\r
+ functionality provided by PyDoc, are:\r
+ _codecs _collections _functools _random\r
+ _sre _struct _weakref binascii\r
+ cStringIO gc itertools math\r
+ operator time\r
+\r
+ B. Edit AppPkg/AppPkg.dsc to enable (uncomment) the PythonCore.inf line\r
+ within the [Components] section.\r
+\r
+ C. Build AppPkg, which includes Python, using the standard "build" command:\r
+ For example, to build Python for an X64 CPU architecture:\r
+ build -a X64 -p AppPkg\AppPkg.dsc\r
+\r
+4. Python-related paths and files\r
+=================================\r
+Python depends upon the existence of several directories and files on the\r
+target system.\r
+\r
+ \EFI Root of the UEFI system area.\r
+ |- \Tools Location of the Python.efi executable.\r
+ |- \Boot UEFI specified Boot directory.\r
+ |- \StdLib Root of the Standard Libraries sub-tree.\r
+ |- \etc Configuration files used by libraries.\r
+ |- \tmp Temporary files created by tmpfile(), etc.\r
+ |- \lib Root of the libraries tree.\r
+ |- \python.27 Directory containing the Python library modules.\r
+ |- \lib-dynload Dynamically loadable Python extensions.\r
+ |- \site-packages Site-specific packages and modules.\r
+\r
+\r
+5. Installing Python\r
+====================\r
+These directories, on the target system, are populated from the development\r
+system as follows:\r
+\r
+ * \Efi\Tools receives a copy of Build/AppPkg/DEBUG_VS2005/X64/Python.efi.\r
+ ^^^^^ ^^^^^^\r
+ Modify the host path to match the your build type and compiler.\r
+\r
+ * The \Efi\StdLib\etc directory is populated from the StdLib/Efi/StdLib/etc\r
+ source directory.\r
+\r
+ * Directory \Efi\StdLib\lib\python.27 is populated with packages and modules\r
+ from the AppPkg/Applications/Python/Python-2.7.2/Lib directory.\r
+ The recommended minimum set of modules (.py, .pyc, and/or .pyo):\r
+ os stat ntpath warnings traceback\r
+ site types copy_reg linecache genericpath\r
+\r
+ * Python C Extension Modules built as dynamically loadable extensions go into\r
+ the \Efi\StdLib\lib\python.27\lib-dynload directory.\r
+\r
+\r
+6. Example: Enabling socket support\r
+===================================\r
+ 1. enable {"_socket", init_socket}, in Efi\config.c\r
+ 2. enable Python-2.7.2/Modules/socketmodule.c in PythonCore.inf.\r
+ 3. copy socket.py over to /Efi/StdLib/lib/python.27 on your target system.\r
+ 4. Make sure dependent modules are present(.py) or built in(.c):\r
+ functools, types, os, sys, warnings, cStringIO, StringIO, errno\r
+\r
+ 5. build -a X64 -p AppPkg\AppPkg.dsc\r
+ 6. copy Build\AppPkg\DEBUG_VS2005\X64\Python.efi to \Efi\Tools on your target system.\r
+ ^^^^ Modify as needed\r
+\r
+\r
+7. Supported C Modules\r
+======================\r
+ Module Name C File(s)\r
+ =============== =============================================\r
+ _ast Python/Python-ast.c\r
+ _bisect Modules/_bisectmodule.c\r
+ _codecs Modules/_codecsmodule.c\r
+ _codecs_cn Modules/cjkcodecs/_codecs_cn.c\r
+ _codecs_hk Modules/cjkcodecs/_codecs_hk.c\r
+ _codecs_iso2022 Modules/cjkcodecs/_codecs_iso2022.c\r
+ _codecs_jp Modules/cjkcodecs/_codecs_jp\r
+ _codecs_kr Modules/cjkcodecs/_codecs_kr\r
+ _codecs_tw Modules/cjkcodecs/_codecs_tw\r
+ _collections Modules/_collectionsmodule.c\r
+ _csv Modules/_csv.c\r
+ _functools Modules/_functoolsmodule.c\r
+ _heapq Modules/_heapqmodule.c\r
+ _io Modules/_io/_iomodule.c Modules/_io/*\r
+ _json Modules/_json.c\r
+ _md5 Modules/md5module.c Modules/md5.c\r
+ _multibytecodec Modules/cjkcodecs/_multibytecodec.c\r
+ _random Modules/_randommodule.c\r
+ _sha Modules/shamodule.c\r
+ _sha256 Modules/sha256module.c\r
+ _sha512 Modules/sha512module.c\r
+ _socket Modules/socketmodule.c\r
+ _sre Modules/_sre.c\r
+ _struct Modules/_struct.c\r
+ _symtable Modules/symtablemodule.c\r
+ _weakref Modules/_weakref.c\r
+ array Modules/arraymodule.c\r
+ binascii Modules/binascii.c\r
+ cmath Modules/cmathmodule.c\r
+ cPickle Modules/cPickle.c\r
+ cStringIO Modules/cStringIO.c\r
+ datetime Modules/datetimemodule.c\r
+ edk2 Modules/Efi/edk2module.c\r
+ errno Modules/errnomodule.c\r
+ future_builtins Modules/future_builtins.c\r
+ gc Modules/gcmodule.c\r
+ imp Python/import.c\r
+ itertools Modules/itertoolsmodule.c\r
+ marshal Python/marshal.c\r
+ math Modules/mathmodule.c Modules/_math.c\r
+ operator Modules/operator.c\r
+ parser Modules/parsermodule.c\r
+ select Modules/selectmodule.c\r
+ signal Modules/signalmodule.c\r
+ strop Modules/stropmodule.c\r
+ time Modules/timemodule.c\r
+ xxsubtype Modules/xxsubtype.c\r
+ zipimport Modules/zipimport.c\r
+ zlib Modules/zlibmodule.c Modules/zlib/*\r
+\r
+\r
+8. Tested Python Library Modules\r
+================================\r
+This is a partial list of the packages and modules of the Python Standard\r
+Library that have been tested or used in some manner.\r
+\r
+ encodings genericpath.py sha.py\r
+ importlib getopt.py SimpleHTTPServer.py\r
+ json hashlib.py site.py\r
+ pydoc_data heapq.py socket.py\r
+ xml HTMLParser.py SocketServer.py\r
+ abc.py inspect.py sre.py\r
+ argparse.py io.py sre_compile.py\r
+ ast.py keyword.py sre_constants.py\r
+ atexit.py linecache.py sre_parse.py\r
+ BaseHTTPServer.py locale.py stat.py\r
+ binhex.py md5.py string.py\r
+ bisect.py modulefinder.py StringIO.py\r
+ calendar.py ntpath.py struct.py\r
+ cmd.py numbers.py textwrap.py\r
+ codecs.py optparse.py token.py\r
+ collections.py os.py tokenize.py\r
+ copy.py platform.py traceback.py\r
+ copy_reg.py posixpath.py types.py\r
+ csv.py pydoc.py warnings.py\r
+ dummy_thread.py random.py weakref.py\r
+ fileinput.py re.py xmllib.py\r
+ formatter.py repr.py zipfile.py\r
+ functools.py runpy.py\r
+\r
+# # #\r