
# PyInstaller构建
使用PyInstaller工具可以将Python脚本打包成独立的可执行文件。
- [图形化构建]
  在[配置构建步骤](https://support.huaweicloud.com/usermanual-codeci/codeci_ug_0059.html)中，添加"PyInstaller构建"构建步骤，参考[表1]配置参数。
   表1PyInstaller构建参数说明 
  | **参数**    | **说明**                                                                                                                                                                                                                                                                                                                                                                    |
  |:---|:---|
  | 步骤显示名称    | 构建步骤的名称，可自定义修改。 - 支持中文、英文、数字、"-"、"_"、英文逗号、英文分号、英文冒号、"."、"/"、圆括号（中英文）。  - 字符长度范围为1\~128。   |
  | 工具版本      | 根据用户实际开发环境的需要，选择对应的工具版本。 CodeArts Build支持的工具版本，可查看[构建工具版本](https://support.huaweicloud.com/productdesc-codeci/cloudbuild_07_0004.html)。若当前的工具版本不满足您的使用要求，您可以[制作镜像并推送到SWR仓库](https://support.huaweicloud.com/usermanual-codeci/codeci_ug_0013.html)。                                                                                     |
  | 命令        | 配置构建打包命令，默认命令是将项目打包成一个可执行文件。更多命令使用方法可参考[PyInstaller官网](https://pyinstaller.readthedocs.io/en/stable/usage.html)。                                                                                                                                                                                                                                                          |
  | 失败后是否继续运行 | 当前步骤执行失败后是否继续执行下一个步骤，根据实际使用场景选择是或否。                                                                                                                                                                                                                                                                                                                                       |
     
- [代码化构建]
  参考以下代码示例，修改在[创建代码化构建使用的YAML文件](https://support.huaweicloud.com/usermanual-codeci/codeci_ug_0058.html#codeci_ug_0058__section72391847131511)中的BUILD部分代码信息。
  ```
  version: 2.0 # 必须是2.0
  steps:
    BUILD:
      - python: 
          name: PyInstaller构建
          image: cloudbuild@python3.6
          inputs: 
            command: |
              pip config set global.index-url https://pypi.org/simple
              pip config set global.trusted-host repo.xxcloud.com
              # -F创建单一的可执行文件，文件位置在dist目录下
              # 详细命令参见： https://pyinstaller.readthedocs.io/en/stable/usage.html
              pyinstaller -F  *.py
            ignore_fail: true
  ```
  表2代码示例参数说明 
  | **参数**      | **类型** | **说明**                                                                                                                                                                                                                                                                                                                                                                                                                   |
  |:---|:---|:---|
  | name        | string | 可选参数。 构建步骤的名称，可自定义修改。 - 支持中文、英文、数字、"-"、"_"、英文逗号、英文分号、英文冒号、"."、"/"、圆括号（中英文）。  - 字符长度范围为1\~128。   |
  | image       | string | 可选参数。 填写镜像版本，"cloudbuild@"为固定部分，后面为支持的Python版本。 CodeArts Build支持的工具版本，可查看[构建工具版本](https://support.huaweicloud.com/productdesc-codeci/cloudbuild_07_0004.html)。若当前的工具版本不满足您的使用要求，您可以[制作镜像并推送到SWR仓库](https://support.huaweicloud.com/usermanual-codeci/codeci_ug_0013.html)。 默认值：cloudbuild@python3.6。            |
  | command     | string | 配置构建打包命令，默认命令是将项目打包成一个可执行文件。更多命令使用方法可参考[PyInstaller官网](https://pyinstaller.readthedocs.io/en/stable/usage.html)。                                                                                                                                                                                                                                                                                                         |
  | ignore_fail | string | 用于控制当前步骤执行失败后是否继续执行下一个步骤。 - true：是。  - 为空：否。                                                                                                                 |
     
