gpt4 book ai didi

具有所有依赖项的 Python Windows 安装程序?

转载 作者:太空狗 更新时间:2023-10-29 17:34:33 26 4
gpt4 key购买 nike

我在 PyPI 存储库中有一个包。我通过运行以下命令上传新版本(特别是“bdist_wininst”)来包含 Windows 安装程序:

python3 setup.py register sdist bdist_wininst upload

但是,当用户运行关联的 .exe 文件时,它不会安装 Python 3 本身。此外,即使安装了 Python 3,它也不会安装任何相关的依赖项。

如果没有安装 Python 3,那么创建一个 Windows 安装程序的最佳方法是什么,以及我的包及其依赖项?

如果这不可能,假设安装了 Python 3,创建将安装我的包及其依赖项的 Windows 安装程序的最佳方法是什么?

我在 Ubuntu 12.04 上。如果有任何帮助,这是我的 setup.py:

from distutils.core import setup

import codecs
try:
codecs.lookup('mbcs')
except LookupError:
ascii = codecs.lookup('ascii')
func = lambda name, enc=ascii: {True: enc}.get(name=='mbcs')
codecs.register(func)

setup(
name='SIGACTor',
version='0.1.14dev',
description=open('README.txt').read(),
url='http://bitbucket.org/davidystephenson/sigactor',
author='David Y. Stephenson',
author_email='david@davidystephenson.com',
packages=['sigactor'],
license='Proprietary',
long_description=open('README.txt').read(),
install_requires=[
'beautifulsoup4',
'feedparser',
'python-dateutil',
'pyyaml'
],
)

最佳答案

你应该明确地尝试 pynsist,它可以将 Python 与你的包捆绑在一起,并且基于完善的 NSIS 开源安装程序:

https://pypi.python.org/pypi/pynsist

Anaconda团队再次提供了基于conda和NSIS的Constructor:

https://github.com/conda/constructor

最后,这种方法使用 WinPython 和最稳定的安装程序 InnoSetup:

http://cyrille.rossant.net/create-a-standalone-windows-installer-for-your-python-application/

但如果你的包不是一个库而是一个应用程序,那么你可以将它与 Python 和所有依赖项捆绑(卡住),甚至可以使用 pyinstaller 压缩它:

http://www.pyinstaller.org

这就是我在所有应用程序中使用的,即使有疯狂的互操作依赖!

奖励 - pyinstaller 的自动更新工具:

https://github.com/JMSwag/PyUpdater

关于具有所有依赖项的 Python Windows 安装程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17428199/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com