简体   繁体   English

适用于Python模块的Windows安装程序,其中包括依赖项

[英]Windows installer for Python module which includes dependencies

I have a python module with an entry point in its setup.py which points to __ main__.py. 我在其setup.py中有一个带有入口点的python模块,它指向__ main__.py。 I want to be able to distribute this module to my coworkers in such a way that they can install it using a windows installer, and execute the entry point from the command line. 我希望能够将此模块分发给我的同事,以便他们可以使用Windows Installer来安装它,并从命令行执行入口点。 They already have Python installed on their computer. 他们已经在计算机上安装了Python。

The built-in python setup.py bdist_wininst functionality looked perfect, except that my module has a third party module dependency, and for some reason, bdist_wininst does not install dependencies even if they are specified in the setup's install_requires . 内置的python setup.py bdist_wininst功能看起来很完美,除了我的模块具有第三方模块依赖项,并且由于某些原因,即使在安装程序的install_requires中指定了依赖项,bdist_wininst也不会安装依赖项。

All-in-one windows exe solutions such as py2exe or pyinstaller are not suitable since the entry point requires input, and I want the user to be able to specify the input via the command line. 诸如py2exe或pyinstaller之类的多合一Windows exe解决方案不适合,因为入口点需要输入,并且我希望用户能够通过命令行指定输入。

Of course, I could distribute the module source files and have my coworkers run python setup.py install, but they will be too afraid - they are not programmers. 当然,我可以分发模块源文件,并让我的同事运行python setup.py install,但是他们会很害怕-他们不是程序员。

Yes, it would be possible to use an application like Nullsoft NSIS to build an installer that would install your python package, but it will require more code and an extra build step. 是的,可以使用Nullsoft NSIS之类的应用程序来构建将安装python软件包的安装程序,但是这将需要更多的代码和额外的构建步骤。

Do your coworkers have pip and setuptools installed? 您的同事是否已安装pip和setuptools? Are you able to distribute your package on pypi? 您可以在pypi上分发您的软件包吗? If so, it would be really simple for your coworkers to just do pip install mypackage . 如果是这样,那么对您的同事来说,只需执行pip install mypackage It has the added benefit of handling dependencies and if you use python wheels, your users don't require a build environment to install your package. 它具有处理依赖项的额外好处,如果您使用python wheel,则用户不需要构建环境即可安装软件包。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM