在项目中包含库。最佳实践

发布于 2024-08-26 22:29:40 字数 375 浏览 4 评论 0原文

我正在编写一个 Python 开源应用程序。我的应用程序使用一些开源 Python 库。这些库又使用其他开源库。

我打算在 Sourceforge 或 Google Code 上发布我的代码,但我是否需要包含其他库的源代码?这是一个好的做法吗? ...或者我应该简单地将这些信息写入自述文件中,通知其他所需库的使用。

我已将所有这些库放入源目录中的 libs 子文件夹中。将我的代码签入 SVN 时,我应该使用名为 svn:externals 的东西来链接到其他源吗?

有没有办法将我的库动态更新到最新版本,或者这是我在发布新版本时必须手动执行的操作。

如果我的问题听起来含糊不清,我表示最诚挚的歉意,但我在这件事上很迷茫,我不知道要谷歌什么。

谢谢大家。

I'm writing a Python open-source app. My app uses some open source Python libraries. These libraries in turn use other open-source libraries.

I intend to release my code at Sourceforge or Google Code but do I need to include the sources of the other libraries? Is this a good practice? ...or should I simply write this information into a README file informing the use about the other required libraries.

I've placed all these libraries into a libs sub folder in my source directory. When checking my code into SVN, should I use something called svn:externals to link to other sources?

Is there a way to dynamically update my libraries to the latest version or is this something I have to do manually when I release a new version.

My sincerest apologies if my question sounds vague but I'm pretty lost in this matter and I don't know what to Google for.

Thanks all.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

小兔几 2024-09-02 22:29:40

使用 pip 要求文本文件。

只需命名包[和可选版本]

要求用户执行自述文件中的以下命令。 (如果您提供安装脚本,那么您应该在其中调用此脚本;在这种情况下,您还应该使用 Virtualenv

pip install -r requirements.txt

并且您包含在需求中的所有库都将安装在该环境中。

您还可以在 pip 要求中包含 svn 路径、git 路径、mercurial 路径或 bzr 路径。

请参阅文档:http://pip.openplans.org/requirement-format.html

如果你的所有库都可以从 svn 获得,并且你的所有包用户都从 svn 安装它,你也可以使用 svn externals;但 pip 更干净。

Use the pip requirements text file.

Just name the packages [and optionally version]

Ask the users to execute the following command in the README. (If you provide an install script, then you should call this within that; In that case you should also use Virtualenv)

pip install -r requirements.txt

and all the libraries you included in the requirements will be installed in that environment.

You can also include svn path, git path, mercurial path, or bzr path in the pip requirements.

Refer to the documentation: http://pip.openplans.org/requirement-format.html

If all your libraries are available from svn, and all your package users install it from the svn, you can also use svn externals; But pip is a lot more cleaner.

流星番茄 2024-09-02 22:29:40

正如其他人所说,不要包含库,在文档中说明要求。这样,您的项目就可以使用用户已有的库,有时是由其操作系统发行版提供的。

但是,请记住那些可能存在于不同版本甚至配置中的外部依赖项。尽可能选择库的稳定分支(而不是前沿开发快照)。当您确实需要库的特定快照时,将其包含在您的包中可能是一个更好的选择,而不是强迫用户在其系统中安装非标准的东西。

As others say, do not include the libraries, state the requirements in documentation. This way your project can use the libraries users already have, sometimes provided by their operating system distribution.

But then, keep in mind those external dependencies, that may exist in different versions or even configurations. Choose a stable branch (not the bleeding edge development snapshots) of the libraries whenever possible. When you really need a specific snapshot of the library, then including it in your package may be a better choice then forcing users to install something non-standard in their systems.

清欢 2024-09-02 22:29:40

通常,您只需将库包含在最终发布的版本中,但不一定将它们包含在源版本中。

Normally you would just include the libraries in the final released version, but not necessarily include them in the source releases.

我认为最常见的做法是在 README.txt 文件中告知用户您的代码使用了哪些库和版本号。您可以为您的代码创建一个 Python Egg 包,其中包含库依赖项(如果它们也有 Egg),可以在安装时与您的包一起下载。使用 setuptools 包创建 python Egg。

I think the most common practice is to inform your user which libraries and version numbers your code uses in something like a README.txt file. You can create a Python Egg package for you code that includes the library dependencies (if they have eggs as well), that can be download with your package upon installation. Use the setuptools package to create python eggs.

酷到爆炸 2024-09-02 22:29:40

一般来说(对于 Python):不要提供代码中依赖的其他库的源代码。

只需在网站上和源附带的说明中说明所需的依赖项(包括所需的最低版本、安装说明等)。

In general (for Python): don't ship the source of other libraries which you depend upon in your code.

Just state the required dependencies (complete with minimum required version, installation instructions etc) on a website and in instructions shipped with the source.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文