简体   繁体   English

如何打包我正在使用的python库我可以用我的应用程序分发它们并尽可能少依赖

[英]How to pack python libs I'm using so I can distribute them with my app and have as few dependencies as possible

How to pack python libs I'm using so I can distribute them with my app and have as few dependencies as possible and also not to conflict with different lib/version that is already on my system. 如何打包python libs我正在使用,所以我可以用我的应用程序分发它们,并尽可能少的依赖项,也不要与我系统上已有的不同的lib /版本冲突。

LE: Sorry i forgot to specify. LE:对不起,我忘了指定。 I will be doing this on linux. 我将在linux上这样做。 And I'm not referring in making my app a installable file like deb/rpm, etc but how to organize my files so like for example I'll be using cherrypy and sqlalchemy I'll ship those with my app and not put the user through the pain of installing all the dependencies by himself. 我并不是指我的应用程序是一个可安装的文件,如deb / rpm等,但如何组织我的文件,例如我将使用cherrypy和sqlalchemy我会发送与我的应用程序,而不是用户通过自己安装所有依赖项的痛苦。

您可以尝试freeze.py ,有关详细信息,请参阅http://wiki.python.org/moin/Freeze

试试py2exe

But if you make a deb with the correct dependencies listed the installer will download them for the user. 但如果您使用列出的正确依赖项进行deb,则安装程序将为用户下载它们。 That's the best way, as it's non redundant. 这是最好的方式,因为它不是多余的。

Maybe you could make a tar or zip with your deb and all the third-party deb's and an install script that just install all the debs in the correct order. 也许你可以用你的deb和所有第三方deb和一个安装脚本制作一个tar或zip,只需按正确的顺序安装所有的deb。 This way, if the user already has some package it wouldn't be installed again. 这样,如果用户已经有一些包,则不会再次安装。

You can have your users run the system from a startup script, and that script can fix the pythonpath ahead of time to put your versions first. 您可以让您的用户从启动脚本运行系统,该脚本可以提前修复pythonpath以将您的版本放在第一位。 For example if you put CherryPy, SQLAlchemy, etc. in an "external" subdirectory, you could try: 例如,如果您将CherryPy,SQLAlchemy等放在“外部”子目录中,您可以尝试:

# startproj.sh
script_path=`dirname $0`
export PYTHONPATH=${script_path}/external;${PYTHONPATH}
exec ${script_path}/projstartup.py

暂无
暂无

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

相关问题 如何打包我的Python 3程序,以便我可以发布它 - How to pack my Python 3 program so I can release it 如何打包和分发python程序(.py源代码),以便其他开发人员可以轻松安装所有必需的依赖项? - How to pack and distribute python program (.py source code) so that other developers can easily install all required dependencies? 如何使用 Python 分发 Electron 应用程序 - How can I distribute an Electron app with Python 如何全局安装 Python (dev) 依赖项,这样我就不必在每个 venv 中重新安装它们? - How to install Python (dev) dependencies globally so that I don't have to reinstall them in every venv? 如何使用 python -m 构建将 fonts 与我的 python package 一起分发? - How do I distribute fonts with my python package using python -m build? 如何在使用python时不分发我的秘密密钥(facebook api)? - how can I not distribute my secret key (facebook api) while using python? 如何使用需要驱动程序安装的依赖项打包和分发Python项目? - How can I package and distribute Python projects with dependencies that require driver installations? 如何分发 python 程序? - How can I distribute python programs? 如何格式化我的数据,以便我有相应的团队及其分数? (爬虫Python) - How can I format my data so that I have the corresponding teams with their scores? (Scrapy Python) 我在 python 中使用 append 有一些问题 - I have a few problems using append in python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM