]>
Commit | Line | Data |
---|---|---|
d78fab6b | 1 | EDK II Python\r |
27c19606 DM |
2 | ReadMe\r |
3 | Version 2.7.2\r | |
4 | Release 1.02\r | |
5 | 18 Jan. 2013\r | |
d78fab6b | 6 | \r |
7 | \r | |
8 | 1. OVERVIEW\r | |
9 | ===========\r | |
10 | This document is devoted to general information on building and setup of the\r | |
11 | Python environment for UEFI 2.3, the invocation of the interpreter, and things\r | |
12 | that make working with Python easier.\r | |
13 | \r | |
14 | It is assumed that you already have either UDK2010 or a current snapshot of\r | |
15 | the EDK II sources from www.tianocore.org, and that you can successfully build\r | |
16 | packages within that distribution.\r | |
17 | \r | |
18 | 2. Release Notes\r | |
19 | ================\r | |
aafc4dcf DM |
20 | 1) All C extension modules must be statically linked (built in)\r |
21 | 2) The site and os modules must exist as discrete files in ...\lib\python.27\r | |
22 | 3) User-specific configurations are not supported.\r | |
23 | 4) Environment variables are not supported.\r | |
d78fab6b | 24 | \r |
aafc4dcf | 25 | 3. Getting and Building Python\r |
d78fab6b | 26 | ======================================================\r |
27 | 3.1 Getting Python\r | |
28 | ==================\r | |
27c19606 DM |
29 | For development ease, a subset of the Python 2.7.2 distribution has been\r |
30 | included in the AppPkg source tree. If a full distribution is desired, the\r | |
31 | Python-2.7.2 directory can be removed or renamed and the full source code\r | |
32 | downloaded from http://www.python.org/ftp/python/2.7.2/.\r | |
d78fab6b | 33 | \r |
34 | A. Within your EDK II development tree, extract the Python distribution into\r | |
35 | AppPkg/Applications/Python. This should create the\r | |
36 | AppPkg/Applications/Python/Python-2.7.2 directory.\r | |
37 | \r | |
38 | B. Copy the files from PyMod-2.7.2 into the corresponding directories within\r | |
39 | the Python-2.7.2 tree. This will overwrite existing files with files\r | |
40 | modified for UEFI usage.\r | |
41 | \r | |
42 | 3.2 Building Python\r | |
43 | ===================\r | |
44 | A. Edit Efi/config.c to enable the built-in modules you need.\r | |
45 | Mandatory Built-in Modules:\r | |
46 | edk2 errno imp marshal\r | |
47 | \r | |
48 | Additional built-in modules which are required to use the help()\r | |
49 | functionality provided by PyDoc, are:\r | |
50 | _codecs _collections _functools _random\r | |
51 | _sre _struct _weakref binascii\r | |
52 | cStringIO gc itertools math\r | |
53 | operator time\r | |
54 | \r | |
55 | B. Edit AppPkg/AppPkg.dsc to enable (uncomment) the PythonCore.inf line\r | |
56 | within the [Components] section.\r | |
57 | \r | |
58 | C. Build AppPkg, which includes Python, using the standard "build" command:\r | |
59 | For example, to build Python for an X64 CPU architecture:\r | |
60 | build -a X64 -p AppPkg\AppPkg.dsc\r | |
61 | \r | |
62 | 4. Python-related paths and files\r | |
63 | =================================\r | |
64 | Python depends upon the existence of several directories and files on the\r | |
65 | target system.\r | |
66 | \r | |
67 | \EFI Root of the UEFI system area.\r | |
68 | |- \Tools Location of the Python.efi executable.\r | |
69 | |- \Boot UEFI specified Boot directory.\r | |
70 | |- \StdLib Root of the Standard Libraries sub-tree.\r | |
71 | |- \etc Configuration files used by libraries.\r | |
72 | |- \tmp Temporary files created by tmpfile(), etc.\r | |
73 | |- \lib Root of the libraries tree.\r | |
27c19606 DM |
74 | |- \python.27 Directory containing the Python library\r |
75 | | modules.\r | |
d78fab6b | 76 | |- \lib-dynload Dynamically loadable Python extensions.\r |
77 | |- \site-packages Site-specific packages and modules.\r | |
78 | \r | |
79 | \r | |
80 | 5. Installing Python\r | |
81 | ====================\r | |
82 | These directories, on the target system, are populated from the development\r | |
83 | system as follows:\r | |
84 | \r | |
85 | * \Efi\Tools receives a copy of Build/AppPkg/DEBUG_VS2005/X64/Python.efi.\r | |
27c19606 | 86 | ^^^^^ ^^^^^^^^^^\r |
d78fab6b | 87 | Modify the host path to match the your build type and compiler.\r |
88 | \r | |
89 | * The \Efi\StdLib\etc directory is populated from the StdLib/Efi/StdLib/etc\r | |
90 | source directory.\r | |
91 | \r | |
92 | * Directory \Efi\StdLib\lib\python.27 is populated with packages and modules\r | |
93 | from the AppPkg/Applications/Python/Python-2.7.2/Lib directory.\r | |
94 | The recommended minimum set of modules (.py, .pyc, and/or .pyo):\r | |
95 | os stat ntpath warnings traceback\r | |
96 | site types copy_reg linecache genericpath\r | |
97 | \r | |
98 | * Python C Extension Modules built as dynamically loadable extensions go into\r | |
27c19606 DM |
99 | the \Efi\StdLib\lib\python.27\lib-dynload directory. This functionality is\r |
100 | not yet implemented.\r | |
d78fab6b | 101 | \r |
102 | \r | |
103 | 6. Example: Enabling socket support\r | |
104 | ===================================\r | |
105 | 1. enable {"_socket", init_socket}, in Efi\config.c\r | |
106 | 2. enable Python-2.7.2/Modules/socketmodule.c in PythonCore.inf.\r | |
107 | 3. copy socket.py over to /Efi/StdLib/lib/python.27 on your target system.\r | |
108 | 4. Make sure dependent modules are present(.py) or built in(.c):\r | |
109 | functools, types, os, sys, warnings, cStringIO, StringIO, errno\r | |
110 | \r | |
111 | 5. build -a X64 -p AppPkg\AppPkg.dsc\r | |
27c19606 DM |
112 | 6. copy Build\AppPkg\DEBUG_VS2005\X64\Python.efi to \Efi\Tools on your\r |
113 | target system. Replace "DEBUG_VS2005\X64", in the source path, with\r | |
114 | values appropriate for your tool chain and processor architecture.\r | |
115 | \r | |
116 | \r | |
117 | 7. Running Python\r | |
118 | =================\r | |
119 | Python must currently be run from an EFI FAT-32 partition, or volume, under\r | |
120 | the UEFI Shell. At the Shell prompt enter the desired volume name, followed\r | |
121 | by a colon ':', then press Enter. Python can then be executed by typing its\r | |
122 | name, followed by any desired options and arguments.\r | |
123 | \r | |
124 | EXAMPLE:\r | |
125 | 2.0 Shell> fs0:\r | |
126 | 2.0 FS0:\> python\r | |
127 | Python 2.7.2 (default, Oct 13 2015, 16:21:53) [C] on uefi\r | |
128 | Type "help", "copyright", "credits" or "license" for more information.\r | |
129 | >>> exit()\r | |
130 | 2.0 FS0:\>\r | |
131 | \r | |
132 | NOTE:\r | |
133 | Python, as distributed, sends its interactive prompts to stderr. If\r | |
134 | STDERR isn't enabled in UEFI Setup so that it's output goes to the\r | |
135 | console, it may appear that Python hangs on startup. If this happens,\r | |
136 | one may be able to rectify the condition by typing "exit()" followed\r | |
137 | by <enter> to exit out of Python. Then, type "exit" at the Shell prompt\r | |
138 | which should enter Setup where you can use the Boot Maintenance\r | |
139 | Manager to modify your Console settings.\r | |
140 | \r | |
141 | NOTE:\r | |
142 | Some platforms don't include the Setup utility, or don't allow STDERR to\r | |
143 | be modified. In these cases, Python may be started with the '-#' option\r | |
144 | which will cause stderr to be the same as stdout and should allow\r | |
145 | Python to be used interactively on those platforms.\r | |
146 | \r | |
147 | Depending upon the version of Shell you are using, it may be necessary\r | |
148 | to escape the '#' character so that the Shell doesn't interpret it as\r | |
149 | the start of a comment. The escape character is '^'.\r | |
150 | Example:\r | |
151 | python -^# -V\r | |
152 | \r | |
153 | 8. Supported C Modules\r | |
d78fab6b | 154 | ======================\r |
155 | Module Name C File(s)\r | |
156 | =============== =============================================\r | |
157 | _ast Python/Python-ast.c\r | |
158 | _bisect Modules/_bisectmodule.c\r | |
159 | _codecs Modules/_codecsmodule.c\r | |
160 | _codecs_cn Modules/cjkcodecs/_codecs_cn.c\r | |
161 | _codecs_hk Modules/cjkcodecs/_codecs_hk.c\r | |
162 | _codecs_iso2022 Modules/cjkcodecs/_codecs_iso2022.c\r | |
163 | _codecs_jp Modules/cjkcodecs/_codecs_jp\r | |
164 | _codecs_kr Modules/cjkcodecs/_codecs_kr\r | |
165 | _codecs_tw Modules/cjkcodecs/_codecs_tw\r | |
166 | _collections Modules/_collectionsmodule.c\r | |
167 | _csv Modules/_csv.c\r | |
168 | _functools Modules/_functoolsmodule.c\r | |
169 | _heapq Modules/_heapqmodule.c\r | |
170 | _io Modules/_io/_iomodule.c Modules/_io/*\r | |
171 | _json Modules/_json.c\r | |
172 | _md5 Modules/md5module.c Modules/md5.c\r | |
173 | _multibytecodec Modules/cjkcodecs/_multibytecodec.c\r | |
174 | _random Modules/_randommodule.c\r | |
175 | _sha Modules/shamodule.c\r | |
176 | _sha256 Modules/sha256module.c\r | |
177 | _sha512 Modules/sha512module.c\r | |
178 | _socket Modules/socketmodule.c\r | |
179 | _sre Modules/_sre.c\r | |
180 | _struct Modules/_struct.c\r | |
181 | _symtable Modules/symtablemodule.c\r | |
182 | _weakref Modules/_weakref.c\r | |
183 | array Modules/arraymodule.c\r | |
184 | binascii Modules/binascii.c\r | |
185 | cmath Modules/cmathmodule.c\r | |
186 | cPickle Modules/cPickle.c\r | |
187 | cStringIO Modules/cStringIO.c\r | |
188 | datetime Modules/datetimemodule.c\r | |
189 | edk2 Modules/Efi/edk2module.c\r | |
190 | errno Modules/errnomodule.c\r | |
191 | future_builtins Modules/future_builtins.c\r | |
192 | gc Modules/gcmodule.c\r | |
193 | imp Python/import.c\r | |
194 | itertools Modules/itertoolsmodule.c\r | |
195 | marshal Python/marshal.c\r | |
196 | math Modules/mathmodule.c Modules/_math.c\r | |
197 | operator Modules/operator.c\r | |
198 | parser Modules/parsermodule.c\r | |
199 | select Modules/selectmodule.c\r | |
200 | signal Modules/signalmodule.c\r | |
201 | strop Modules/stropmodule.c\r | |
202 | time Modules/timemodule.c\r | |
203 | xxsubtype Modules/xxsubtype.c\r | |
204 | zipimport Modules/zipimport.c\r | |
205 | zlib Modules/zlibmodule.c Modules/zlib/*\r | |
206 | \r | |
207 | \r | |
27c19606 | 208 | 9. Tested Python Library Modules\r |
d78fab6b | 209 | ================================\r |
210 | This is a partial list of the packages and modules of the Python Standard\r | |
211 | Library that have been tested or used in some manner.\r | |
212 | \r | |
213 | encodings genericpath.py sha.py\r | |
214 | importlib getopt.py SimpleHTTPServer.py\r | |
215 | json hashlib.py site.py\r | |
216 | pydoc_data heapq.py socket.py\r | |
217 | xml HTMLParser.py SocketServer.py\r | |
218 | abc.py inspect.py sre.py\r | |
219 | argparse.py io.py sre_compile.py\r | |
220 | ast.py keyword.py sre_constants.py\r | |
221 | atexit.py linecache.py sre_parse.py\r | |
222 | BaseHTTPServer.py locale.py stat.py\r | |
223 | binhex.py md5.py string.py\r | |
224 | bisect.py modulefinder.py StringIO.py\r | |
225 | calendar.py ntpath.py struct.py\r | |
226 | cmd.py numbers.py textwrap.py\r | |
227 | codecs.py optparse.py token.py\r | |
228 | collections.py os.py tokenize.py\r | |
229 | copy.py platform.py traceback.py\r | |
230 | copy_reg.py posixpath.py types.py\r | |
231 | csv.py pydoc.py warnings.py\r | |
232 | dummy_thread.py random.py weakref.py\r | |
233 | fileinput.py re.py xmllib.py\r | |
234 | formatter.py repr.py zipfile.py\r | |
aafc4dcf | 235 | functools.py runpy.py expat\r |
d78fab6b | 236 | \r |
237 | # # #\r |