]>
Commit | Line | Data |
---|---|---|
d78fab6b | 1 | EDK II Python\r |
2 | ReadMe\r | |
3 | Beta Release\r | |
4 | 23 Mar. 2012\r | |
5 | \r | |
6 | \r | |
7 | 1. OVERVIEW\r | |
8 | ===========\r | |
9 | This document is devoted to general information on building and setup of the\r | |
10 | Python environment for UEFI 2.3, the invocation of the interpreter, and things\r | |
11 | that make working with Python easier.\r | |
12 | \r | |
13 | It is assumed that you already have either UDK2010 or a current snapshot of\r | |
14 | the EDK II sources from www.tianocore.org, and that you can successfully build\r | |
15 | packages within that distribution.\r | |
16 | \r | |
17 | 2. Release Notes\r | |
18 | ================\r | |
19 | 1) There is no input line editing. Backspace, ^C, etc. do not work.\r | |
20 | 2) All C extension modules must be statically linked (built in)\r | |
21 | 3) The site and os modules must exist as discrete files in ...\lib\python.27\r | |
521527e0 | 22 | 4) User-specific configurations are not supported.\r |
23 | 5) Environment variables are not supported.\r | |
d78fab6b | 24 | \r |
25 | 3. Getting and Building the latest version of Python\r | |
26 | ======================================================\r | |
27 | 3.1 Getting Python\r | |
28 | ==================\r | |
29 | Currently only version 2.7.2 of the CPython distribution is supported. The\r | |
30 | source code can be downloaded from http://www.python.org/download/source/.\r | |
31 | \r | |
32 | A. Within your EDK II development tree, extract the Python distribution into\r | |
33 | AppPkg/Applications/Python. This should create the\r | |
34 | AppPkg/Applications/Python/Python-2.7.2 directory.\r | |
35 | \r | |
36 | B. Copy the files from PyMod-2.7.2 into the corresponding directories within\r | |
37 | the Python-2.7.2 tree. This will overwrite existing files with files\r | |
38 | modified for UEFI usage.\r | |
39 | \r | |
40 | 3.2 Building Python\r | |
41 | ===================\r | |
42 | A. Edit Efi/config.c to enable the built-in modules you need.\r | |
43 | Mandatory Built-in Modules:\r | |
44 | edk2 errno imp marshal\r | |
45 | \r | |
46 | Additional built-in modules which are required to use the help()\r | |
47 | functionality provided by PyDoc, are:\r | |
48 | _codecs _collections _functools _random\r | |
49 | _sre _struct _weakref binascii\r | |
50 | cStringIO gc itertools math\r | |
51 | operator time\r | |
52 | \r | |
53 | B. Edit AppPkg/AppPkg.dsc to enable (uncomment) the PythonCore.inf line\r | |
54 | within the [Components] section.\r | |
55 | \r | |
56 | C. Build AppPkg, which includes Python, using the standard "build" command:\r | |
57 | For example, to build Python for an X64 CPU architecture:\r | |
58 | build -a X64 -p AppPkg\AppPkg.dsc\r | |
59 | \r | |
60 | 4. Python-related paths and files\r | |
61 | =================================\r | |
62 | Python depends upon the existence of several directories and files on the\r | |
63 | target system.\r | |
64 | \r | |
65 | \EFI Root of the UEFI system area.\r | |
66 | |- \Tools Location of the Python.efi executable.\r | |
67 | |- \Boot UEFI specified Boot directory.\r | |
68 | |- \StdLib Root of the Standard Libraries sub-tree.\r | |
69 | |- \etc Configuration files used by libraries.\r | |
70 | |- \tmp Temporary files created by tmpfile(), etc.\r | |
71 | |- \lib Root of the libraries tree.\r | |
72 | |- \python.27 Directory containing the Python library modules.\r | |
73 | |- \lib-dynload Dynamically loadable Python extensions.\r | |
74 | |- \site-packages Site-specific packages and modules.\r | |
75 | \r | |
76 | \r | |
77 | 5. Installing Python\r | |
78 | ====================\r | |
79 | These directories, on the target system, are populated from the development\r | |
80 | system as follows:\r | |
81 | \r | |
82 | * \Efi\Tools receives a copy of Build/AppPkg/DEBUG_VS2005/X64/Python.efi.\r | |
83 | ^^^^^ ^^^^^^\r | |
84 | Modify the host path to match the your build type and compiler.\r | |
85 | \r | |
86 | * The \Efi\StdLib\etc directory is populated from the StdLib/Efi/StdLib/etc\r | |
87 | source directory.\r | |
88 | \r | |
89 | * Directory \Efi\StdLib\lib\python.27 is populated with packages and modules\r | |
90 | from the AppPkg/Applications/Python/Python-2.7.2/Lib directory.\r | |
91 | The recommended minimum set of modules (.py, .pyc, and/or .pyo):\r | |
92 | os stat ntpath warnings traceback\r | |
93 | site types copy_reg linecache genericpath\r | |
94 | \r | |
95 | * Python C Extension Modules built as dynamically loadable extensions go into\r | |
96 | the \Efi\StdLib\lib\python.27\lib-dynload directory.\r | |
97 | \r | |
98 | \r | |
99 | 6. Example: Enabling socket support\r | |
100 | ===================================\r | |
101 | 1. enable {"_socket", init_socket}, in Efi\config.c\r | |
102 | 2. enable Python-2.7.2/Modules/socketmodule.c in PythonCore.inf.\r | |
103 | 3. copy socket.py over to /Efi/StdLib/lib/python.27 on your target system.\r | |
104 | 4. Make sure dependent modules are present(.py) or built in(.c):\r | |
105 | functools, types, os, sys, warnings, cStringIO, StringIO, errno\r | |
106 | \r | |
107 | 5. build -a X64 -p AppPkg\AppPkg.dsc\r | |
108 | 6. copy Build\AppPkg\DEBUG_VS2005\X64\Python.efi to \Efi\Tools on your target system.\r | |
109 | ^^^^ Modify as needed\r | |
110 | \r | |
111 | \r | |
112 | 7. Supported C Modules\r | |
113 | ======================\r | |
114 | Module Name C File(s)\r | |
115 | =============== =============================================\r | |
116 | _ast Python/Python-ast.c\r | |
117 | _bisect Modules/_bisectmodule.c\r | |
118 | _codecs Modules/_codecsmodule.c\r | |
119 | _codecs_cn Modules/cjkcodecs/_codecs_cn.c\r | |
120 | _codecs_hk Modules/cjkcodecs/_codecs_hk.c\r | |
121 | _codecs_iso2022 Modules/cjkcodecs/_codecs_iso2022.c\r | |
122 | _codecs_jp Modules/cjkcodecs/_codecs_jp\r | |
123 | _codecs_kr Modules/cjkcodecs/_codecs_kr\r | |
124 | _codecs_tw Modules/cjkcodecs/_codecs_tw\r | |
125 | _collections Modules/_collectionsmodule.c\r | |
126 | _csv Modules/_csv.c\r | |
127 | _functools Modules/_functoolsmodule.c\r | |
128 | _heapq Modules/_heapqmodule.c\r | |
129 | _io Modules/_io/_iomodule.c Modules/_io/*\r | |
130 | _json Modules/_json.c\r | |
131 | _md5 Modules/md5module.c Modules/md5.c\r | |
132 | _multibytecodec Modules/cjkcodecs/_multibytecodec.c\r | |
133 | _random Modules/_randommodule.c\r | |
134 | _sha Modules/shamodule.c\r | |
135 | _sha256 Modules/sha256module.c\r | |
136 | _sha512 Modules/sha512module.c\r | |
137 | _socket Modules/socketmodule.c\r | |
138 | _sre Modules/_sre.c\r | |
139 | _struct Modules/_struct.c\r | |
140 | _symtable Modules/symtablemodule.c\r | |
141 | _weakref Modules/_weakref.c\r | |
142 | array Modules/arraymodule.c\r | |
143 | binascii Modules/binascii.c\r | |
144 | cmath Modules/cmathmodule.c\r | |
145 | cPickle Modules/cPickle.c\r | |
146 | cStringIO Modules/cStringIO.c\r | |
147 | datetime Modules/datetimemodule.c\r | |
148 | edk2 Modules/Efi/edk2module.c\r | |
149 | errno Modules/errnomodule.c\r | |
150 | future_builtins Modules/future_builtins.c\r | |
151 | gc Modules/gcmodule.c\r | |
152 | imp Python/import.c\r | |
153 | itertools Modules/itertoolsmodule.c\r | |
154 | marshal Python/marshal.c\r | |
155 | math Modules/mathmodule.c Modules/_math.c\r | |
156 | operator Modules/operator.c\r | |
157 | parser Modules/parsermodule.c\r | |
158 | select Modules/selectmodule.c\r | |
159 | signal Modules/signalmodule.c\r | |
160 | strop Modules/stropmodule.c\r | |
161 | time Modules/timemodule.c\r | |
162 | xxsubtype Modules/xxsubtype.c\r | |
163 | zipimport Modules/zipimport.c\r | |
164 | zlib Modules/zlibmodule.c Modules/zlib/*\r | |
165 | \r | |
166 | \r | |
167 | 8. Tested Python Library Modules\r | |
168 | ================================\r | |
169 | This is a partial list of the packages and modules of the Python Standard\r | |
170 | Library that have been tested or used in some manner.\r | |
171 | \r | |
172 | encodings genericpath.py sha.py\r | |
173 | importlib getopt.py SimpleHTTPServer.py\r | |
174 | json hashlib.py site.py\r | |
175 | pydoc_data heapq.py socket.py\r | |
176 | xml HTMLParser.py SocketServer.py\r | |
177 | abc.py inspect.py sre.py\r | |
178 | argparse.py io.py sre_compile.py\r | |
179 | ast.py keyword.py sre_constants.py\r | |
180 | atexit.py linecache.py sre_parse.py\r | |
181 | BaseHTTPServer.py locale.py stat.py\r | |
182 | binhex.py md5.py string.py\r | |
183 | bisect.py modulefinder.py StringIO.py\r | |
184 | calendar.py ntpath.py struct.py\r | |
185 | cmd.py numbers.py textwrap.py\r | |
186 | codecs.py optparse.py token.py\r | |
187 | collections.py os.py tokenize.py\r | |
188 | copy.py platform.py traceback.py\r | |
189 | copy_reg.py posixpath.py types.py\r | |
190 | csv.py pydoc.py warnings.py\r | |
191 | dummy_thread.py random.py weakref.py\r | |
192 | fileinput.py re.py xmllib.py\r | |
193 | formatter.py repr.py zipfile.py\r | |
194 | functools.py runpy.py\r | |
195 | \r | |
196 | # # #\r |