简体   繁体   English

我应该在模块的requirements.txt中包含Sphinx和/或Nose吗?

[英]Should I include Sphinx and/or Nose in my module's requirements.txt?

I've created a Python module on Github that uses Nose for unit testing and Sphinx for generating documentation. 我在Github上创建了一个Python模块,它使用Nose进行单元测试,使用Sphinx生成文档。 I have two questions: 我有两个问题:

  • Should I include Sphinx and/or Nose in my module's dependencies in setup.py (install_requires), as they are not required for basic module functionality, only if you want to build the documentation/run tests yourself? 我应该在我的模块的setup.py(install_requires)依赖项中包含Sphinx和/或Nose,因为它们不是基本模块功能所必需的,只有你想自己构建文档/运行测试?

  • Should I include Sphinx and/or Nose in my module's requirements.txt on Github, for the same reasons but users that download my project from Github might be more likely to build docs/run tests? 我是否应该在Github上的模块的requirements.txt中包含Sphinx和/或Nose,原因相同但是从Github下载我的项目的用户可能更有可能构建docs / run测试?

This is my first Python module, so a bit of best practices/standards advice would be appreciated. 这是我的第一个Python模块,因此我们将非常感谢您提供一些最佳实践/标准建议。

If nose and/or sphinx are not required for the basic functionality of your package then don't include them in setup.py . 如果包的基本功能不需要nose和/或sphinx ,则不要将它们包含在setup.py There's no point in forcing users to install packages that they might not ever use. 强迫用户安装他们可能永远不会使用的软件包是没有意义的。 If they eventually want to help you develop your package they can install the requisite packages themselves. 如果他们最终想帮助您开发包,他们可以自己安装必需的包。

requirements.txt files should also not include development-required packages, though there's some wiggle room there. requirements.txt文件也不应该包含开发所需的包,尽管那里有一些摆动空间。

For example, over at pandas we use requirements files for our Travis-CI builds. 例如,在pandas我们使用Travis-CI构建的需求文件。 You can check them out here . 你可以在这里查看

One thing we are considering is building our documentation on Travis-CI, as sometimes a failed doc build catches bugs that the test suite doesn't. 我们正在考虑的一件事是在Travis-CI上构建我们的文档,因为有时失败的doc构建会捕获测试套件没有的错误。 In that case we would put sphinx in the requirements file of the Python version we use to build the documentation. 在这种情况下,我们 sphinx放在我们用来构建文档的Python版本的requirements文件中。

Don't include those nice-to-haves in your setup.py. 不要在setup.py中包含那些有用的东西。 You can write a requirements file for developers if you like; 如果您愿意,可以为开发人员编写需求文件; users won't need one. 用户不需要一个。 For example, call one file reqs.development : 例如,调用一个文件reqs.development

-e . # include the package defined by setup.py in editable (development) mode
nose
sphinx

Users can pip install yourmodule or pip install https://your/tarball , developers can fork, clone and pip install -r reqs.development . 用户可以pip install yourmodulepip install https://your/tarball ,开发人员可以fork,clone和pip install -r reqs.development

暂无
暂无

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

相关问题 如何优化我的 requirements.txt 以仅包含我的应用程序直接使用的包? - How can I optimize my requirements.txt to include only the packages my application uses directly? 对于 pip,我应该从 pip 冻结创建 requirements.txt,还是手动编辑 requirements.txt 文件? - With pip, should I create requirements.txt from pip freeze, or by manually editing the requirements.txt file? 我应该多久在我的 python 项目中运行 requirements.txt 文件? - How often should i run requirements.txt file in my python project? 我应该使用什么来管理团队中的软件包依赖关系:requirements.txt或setup.py? - What should I use to manage package dependencies in my team: requirements.txt or setup.py? 我应该在我的 Git 存储库中还是在专用的父目录中运行“pip install -r requirements.txt”? - Should I run "pip install -r requirements.txt" inside of my Git repository, or in a dedicated parent directory? 我的 requirements.txt 中的 Scikit-learn 并成功安装,但我仍然收到 ModuleNotFoundError: No module named 'sklearn' - Scikit-learn in my requirements.txt & it installs successfully, but I still get ModuleNotFoundError: No module named 'sklearn' "找不到 gunicorn 命令,但它在我的 requirements.txt 中" - gunicorn command not found, but it's in my requirements.txt 在Python wheel中包含requirements.txt文件 - Include requirements.txt file in Python wheel 在requirements.txt中包含python版本吗? - Include python version in requirements.txt? 我可以在我的 requirements.txt 中有一个可编辑的条目吗? - Can I have an editable entry in my requirements.txt?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM