It is simple description for how to build self-defined Python package.
Assume following folder structure in boot device
FS0:--+--EFI--+--Boot
| |
| +--StdLib--lib--python.27
| |
| +--Tools
|
+--Tools-+-Python.efi
| |
| +-CpuIds.py
|
+--ToolsPkg-+-__init__.py
|
+-CpuId.py
Python.efi is at FS0:\EFI\Tools
Self-defined package is FS0:\ToolsPkg and executable python tool is at FS0:\Tools.
Any python program in FS0:\Tools will import Python module in FS0:\ToolsPkg.
First, We have to set EFI shell environment, named "PYTHONPATH".
Second, Create __init__.py in FS0:\ToolsPkg, each sub-folder has to have __init__.py, too.
Third, make sure EFI shell environment "path" including FS0:\Tools
For example, This script file "Startup.nsh" run "CpuIds.py", automatically, while system boot into shell.
fs0:
set PYTHONPATH fs0:\ToolsPkg
Python.efi fs0:\Tools\CpuIds.py
Explanation:
fs0:\ToolsPkg folder includes __init__.py and CpuId.py, which is used by CpuIds.py in FS0:\Tools
#
# CpuIds.py
#
import CpuId.py
No comments:
Post a Comment