我应该如何将 Python 模块拆分为 PyPi 包?
我已经编写了一个 Python 模块,我希望将其提供给其他人。现在,它是一个嵌套在子文件夹中的大模块:
- wraith
- 实用程序
- 分机
- 颜色
我认为最好将这些子文件夹分成单独的包。 tipfy 项目执行此操作。但是,ext 和 color 模块依赖于 util。
组织和发布这些模块的最佳方式是什么?我是否将它们分开并命名为 wraith.util、wraith.ext 和 < em>wraith.color 像tipfy一样?当人们安装 ext 或 color 时,我是否包含 util?
I have written a Python module that I'd like to make available for others. Right now, it is one large module nested into sub-folders:
- wraith
- util
- ext
- color
I think it's best to split these sub-folders up into separate packages. The tipfy project does this. However, the ext and color modules depend on util.
What's the best way to organize and release these modules? Do I split them up and name them wraith.util, wraith.ext, and wraith.color like tipfy? Do I include util when people install ext or color?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果 wraith.ext 等本身没有用,则无需拆分。你能想象有人会在不安装 wraith.color 的情况下使用 wrait.util 吗?
如果您决定拆分,则需要在 setup.py 中设置 install_requires ,它告诉 setuptools 等程序包依赖项。此外,您还需要设置 namespace_packages 告诉 wrait 命名空间也将接收其他包。
更多信息
http:// /tarekziade.wordpress.com/2011/08/19/5-tips-for-packaging-your-python-projects/
http://packages.python.org/distribute/setuptools.html
If wraith.ext etc. are not useful on their own it is not necessary to split. Can you imagine someone would use wrait.util without installing wraith.color?
If you decide to split you need to set install_requires in setup.py which tells setuptools etc. the package dependencies. Also you need to set-up namespace_packages telling that wrait namespace will receive other packages too.
More info
http://tarekziade.wordpress.com/2011/08/19/5-tips-for-packaging-your-python-projects/
http://packages.python.org/distribute/setuptools.html