[英]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.