【问题标题】:How to use bdist_rpm like bdist_wininst?如何像 bdist_wininst 一样使用 bdist_rpm?
【发布时间】:2023-03-28 00:53:01
【问题描述】:

我正在构建一个 Tkinter 应用程序并将其分发到 centos 和 win7

为win7打包时

python setup.py bdist_wininst --install-script script_to_create_shortcut.py

在开始菜单和桌面上都可以很好地使用启动器

但对于 CentOS

python setup.py bdist_rpm --install-script script_to_create_shortcut_for_linux.py

惨败

后来我意识到 rpm 需要 sh 文件才能执行,所以我使用了安装后脚本

python setup.py bdist_rpm --post-install=script_to_create_shortcut_for_linux.py

失败,因为它也是存储在 sh 文件中的 python 代码

现在,我编写了一个运行 python -c "from module import post_install_script" 的 sh 文件 但这也失败了,因为安装后脚本找不到正确的函数名称

setup.py

setup=(..
      scripts=[os.path.join('tickets','complaints.py'),
               os.path.join('tickets','shortcut_linux.py'),
               os.path.join('tickets','tickets.svg')],
...)

快捷方式创建者或安装后 python 脚本

        file_created(os.path.join(sys.prefix,'bin','complaints.py'))
        desktop=get_special_folder_path("CSIDL_COMMON_DESKTOPDIRECTORY")
        startmenu=get_special_folder_path("CSIDL_COMMON_STARTMENU")
        create_shortcut(os.path.join(sys.prefix,'bin','complaints.py'),
                        "Complaints Register",
                        os.path.join(desktop,'complaints.desktop'),
                        '','',
                        os.path.join(sys.prefix,'bin','tickets.svg'))
        file_created(os.path.join(desktop,'complaints.desktop'))
        create_shortcut(os.path.join(sys.prefix,'bin','complaints.py'),
                        "Complaints Register",
                        os.path.join(startmenu,'complaints.desktop'),
                        '','',
                        os.path.join(sys.prefix,'bin','tickets.svg'))

失败并出现错误全局名称 file_created 未定义...

为什么 rpm 不像 wininst 那样简单,它做的一切都非常简单

我花了太多时间在这...任何帮助将不胜感激 谢谢

注意:对于wininst,快捷方式文件有不同的路径,例如:它有'bin'

【问题讨论】:

  • file_created 应该来自哪里?哪个模块有这个功能?
  • 我关注这个,它是安装后脚本的文档docs.python.org/2/distutils/…
  • 您也意识到CSIDL_* 是仅限Windows 的路径,对吧? file_created 似乎也是一个仅限 Windows 的 bdist 函数。您不能只运行您的 for-Windows 脚本并期望它生成一个 rpm。您需要使用 bdist_rpm 并进行适当的配置。
  • 哦,我的坏..所以没有在 linux 中创建快捷方式的选项吗?使用后安装脚本,我的意思是任何解决方法?我的知识很少..
  • 我不知道bdist_rpm 提供了什么。您当然可以创建这样的快捷方式。有关于主要台式机如何做到这一点的规范。它们涉及创建一个特殊文件并将其注册到我相信的系统(但我不确定,因为我不使用它们)。

标签: python tkinter centos rpm distutils


【解决方案1】:

你是否在Windows/CentOs? 中构建rpm 如果是centos system,则需要安装rpm-build package 用于构建rpm 使用->

python setup.py bdist_rpm

首先,使用命令安装 rpm-build 包 ->

yum install rpm-build

然后,运行命令->

python setup.py bdist_rpm

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-02-03
    • 2021-09-09
    • 2015-04-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-01-12
    • 2012-04-28
    相关资源
    最近更新 更多