用python项目捆绑第三方库的最佳做法是什么? (对于没有互联网的用户) [英] What is the best practice for bundling third party libraries with your python project? (for users with no Internet)
问题描述
我正在尝试构建一个包含几个开放源代码第三方库的项目,但是我想将我的发行版与所述库绑定在一起,因为我希望我的用户希望在没有Internet连接的情况下使用我的项目。另外,我想把他们的代码保持100%不变,甚至可以把目录结构保持原样。到目前为止,我的方法是提取tarball并将整个文件夹放在 MyProject / lib
中,但是我不得不把 __ init __。py
在每个子目录中,以便能够引用我自己的模块中的第三方代码。
I'm trying to build a project which includes a few open source third party libraries, but I want to bundle my distribution with said libraries - because I expect my users to want to use my project without an Internet connection. Additionally, I'd like to leave their code 100% untouched and even leave their directory structure untouched if I can. My approach so far has been to extract the tarballs and place the entire folder in MyProject/lib
, but I've had to put __init__.py
in every sub-directory to be able to reference the third-party code in my own modules.
完成此任务的常见最佳做法是什么? ?如何通过保留项目结构来最好地尊重应用程式的开发人员?我如何在我的代码中导入这些库不那么痛苦?
What's the common best practice for accomplishing this task? How can I best respect the apps' developers by retaining their projects' structure? How can I make importing these libraries in my code less painful?
我是一个在Python中编写可分发项目的新手,所以我不知道是否有东西可以在 __ init __。py
或 setup.py
中进行操作,以使自己不必键入从lib.app_name.app_name.app_module包括*
和whatnot。
I'm new to making a distributable project in Python, so I've no clue if there's something I can do in __init__.py
or in setup.py
to keep myself from having to type from lib.app_name.app_name.app_module include *
and whatnot.
对于什么是值得的,我将在OS X上分发, * nix中。我想避免使用另一个库(例如 setuptools
)来完成此操作。 (奇怪的是,它似乎已经安装在我的系统上,但是我没有安装它,所以我不知道发生了什么。)
For what it's worth, I will be distributing this on OS X and possibly *nix. I'd like to avoid using another library (e.g. setuptools
) to accomplish this. (Weirdly, it seems to already be installed on my system, but I didn't install it, so I've no idea what's going on.)
我意识到这个问题似乎与这一个重复,但我不认为是因为我要求分配第三方代码与自己的方法的最佳做法。请原谅我,如果我在问垃圾问题。
I realize that this question seems to be a duplicate of this one, but I don't think it is because I'm asking for the best practice for the "distribute-the-third-party-code-with-your-own" approach. Please forgive me if I'm asking a garbage question.
推荐答案
buildout 是构建和分发Python软件的好解决方案。
buildout is good solution for building and distributing Python software.
这篇关于用python项目捆绑第三方库的最佳做法是什么? (对于没有互联网的用户)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!