尝试在 Gitlab CI/CD Pipeline 中使用“cx_Freeze”创建 MSI 安装程序时,命令“bdist_msi”无效

问题描述 投票:0回答:1

我正在使用

py setup.py bdist_msi
为我的 python 应用程序生成 Windows 单个可执行文件。这在我的计算机上运行良好,但在 GitLab 管道中执行时不起作用。有谁知道如何解决这个问题?我在本地计算机和管道上使用 Python 3.11.8。这是错误:

这是我的 setup.py 文件:

from cx_Freeze import setup, Executable
import sys



directory_table = [("ProgramMenuFolder", "TARGETDIR", "."),
                   ("MyProgramMenu", "ProgramMenuFolder", "MYPROG~1|My Program")]

msi_data = {"Directory": directory_table,
            "ProgId": [("Prog.Id", None, None, "This is a description", "IconId", None)],
            "Icon": [("IconId", "matplotlib.ico")]}
files = ['param_list.py', 'mca_ioconfig_parser.py', 'mca_package_manifest_parser.py', 'mca_rti_log_parser.py',
         'ui_interface.py', 'resources_rc.py']
bdist_msi_options = {"add_to_path": False,
                     "data": msi_data,
                     'initial_target_dir': r'[ProgramFilesFolder]%s' % 'yammiX',
                     "upgrade_code": "{96a85bac-52af-4019-9e94-3afcc9e1ad0c}"}

build_exe_options = {"excludes": [], "includes": []}
executables = Executable(script="toolName.py",
                         base="Win32GUI" if sys.platform == "win32" else None,
                         icon="matplotlib.ico",
                         shortcut_name="toolName",
                         shortcut_dir="DesktopFolder")
setup(name="toolName",
      version="0.1.5",
      author="toolName",
      description="",
      executables=[executables],
      options={"build_exe": build_exe_options,
               "bdist_msi": bdist_msi_options})

这是我的 yml 文件:

image: python:3.11.8
stages:
  - build
  - test
  - deploy

build-job:
  stage: build
  # Update stuff before building versions
  before_script:
    - apt-get update -q -y
    - apt install -y python3-pip
    - apt install -y python3-venv
    - python3 -m venv .venv
    - source .venv/bin/activate
    - python3 --version
    - python3 -m pip install -r requirements.txt
  script:
    - python3 setup.py -q bdist_msi

  artifacts:
    paths:
      - build/

unit-test-job:
  stage: test
  script:
    - echo "Running unit tests... This will take about few seconds."
    - echo "Code coverage is 100%"

deploy-job:
  stage: deploy
  script:
    - echo "Deploying application..."
    - echo "Application successfully deployed."
python gitlab-ci cx-freeze gitlab-ci.yml
1个回答
0
投票

bdist_msi
选项需要Windows系统。你的工作是使用 Linux。

请参阅 cx_Freeze 文档,其中指出(已添加重点):

在 Windows 上,您可以通过运行安装脚本来构建一个简单的安装程序,其中包含 cx_Freeze 为您的应用程序包含的所有文件:

python setup.py bdist_msi

cx_Freeze 不支持交叉编译。因此,您需要在 Windows GitLab 运行器上运行它,以便使用

cx_Freeze

创建 Windows 安装文件
© www.soinside.com 2019 - 2024. All rights reserved.